@Override public Class<?> getContainerClass() { Contracts.assertTrue( kind == ElementKind.BEAN || kind == ElementKind.PROPERTY || kind == ElementKind.CONTAINER_ELEMENT, "getContainerClass() may only be invoked for nodes of type ElementKind.BEAN, ElementKind.PROPERTY or ElementKind.CONTAINER_ELEMENT." ); if ( parent == null ) { return null; } return parent.containerClass; }
@Override public Integer getTypeArgumentIndex() { Contracts.assertTrue( kind == ElementKind.BEAN || kind == ElementKind.PROPERTY || kind == ElementKind.CONTAINER_ELEMENT, "getTypeArgumentIndex() may only be invoked for nodes of type ElementKind.BEAN, ElementKind.PROPERTY or ElementKind.CONTAINER_ELEMENT." ); if ( parent == null ) { return null; } return parent.typeArgumentIndex; }
@Override public int getParameterIndex() { Contracts.assertTrue( kind == ElementKind.PARAMETER, "getParameterIndex() may only be invoked for nodes of type ElementKind.PARAMETER." ); return parameterIndex.intValue(); }
@Override public int getParameterIndex() { Contracts.assertTrue( kind == ElementKind.PARAMETER, "getParameterIndex() may only be invoked for nodes of ElementKind.PARAMETER." ); return parameterIndex.intValue(); }
public static Class<?> getErasedReferenceType(Type type) { Contracts.assertTrue( isReferenceType( type ), "type is not a reference type: %s", type ); return (Class<?>) getErasedType( type ); }
private static Class<?> getErasedReferenceType(Type type) { Contracts.assertTrue( isReferenceType( type ), "type is not a reference type: " + type ); return (Class<?>) getErasedType( type ); }
@Override public <A extends Annotation> ConstraintDefinitionContext<A> constraintDefinition(Class<A> annotationClass) { Contracts.assertNotNull( annotationClass, MESSAGES.annotationTypeMustNotBeNull() ); Contracts.assertTrue( annotationClass.isAnnotationPresent( Constraint.class ), MESSAGES.annotationTypeMustBeAnnotatedWithConstraint() ); if ( definedConstraints.contains( annotationClass ) ) { // Fail fast for easy-to-detect definition conflicts; other conflicts are handled in ValidatorFactoryImpl throw LOG.getConstraintHasAlreadyBeenConfiguredViaProgrammaticApiException( annotationClass ); } ConstraintDefinitionContextImpl<A> constraintContext = new ConstraintDefinitionContextImpl<>( this, annotationClass ); constraintContexts.add( constraintContext ); definedConstraints.add( annotationClass ); return constraintContext; }
@Override public <A extends Annotation> ConstraintDefinitionContext<A> constraintDefinition(Class<A> annotationClass) { Contracts.assertNotNull( annotationClass, MESSAGES.annotationTypeMustNotBeNull() ); Contracts.assertTrue( annotationClass.isAnnotationPresent( Constraint.class ), MESSAGES.annotationTypeMustBeAnnotatedWithConstraint() ); if ( definedConstraints.contains( annotationClass ) ) { // Fail fast for easy-to-detect definition conflicts; other conflicts are handled in ValidatorFactoryImpl throw log.getConstraintHasAlreadyBeenConfiguredViaProgrammaticApiException( annotationClass ); } ConstraintDefinitionContextImpl<A> constraintContext = new ConstraintDefinitionContextImpl<A>( this, annotationClass ); constraintContexts.add( constraintContext ); definedConstraints.add( annotationClass ); return constraintContext; }
public ContainerElementConstraintMappingContext containerElement(ContainerElementTarget parent, TypeConstraintMappingContextImpl<?> typeContext, ConstraintLocation location, int index, int... nestedIndexes) { Contracts.assertTrue( index >= 0, "Type argument index must not be negative" );