当前位置: 首页>>代码示例>>Java>>正文


Java GroupSequence类代码示例

本文整理汇总了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;
    }
}
 
开发者ID:hibernate,项目名称:beanvalidation-benchmark,代码行数:19,代码来源:MetaJavaBean.java

示例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();
}
 
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:45,代码来源:GwtSpecificValidatorCreator.java


注:本文中的javax.validation.GroupSequence类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。