Package javax.validation.constraints

Examples of javax.validation.constraints.NotNull


    FrenchAddress address = getFrenchAddressWithoutZipCode();
    Set<ConstraintViolation<FrenchAddress>> constraintViolations = validator.validate( address );
    assertCorrectNumberOfViolations( constraintViolations, 1 );
    ConstraintViolation<FrenchAddress> constraintViolation = constraintViolations.iterator().next();
    assertCorrectConstraintTypes( constraintViolations, NotNull.class );
    NotNull notNull = (NotNull) constraintViolation.getConstraintDescriptor().getAnnotation();
    List<Class<?>> groups = Arrays.asList( notNull.groups() );
    assertTrue( groups.size() == 2, "There should be two groups" );
    assertTrue( groups.contains( Default.class ), "The default group should be in the list." );
    assertTrue(
        groups.contains( FrenchAddress.FullAddressCheck.class ),
        "The FrenchAddress.FullAddressCheck group should be inherited."
View Full Code Here


            // not expecting this to be used on assoc one properties
            prop.setExtraWhere(where.clause());
        }

        if (validationAnnotations) {
          NotNull notNull = get(prop, NotNull.class);
          if (notNull != null) {
              prop.setNullable(false);
              // overrides optional attribute of ManyToOne etc
              prop.getTableJoin().setType(SqlJoinType.INNER);
          }
View Full Code Here

    FrenchAddress address = getFrenchAddressWithoutZipCode();
    Set<ConstraintViolation<FrenchAddress>> constraintViolations = validator.validate( address );
    assertCorrectNumberOfViolations( constraintViolations, 1 );
    ConstraintViolation<FrenchAddress> constraintViolation = constraintViolations.iterator().next();
    assertCorrectConstraintTypes( constraintViolations, NotNull.class );
    NotNull notNull = (NotNull) constraintViolation.getConstraintDescriptor().getAnnotation();
    List<Class<?>> groups = Arrays.asList( notNull.groups() );
    assertTrue( groups.size() == 2, "There should be two groups" );
    assertTrue( groups.contains( Default.class ), "The default group should be in the list." );
    assertTrue(
        groups.contains( FrenchAddress.FullAddressCheck.class ),
        "The FrenchAddress.FullAddressCheck group should be inherited."
View Full Code Here

            return dataType;
        }

        public boolean notNull()
        {
            final NotNull n = mMethod.getAnnotation(NotNull.class);
            return n != null;
        }
View Full Code Here

    FrenchAddress address = getFrenchAddressWithoutZipCode();
    Set<ConstraintViolation<FrenchAddress>> constraintViolations = validator.validate( address );
    assertCorrectNumberOfViolations( constraintViolations, 1 );
    ConstraintViolation<FrenchAddress> constraintViolation = constraintViolations.iterator().next();
    assertCorrectConstraintTypes( constraintViolations, NotNull.class );
    NotNull notNull = ( NotNull ) constraintViolation.getConstraintDescriptor().getAnnotation();
    List<Class<?>> groups = Arrays.asList( notNull.groups() );
    assertTrue( groups.size() == 2, "There should be two groups" );
    assertTrue( groups.contains( Default.class ), "The default group should be in the list." );
    assertTrue(
        groups.contains( FrenchAddress.FullAddressCheck.class ),
        "The FrenchAddress.FullAddressCheck group should be inherited."
View Full Code Here

    FrenchAddress address = getFrenchAddressWithoutZipCode();
    Set<ConstraintViolation<FrenchAddress>> constraintViolations = validator.validate( address );
    assertCorrectNumberOfViolations( constraintViolations, 1 );
    ConstraintViolation<FrenchAddress> constraintViolation = constraintViolations.iterator().next();
    assertCorrectConstraintTypes( constraintViolations, NotNull.class );
    NotNull notNull = ( NotNull ) constraintViolation.getConstraintDescriptor().getAnnotation();
    List<Class<?>> groups = Arrays.asList( notNull.groups() );
    assertTrue( groups.size() == 2, "There should be two groups" );
    assertTrue( groups.contains( Default.class ), "The default group should be in the list." );
    assertTrue(
        groups.contains( FrenchAddress.FullAddressCheck.class ),
        "The FrenchAddress.FullAddressCheck group should be inherited."
View Full Code Here

                    // JSR 303 doesn't support method level validation
                    // we should provide at least a dummy implementation to detect @NotNull annotations
                    // we should migrate our implementation to bean validation 1.1 when possible
                    final Parameter parameter = invokable.getParameters().get(i);
                    final NotNull annotation = parameter.getAnnotation(NotNull.class);
                    if (annotation != null) {

                        final String parameterName = "arg" + i;
                        final ConstraintDescriptor<NotNull> descriptor = new SimpleConstraintDescriptor<NotNull>(
                                annotation, ImmutableSet.<Class<?>>of(Default.class),
                                ImmutableList.<Class<? extends ConstraintValidator<NotNull, ?>>>of(
                                    NotNullValidator.class), null);

                        final ConstraintViolation<Object> violation = new MethodConstraintValidationHolder<Object>(

                                // message
                                "may not be null",

                                // messageTemplate
                                annotation.message(),

                                // rootBean
                                invocationContext.getProxy(),

                                // leafBean (the object the method is executed on)
View Full Code Here

    FrenchAddress address = getFrenchAddressWithoutZipCode();
    Set<ConstraintViolation<FrenchAddress>> constraintViolations = validator.validate( address );
    assertCorrectNumberOfViolations( constraintViolations, 1 );
    ConstraintViolation<FrenchAddress> constraintViolation = constraintViolations.iterator().next();
    assertCorrectConstraintTypes( constraintViolations, NotNull.class );
    NotNull notNull = ( NotNull ) constraintViolation.getConstraintDescriptor().getAnnotation();
    List<Class<?>> groups = Arrays.asList( notNull.groups() );
    assertTrue( groups.size() == 2, "There should be two groups" );
    assertTrue( groups.contains( Default.class ), "The default group should be in the list." );
    assertTrue(
        groups.contains( FrenchAddress.FullAddressCheck.class ),
        "The FrenchAddress.FullAddressCheck group should be inherited."
View Full Code Here

        }
    }

    @Override
    public Boolean hasRequiredMarker(AnnotatedMember m) {
        NotNull annotation = m.getAnnotation(NotNull.class);
        if (annotation == null) {
            return null;
        }
        return Boolean.TRUE;
    }
View Full Code Here

            return dataType;
        }

        public boolean notNull()
        {
            final NotNull n = mMethod.getAnnotation(NotNull.class);
            return n != null;
        }
View Full Code Here

TOP

Related Classes of javax.validation.constraints.NotNull

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.