use of javax.validation.constraints.NotNull in project podam by devopsfolks.
the class TypeManufacturerUtil method findAttributeStrategy.
/**
* It returns a {@link AttributeStrategy} if one was specified in
* annotations, or {@code null} otherwise.
*
* @param strategy
* The data provider strategy
* @param annotations
* The list of annotations, irrelevant annotations will be removed
* @param attributeType
* Type of attribute expected to be returned
* @return {@link AttributeStrategy}, if {@link PodamStrategyValue} or bean
* validation constraint annotation was found among annotations
* @throws IllegalAccessException
* if attribute strategy cannot be instantiated
* @throws InstantiationException
* if attribute strategy cannot be instantiated
* @throws SecurityException
* if access security is violated
* @throws InvocationTargetException
* if invocation failed
* @throws IllegalArgumentException
* if illegal argument provided to a constructor
*/
public static AttributeStrategy<?> findAttributeStrategy(DataProviderStrategy strategy, List<Annotation> annotations, Class<?> attributeType) throws InstantiationException, IllegalAccessException, SecurityException, IllegalArgumentException, InvocationTargetException {
List<Annotation> localAnnotations = new ArrayList<Annotation>(annotations);
Iterator<Annotation> iter = localAnnotations.iterator();
while (iter.hasNext()) {
Annotation annotation = iter.next();
if (annotation instanceof PodamStrategyValue) {
PodamStrategyValue strategyAnnotation = (PodamStrategyValue) annotation;
return strategyAnnotation.value().newInstance();
}
/* Podam annotation is present, this will be handled later by type manufacturers */
if (annotation.annotationType().getAnnotation(PodamAnnotation.class) != null) {
return null;
}
/* Find real class out of proxy */
Class<? extends Annotation> annotationClass = annotation.getClass();
if (Proxy.isProxyClass(annotationClass)) {
Class<?>[] interfaces = annotationClass.getInterfaces();
if (interfaces.length == 1) {
@SuppressWarnings("unchecked") Class<? extends Annotation> tmp = (Class<? extends Annotation>) interfaces[0];
annotationClass = tmp;
}
}
AttributeStrategy<?> attrStrategy = strategy.getStrategyForAnnotation(annotationClass);
if (null != attrStrategy) {
return attrStrategy;
}
if (annotation.annotationType().getAnnotation(Constraint.class) != null) {
if (annotation instanceof NotNull || annotation.annotationType().getName().equals("org.hibernate.validator.constraints.NotEmpty") || annotation.annotationType().getName().equals("org.hibernate.validator.constraints.NotBlank")) {
/* We don't need to do anything for NotNull constraint */
iter.remove();
} else if (!NotNull.class.getPackage().equals(annotationClass.getPackage())) {
LOG.warn("Please, register AttributeStratergy for custom " + "constraint {}, in DataProviderStrategy! Value " + "will be left to null", annotation);
}
} else {
iter.remove();
}
}
AttributeStrategy<?> retValue = null;
if (!localAnnotations.isEmpty() && !Collection.class.isAssignableFrom(attributeType) && !Map.class.isAssignableFrom(attributeType) && !attributeType.isArray()) {
retValue = new BeanValidationStrategy(attributeType);
}
return retValue;
}
use of javax.validation.constraints.NotNull in project che by eclipse.
the class PartButtonWidget method setIcon.
/** {@inheritDoc} */
@NotNull
@Override
public PartButton setIcon(@Nullable SVGResource iconResource) {
this.tabIcon = iconResource;
iconPanel.clear();
if (tabIcon != null) {
iconPanel.add(new SVGImage(tabIcon));
}
return this;
}
use of javax.validation.constraints.NotNull in project che by eclipse.
the class NodeLoader method onLoadFailure.
/**
* Called when children haven't been successfully loaded.
* Also fire {@link org.eclipse.che.ide.ui.smartTree.event.LoadExceptionEvent} event.
*
* @param parent
* parent node, children which haven't been loaded
* @return instance of {@link org.eclipse.che.api.promises.client.Operation} which contains promise with error
*/
@NotNull
private Operation<PromiseError> onLoadFailure(@NotNull final Node parent) {
return new Operation<PromiseError>() {
@Override
public void apply(PromiseError t) throws OperationException {
childRequested.remove(parent);
fireEvent(new LoadExceptionEvent(parent, t.getCause()));
}
};
}
use of javax.validation.constraints.NotNull in project che by eclipse.
the class RecipeEditorViewImpl method createButton.
@NotNull
private EditorButtonWidget createButton(@NotNull String title, @NotNull EditorButtonWidget.ActionDelegate delegate, @NotNull EditorButtonWidgetImpl.Background background) {
EditorButtonWidget button = widgetFactory.createEditorButton(title, background);
button.setDelegate(delegate);
buttonsPanel.add(button);
return button;
}
use of javax.validation.constraints.NotNull in project drill by apache.
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);
}
Aggregations