本文整理汇总了Java中javax.validation.GroupSequence类的典型用法代码示例。如果您正苦于以下问题:Java GroupSequence类的具体用法?Java GroupSequence怎么用?Java GroupSequence使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GroupSequence类属于javax.validation包,在下文中一共展示了GroupSequence类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildGroupSequenceAnnot
import javax.validation.GroupSequence; //导入依赖的package包/类
public MetaAnnotation buildGroupSequenceAnnot() {
if ( this.groups.isEmpty() ) {
return null; // No group sequence needed
}
else {
// Build the array of groups
JDefinedClass[] gs = new JDefinedClass[groups.size()+1];
int i=0;
for ( MetaGroup group : groups ) {
gs[i++] = group.getGeneratedClass();
}
gs[i] = getGeneratedClass(); // Add the class itself (acts as Default)
HashMap<String,Object> gsParams = Maps.newHashMap();
gsParams.put("value", gs);
MetaAnnotation gsAnnot = new MetaAnnotation(getGeneratedClass().owner(), GroupSequence.class, AnnotationType.OTHER, gsParams);
return gsAnnot;
}
}
示例2: writeBeanMetadata
import javax.validation.GroupSequence; //导入依赖的package包/类
private void writeBeanMetadata(final SourceWriter sw) throws UnableToCompleteException {
// private final BeanMetadata beanMetadata =
sw.println("private final BeanMetadata beanMetadata =");
sw.indent();
sw.indent();
// new BeanMetadata(
sw.println("new " + BeanMetadata.class.getSimpleName() + "(");
sw.indent();
sw.indent();
// <<bean class>>, <<default group seq class 1>>, <<default group seq class 2>>, ...
final Class<?> beanClazz = this.beanHelper.getClazz();
sw.print(asLiteral(beanClazz));
final GroupSequence groupSeqAnnotation = beanClazz.getAnnotation(GroupSequence.class);
final List<Class<?>> groupSequence = new ArrayList<>();
if (groupSeqAnnotation == null) {
groupSequence.add(beanClazz);
} else {
groupSequence.addAll(Arrays.asList(groupSeqAnnotation.value()));
}
boolean groupSequenceContainsDefault = false;
for (final Class<?> group : groupSequence) {
sw.println(",");
if (group.getName().equals(beanClazz.getName())) {
sw.print(asLiteral(Default.class));
groupSequenceContainsDefault = true;
} else if (group.getName().equals(Default.class.getName())) {
throw error(this.logger, "'Default.class' cannot appear in default group sequence list.");
} else {
sw.print(asLiteral(group));
}
}
if (!groupSequenceContainsDefault) {
throw error(this.logger,
beanClazz.getName() + " must be part of the redefined default group " + "sequence.");
}
sw.println(");");
sw.outdent();
sw.outdent();
sw.outdent();
sw.outdent();
}