本文整理汇总了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;
}