Search in sources :

Example 11 with NotNull

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;
}
Also used : Constraint(javax.validation.Constraint) NotNull(javax.validation.constraints.NotNull) Annotation(java.lang.annotation.Annotation)

Example 12 with NotNull

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;
}
Also used : SVGImage(org.vectomatic.dom.svg.ui.SVGImage) NotNull(javax.validation.constraints.NotNull)

Example 13 with NotNull

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()));
        }
    };
}
Also used : PromiseError(org.eclipse.che.api.promises.client.PromiseError) Operation(org.eclipse.che.api.promises.client.Operation) LoadExceptionEvent(org.eclipse.che.ide.ui.smartTree.event.LoadExceptionEvent) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) NotNull(javax.validation.constraints.NotNull)

Example 14 with NotNull

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;
}
Also used : EditorButtonWidget(org.eclipse.che.ide.extension.machine.client.perspective.widgets.recipe.editor.button.EditorButtonWidget) NotNull(javax.validation.constraints.NotNull)

Example 15 with NotNull

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);
}
Also used : Field(java.lang.reflect.Field) ArrayList(java.util.ArrayList) ColumnMetaData(org.apache.calcite.avatica.ColumnMetaData) NotNull(javax.validation.constraints.NotNull)

Aggregations

NotNull (javax.validation.constraints.NotNull)16 ArrayList (java.util.ArrayList)3 ExportMigrationException (org.codice.ddf.migration.ExportMigrationException)3 MigrationException (org.codice.ddf.migration.MigrationException)3 MigrationWarning (org.codice.ddf.migration.MigrationWarning)3 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 Files (java.nio.file.Files)2 Path (java.nio.file.Path)2 Paths (java.nio.file.Paths)2 Collection (java.util.Collection)2 Properties (java.util.Properties)2 BooleanSupplier (java.util.function.BooleanSupplier)2 Function (java.util.function.Function)2 FileUtils (org.apache.commons.io.FileUtils)2 StringUtils (org.apache.commons.lang.StringUtils)2 Validate.notEmpty (org.apache.commons.lang.Validate.notEmpty)2 Validate.notNull (org.apache.commons.lang.Validate.notNull)2 RecipeWidget (org.eclipse.che.ide.extension.machine.client.perspective.widgets.recipe.entry.RecipeWidget)2