Builds a new constraint from the annotation data.
@param anno JSR-303 annotation instance
@return a new constraint
555432
public static Constraint fromAnnotation(Annotation anno) {
		if (anno instanceof Min) {
			return min(((Min) anno).value());
		} else if (anno instanceof Max) {
			return max(((Max) anno).value());
		} else if (anno instanceof Size) {
			return size(((Size) anno).min(), ((Size) anno).max());
		} else if (anno instanceof Digits) {
			return digits(((Digits) anno).integer(), ((Digits) anno).fraction());
		} else if (anno instanceof Pattern) {
			return pattern(((Pattern) anno).regexp());
		} else {
			return new Constraint(VALIDATORS.get(anno.annotationType()),
					simplePayload(VALIDATORS.get(anno.annotationType()))) {
						public boolean isValid(Object actualValue) {
							return true;
						}
					};
		}
	}
49496
protected Map<String, Object> createVariableForConstraint(final ConstraintDescriptor<?> descriptor) {
        
        final Map<String, Object> vars = new HashMap<String, Object>();
        
        for(Map.Entry<String, Object> entry : descriptor.getAttributes().entrySet()) {
            final String attrName = entry.getKey();
            final Object attrValue = entry.getValue();
            
            // メッセージ変数で必要ないものを除外する
            if(EXCLUDE_MESSAGE_ANNOTATION_ATTRIBUTES.contains(attrName)) {
                continue;
            }
            
            vars.put(attrName, attrValue);
        }
        
        return vars;
        
    }
99593
public Configuration buildConfiguration() throws AnnotationRequired {

        if (!finder.isAnnotationPresent(Configure.class)) {
            // not using annotation configuration, default to most useful
            // configuration
            return new MostUsefulConfiguration();
        }

        Configuration configuration = configurationElement(finder, "using", Configuration.class);
        configuration.useKeywords(configurationElement(finder, "keywords", Keywords.class));
        configuration.useFailureStrategy(configurationElement(finder, "failureStrategy", FailureStrategy.class));
        configuration.usePendingStepStrategy(configurationElement(finder, "pendingStepStrategy",
                PendingStepStrategy.class));
        configuration.useParanamer(configurationElement(finder, "paranamer", Paranamer.class));
        configuration.useStoryControls(configurationElement(finder, "storyControls", StoryControls.class));
        configuration.useStepCollector(configurationElement(finder, "stepCollector", StepCollector.class));
        configuration.useStepdocReporter(configurationElement(finder, "stepdocReporter", StepdocReporter.class));
        configuration.useStepFinder(configurationElement(finder, "stepFinder", StepFinder.class));
        configuration.useStepMonitor(configurationElement(finder, "stepMonitor", StepMonitor.class));
        configuration.useStepPatternParser(configurationElement(finder, "stepPatternParser", StepPatternParser.class));
        configuration.useStoryLoader(configurationElement(finder, "storyLoader", StoryLoader.class));
        configuration.useStoryParser(configurationElement(finder, "storyParser", StoryParser.class));
        configuration.useStoryPathResolver(configurationElement(finder, "storyPathResolver", StoryPathResolver.class));
        configuration
                .useDefaultStoryReporter(configurationElement(finder, "defaultStoryReporter", StoryReporter.class));
        configuration.useStoryReporterBuilder(configurationElement(finder, "storyReporterBuilder",
                StoryReporterBuilder.class));
        configuration.useViewGenerator(configurationElement(finder, "viewGenerator", ViewGenerator.class));
        configuration.useTableTransformers(configurationElement(finder, "tableTransformers", TableTransformers.class));
        configuration.useParameterConverters(
                parameterConverters(finder, configuration.storyLoader(), configuration.tableTransformers()));
        configuration.useParameterControls(configurationElement(finder, "parameterControls", ParameterControls.class));
        configuration.usePathCalculator(configurationElement(finder, "pathCalculator", PathCalculator.class));
        return configuration;
    }
392678
private static Constraint loadConstraint(Annotation context) {
        Constraint constraint = null;
        final ServiceLoader<Constraint> constraints = ServiceLoader.load(Constraint.class);

        for (Constraint aConstraint : constraints) {
            try {
                aConstraint.getClass().getDeclaredMethod("check", context.annotationType());
                constraint = aConstraint;
                break;
            } catch (NoSuchMethodException e) {
                // Look for next implementation if method not found with required signature.
            }
        }

        if (constraint == null) {
            throw new IllegalStateException("Couldn't found any implementation of " + Constraint.class.getName());
        }
        return constraint;
    }
