本文整理匯總了Java中org.lastaflute.core.message.UserMessages.add方法的典型用法代碼示例。如果您正苦於以下問題:Java UserMessages.add方法的具體用法?Java UserMessages.add怎麽用?Java UserMessages.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.lastaflute.core.message.UserMessages
的用法示例。
在下文中一共展示了UserMessages.add方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: registerActionMessage
import org.lastaflute.core.message.UserMessages; //導入方法依賴的package包/類
protected void registerActionMessage(UserMessages messages, ConstraintViolation<Object> vio) {
final String propertyPath = extractPropertyPath(vio);
final String plainMessage = filterMessageItem(extractMessage(vio), propertyPath);
final String delimiter = MESSAGE_HINT_DELIMITER;
final String messageItself;
final String messageKey;
if (plainMessage.contains(delimiter)) { // basically here
messageItself = Srl.substringFirstRear(plainMessage, delimiter);
messageKey = Srl.substringFirstFront(plainMessage, delimiter);
} else { // just in case
messageItself = plainMessage;
messageKey = null;
}
final ConstraintDescriptor<?> descriptor = vio.getConstraintDescriptor();
final Annotation annotation = descriptor.getAnnotation();
final Set<Class<?>> groupSet = descriptor.getGroups();
final Class<?>[] groups = groupSet.toArray(new Class<?>[groupSet.size()]);
messages.add(propertyPath, createDirectMessage(messageItself, annotation, groups, messageKey));
}
示例2: test_hasMessageOf
import org.lastaflute.core.message.UserMessages; //導入方法依賴的package包/類
public void test_hasMessageOf() throws Exception {
// ## Arrange ##
UserMessages messages = new UserMessages();
assertFalse(messages.hasMessageOf("sea"));
UserMessage message = new UserMessage("dockside", "over");
assertFalse(messages.isAccessed());
messages.add("sea", message);
// ## Act ##
// ## Assert ##
assertTrue(messages.hasMessageOf("sea"));
assertFalse(messages.hasMessageOf("land"));
assertFalse(messages.isAccessed());
}
示例3: test_hasMessageOf_key
import org.lastaflute.core.message.UserMessages; //導入方法依賴的package包/類
public void test_hasMessageOf_key() throws Exception {
// ## Arrange ##
UserMessages messages = new UserMessages();
assertFalse(messages.hasMessageOf("sea"));
UserMessage message = new UserMessage("dockside", "over");
assertFalse(messages.isAccessed());
messages.add("sea", message);
// ## Act ##
// ## Assert ##
assertTrue(messages.hasMessageOf("sea", "dockside"));
assertFalse(messages.hasMessageOf("sea", "hangar"));
assertFalse(messages.hasMessageOf("land", "dockside"));
assertFalse(messages.isAccessed());
}
示例4: doAddMessages
import org.lastaflute.core.message.UserMessages; //導入方法依賴的package包/類
protected void doAddMessages(UserMessages messages) {
final UserMessages existingOrCreated = get().orElseGet(() -> newUserMessages());
existingOrCreated.add(messages);
doSaveInfo(existingOrCreated);
}
示例5: prepareUserMessages
import org.lastaflute.core.message.UserMessages; //導入方法依賴的package包/類
protected UserMessages prepareUserMessages(String property, String messageKey, Object[] args) {
final UserMessages messages = newUserMessages();
messages.add(property, new UserMessage(messageKey, args));
return messages;
}