use of javax.validation.constraints.NotNull in project vboard by voyages-sncf-technologies.
the class AuthenticationController method getSessionUserWithSyncFromDB.
@NotNull
public User getSessionUserWithSyncFromDB() {
final User sessionUser = this.getSessionUser();
if (ANONYMOUS_USER.equals(sessionUser)) {
return ANONYMOUS_USER;
}
final User dbUser = this.userDAO.findByEmail(sessionUser.getEmail());
if (dbUser == null) {
throw new VBoardException("No user found in DB for email=" + sessionUser.getEmail());
}
if (!dbUser.equals(this.getSessionUser())) {
this.logger.debug("Updating user in session cache");
this.session.setAttribute("User", dbUser);
}
return dbUser;
}
use of javax.validation.constraints.NotNull in project drill by axbaretto.
the class DrillMetaImpl method drillFieldMetaData.
// Overriding fieldMetaData as Calcite version create ColumnMetaData with invalid offset
protected static ColumnMetaData.StructType drillFieldMetaData(Class<?> clazz) {
final List<ColumnMetaData> list = new ArrayList<>();
for (Field field : clazz.getFields()) {
if (Modifier.isPublic(field.getModifiers()) && !Modifier.isStatic(field.getModifiers())) {
NotNull notNull = field.getAnnotation(NotNull.class);
boolean notNullable = (notNull != null || field.getType().isPrimitive());
list.add(drillColumnMetaData(AvaticaUtils.camelToUpper(field.getName()), list.size(), field.getType(), notNullable));
}
}
return ColumnMetaData.struct(list);
}
use of javax.validation.constraints.NotNull in project minijax by minijax.
the class MinijaxConstraintDescriptor method build.
@SuppressWarnings("unchecked")
public static <T extends Annotation> MinijaxConstraintDescriptor<T> build(final AnnotatedType annotatedType, final T annotation) {
final Constraint constraint = annotation.annotationType().getAnnotation(Constraint.class);
if (constraint == null) {
return null;
}
final Class<?> valueClass = ReflectionUtils.getRawType(annotatedType);
final Class<?> annotationClass = annotation.annotationType();
if (constraint.validatedBy().length > 0) {
return buildDeclaredValidator(annotation, constraint.validatedBy()[0]);
} else if (annotationClass == AssertFalse.class) {
return (MinijaxConstraintDescriptor<T>) buildAssertFalseValidator((AssertFalse) annotation, valueClass);
} else if (annotationClass == AssertTrue.class) {
return (MinijaxConstraintDescriptor<T>) buildAssertTrueValidator((AssertTrue) annotation, valueClass);
} else if (annotationClass == Max.class) {
return (MinijaxConstraintDescriptor<T>) buildMaxValidator((Max) annotation, valueClass);
} else if (annotationClass == Min.class) {
return (MinijaxConstraintDescriptor<T>) buildMinValidator((Min) annotation, valueClass);
} else if (annotationClass == NotBlank.class) {
return (MinijaxConstraintDescriptor<T>) buildNotBlankValidator((NotBlank) annotation, valueClass);
} else if (annotationClass == NotEmpty.class) {
return (MinijaxConstraintDescriptor<T>) buildNotEmptyValidator((NotEmpty) annotation, valueClass);
} else if (annotationClass == NotNull.class) {
return (MinijaxConstraintDescriptor<T>) buildNotNullValidator((NotNull) annotation);
} else if (annotationClass == Pattern.class) {
return (MinijaxConstraintDescriptor<T>) buildPatternValidator((Pattern) annotation, valueClass);
} else if (annotationClass == Size.class) {
return (MinijaxConstraintDescriptor<T>) buildSizeValidator((Size) annotation, valueClass);
} else {
throw new ValidationException("Unrecognized constraint annotation: " + annotation);
}
}
use of javax.validation.constraints.NotNull in project rpki-validator-3 by RIPE-NCC.
the class ValidatedRpkiObjects method initialize.
@PostConstruct
private synchronized void initialize() {
new TransactionTemplate(transactionManager).execute((status) -> {
Map<@NotNull @Valid TrustAnchor, List<RpkiObject>> grouped = Stream.concat(rpkiObjects.findCurrentlyValidated(RpkiObject.Type.ROA), rpkiObjects.findCurrentlyValidated(RpkiObject.Type.ROUTER_CER)).collect(Collectors.groupingBy(pair -> pair.getLeft().getTrustAnchor(), Collectors.mapping(pair -> pair.getRight(), Collectors.toList())));
grouped.forEach(this::update);
return null;
});
}
use of javax.validation.constraints.NotNull in project solr-document-store by DBCDK.
the class EEConfig method getValue.
private String getValue(InjectionPoint ip) throws EJBException {
String name = getName(ip);
String value = props.getProperty(name);
if (value == null) {
Default def = ip.getAnnotated().getAnnotation(Default.class);
if (def != null) {
value = def.value();
}
}
NotNull notNull = ip.getAnnotated().getAnnotation(NotNull.class);
if (notNull != null && value == null) {
throw new EJBException("Cannot resolve value for: " + name + " null is not allowed");
}
log.info("Configuration value {}:{}", name, value);
return value;
}
Aggregations