753404
function createAnnotation(desc) {
  utils.check(['type', 'hasTarget', 'annotatedBy'], desc);

  var anno = { type: desc.type, hasTarget: desc.hasTarget, annotatedAt : desc.annotatedAt || new Date().toISOString(), annotatedBy : desc.annotatedBy, state: desc.state || utils.states.annotations.unvalidated};

 // used to create a hierarchical position
 // FIXME reconcile roots / position
  var position = desc.roots || [], flattened = desc.type + unitSep;
  anno.roots = desc.roots || [];
  if (desc.type === 'quote') {
    utils.check(['ranges', 'quote'], desc);
    if (!desc.ranges || desc.ranges.length < 1) {
      utils.checkError(desc, 'missing ranges');
    }
    anno.quote = desc.quote;
    anno.ranges = desc.ranges;
    position.push(anno.quote);
    flattened += position.join(unitSep);
  } else if (desc.type === 'category') {
    utils.check(['category'], desc);
    anno.category = Array.isArray(desc.category) ? desc.category : [desc.category];
    position = position.concat(anno.category);
    flattened += position.join(unitSep);
  } else if (desc.type === 'value' || desc.type === 'valueQuote') {
    utils.check(['key', 'value'], desc);
    if (desc.type === 'valueQuote') {
      utils.check(['ranges'], desc);
      anno.ranges = desc.ranges;
    }
    anno.key = desc.key;
    anno.value = desc.value;
    position.push(desc.key);
    flattened += position.join(unitSep) + unitSep + desc.value;

// add data types
    if (desc.isA) {
      try {
        anno.isA = desc.isA;
        anno.typed = {};
        anno.typed[desc.isA] = dataTypes[desc.isA](desc.value);
      } catch (e) {
        anno.typed.failure = e;
        GLOBAL.warn('isA failed', e, desc);
      }
    }
  } else {
    throw new Error('unknown type ' + desc.type);
  }
  anno.position = position;
  anno.flattened = flattened;
  if (anno.attributes) {
    anno.attributes = desc.attributes; // additional attributes
  }
  return anno;
}
496610
protected String[] buildAnnotationConstraintParameters(Annotation annotation) {
		
		// Si l'annotation est nulle
		if(annotation == null) return null;
		
		// Si l'annotation est de type @AuthorizedValues
		if(annotation instanceof AuthorizedValues) return new String[] { Arrays.toString(((AuthorizedValues) annotation).values()) };
		
		// Si l'annotation est de type @Interval
		if(annotation instanceof Interval) return new String[] { Double.toString(((Interval) annotation).min()), Double.toString(((Interval) annotation).max()) };
		
		// Si l'annotation est de type @Length
		if(annotation instanceof Length) return new String[] { Integer.toString(((Length) annotation).min()), Integer.toString(((Length) annotation).max()) };
		
		// valeur par defaut
		return null;
	}
898350
public DocumentBuilder newDocumentBuilder() throws ParserConfigurationException
    {
        if(isValidating()) {
            try {
                return new ValidatingDocumentBuilder(
                    _WrappedFactory.newDocumentBuilder(),
                    _Schema.newVerifier());
            } catch(VerifierConfigurationException ex) {
                throw new ParserConfigurationException(ex.getMessage());
            }
        } else
            //if validation is disabled, we simply return the implementation of wrapped DocumentBuilder
            return _WrappedFactory.newDocumentBuilder();
    }
1026166
public static <T extends Annotation> Builder<T> builder(Class<T> annotationType) {
    return new Builder<T>(annotationType);
  }
689472
@SuppressWarnings("unchecked")
    public <A extends Annotation> A getAnnotation(final Field field, final Class<A> annClass) throws AnnotationReadException {
        
        final Class<?> clazz = field.getDeclaringClass();
        
        if(xmlInfo != null && xmlInfo.containsClassInfo(clazz.getName())) {
            final ClassInfo classInfo = xmlInfo.getClassInfo(clazz.getName());
            
            if(classInfo.containsFieldInfo(field.getName())) {
                FieldInfo fieldInfo = classInfo.getFieldInfo(field.getName());
                if(fieldInfo != null && fieldInfo.containsAnnotationInfo(annClass.getName())){
                    AnnotationInfo annInfo = fieldInfo.getAnnotationInfo(annClass.getName());
                    try {
                        return (A)annotationBuilder.buildAnnotation(Class.forName(annInfo.getClassName()), annInfo);
                    } catch (ClassNotFoundException e) {
                        throw new AnnotationReadException(String.format("not found class '%s'", annInfo.getClassName()), e);
                    }
                }
            }
        }
        return field.getAnnotation(annClass);
    }
715575
public Constraint not(Constraint constraint) {
        if (!(constraint instanceof Not))
            return new Not(constraint);

        return ((Not)constraint).getConstraint();
    }
1137570
public AnnotationValueBuilder<T> value(@Nullable AnnotationValue<?> annotation) {
        return member(AnnotationMetadata.VALUE_MEMBER, annotation);
    }
1317550
public BetaConstraints createBetaNodeConstraint(final BuildContext context,
                                                    final List<BetaNodeFieldConstraint> list,
                                                    final boolean disableIndexing) {
        BetaConstraints constraints;
        switch ( list.size() ) {
            case 0 :
                constraints = EmptyBetaConstraints.getInstance();
                break;
            case 1 :
                constraints = new SingleBetaConstraints( list.get( 0 ),
                                                         context.getKnowledgeBase().getConfiguration(),
                                                         disableIndexing );
                break;
            case 2 :
                constraints = new DoubleBetaConstraints( list.toArray( new BetaNodeFieldConstraint[list.size()] ),
                                                         context.getKnowledgeBase().getConfiguration(),
                                                         disableIndexing );
                break;
            case 3 :
                constraints = new TripleBetaConstraints( list.toArray( new BetaNodeFieldConstraint[list.size()] ),
                                                         context.getKnowledgeBase().getConfiguration(),
                                                         disableIndexing );
                break;
            case 4 :
                constraints = new QuadroupleBetaConstraints( list.toArray( new BetaNodeFieldConstraint[list.size()] ),
                                                             context.getKnowledgeBase().getConfiguration(),
                                                             disableIndexing );
                break;
            default :
                constraints = new DefaultBetaConstraints( list.toArray( new BetaNodeFieldConstraint[list.size()] ),
                                                          context.getKnowledgeBase().getConfiguration(),
                                                          disableIndexing );
        }
        return constraints;
    }
303735
public Mapper<K, V> constraint(Restraint<K, V> constraint) {
		return addConstraint(constraint);
	}
5018
public BeanType<ConstraintMappingsType<T>> getOrCreateBean()
   {
      List<Node> nodeList = childNode.get("bean");
      if (nodeList != null &&  nodeList.size() > 0)
      {
         return new BeanTypeImpl<ConstraintMappingsType<T>>(this, "bean", childNode, nodeList.get(0));
      }
      return createBean();
   }
643230
public AnnotationType<ElementType<T>> getOrCreateAnnotation()
   {
      List<Node> nodeList = childNode.get("annotation");
      if (nodeList != null &&  nodeList.size() > 0)
      {
         return new AnnotationTypeImpl<ElementType<T>>(this, "annotation", childNode, nodeList.get(0));
      }
      return createAnnotation();
   }
1327229
public void addConstraint(Constraint constraint) {
        if ( ConstraintType.ALPHA.equals(constraint.getType())) {
            this.addAlphaConstraint( (AlphaNodeFieldConstraint) constraint );
        } else if ( ConstraintType.BETA.equals(constraint.getType())) {
            this.addBetaConstraint( (BetaNodeFieldConstraint) constraint );
        } else {
            throw new RuntimeException( "Constraint type MUST be known in advance.");
        }
    }
400578
private void validateAnnotation(final FieldAccessor accessor, final XlsLabelledArrayCells anno) {

        // 左側のとき、水平方向の配列はサポートしない
        if(anno.type().equals(LabelledCellType.Left) && anno.direction().equals(ArrayDirection.Horizon)) {
            throw new AnnotationInvalidException(anno, MessageBuilder.create("anno.XlsLabelledArrayCell.notSupportTypeAndDirection")
                    .var("property", accessor.getNameWithClass())
                    .varWithAnno("anno", XlsLabelledArrayCells.class)
                    .varWithEnum("typeValue", anno.type())
                    .varWithEnum("directionValue", anno.direction())
                    .format());
        }

    }