Package javax.validation.executable

Examples of javax.validation.executable.ValidateOnExecution


    return executableTypes;
  }

  private EnumSet<ExecutableType> executableTypesDefinedOnConstructor(Constructor<?> constructor) {
    ValidateOnExecution validateOnExecutionAnnotation = constructor.getAnnotation(
        ValidateOnExecution.class
    );
    EnumSet<ExecutableType> executableTypes = commonExecutableTypeChecks( validateOnExecutionAnnotation );

    if ( executableTypes.contains( ExecutableType.IMPLICIT ) ) {
View Full Code Here


    }
    return annotations;
  }

  private EnumSet<ExecutableType> executableTypesDefinedOnType(Class<?> clazz) {
    ValidateOnExecution validateOnExecutionAnnotation = clazz.getAnnotation( ValidateOnExecution.class );
    EnumSet<ExecutableType> executableTypes = commonExecutableTypeChecks( validateOnExecutionAnnotation );

    if ( executableTypes.contains( ExecutableType.IMPLICIT ) ) {
      return DEFAULT_EXECUTABLE_TYPES;
    }
View Full Code Here

    return executableTypes;
  }

  private EnumSet<ExecutableType> executableTypesDefinedOnMethod(Method method, boolean isGetter) {
    ValidateOnExecution validateOnExecutionAnnotation = method.getAnnotation( ValidateOnExecution.class );
    EnumSet<ExecutableType> executableTypes = commonExecutableTypeChecks( validateOnExecutionAnnotation );

    if ( executableTypes.contains( ExecutableType.IMPLICIT ) ) {
      if ( isGetter ) {
        executableTypes.add( ExecutableType.GETTER_METHODS );
View Full Code Here

    return executableTypes;
  }

  private EnumSet<ExecutableType> executableTypesDefinedOnConstructor(Constructor<?> constructor) {
    ValidateOnExecution validateOnExecutionAnnotation = constructor.getAnnotation(
        ValidateOnExecution.class
    );
    EnumSet<ExecutableType> executableTypes = commonExecutableTypeChecks( validateOnExecutionAnnotation );

    if ( executableTypes.contains( ExecutableType.IMPLICIT ) ) {
View Full Code Here

        initClassConfig(targetClass);

        if (constructorValidated == null) {
            synchronized (this) {
                if (constructorValidated == null) {
                    final ValidateOnExecution annotation = targetClass.getConstructor(constructor.getParameterTypes()).getAnnotation(ValidateOnExecution.class);
                    if (annotation == null) {
                        constructorValidated = classConfiguration.contains(ExecutableType.CONSTRUCTORS);
                    } else {
                        final Collection<ExecutableType> types = Arrays.asList(annotation.type());
                        constructorValidated = types.contains(ExecutableType.CONSTRUCTORS) || types.contains(ExecutableType.IMPLICIT) || types.contains(ExecutableType.ALL);
                    }
                }
            }
        }
View Full Code Here

                    Class<?> lastClassWithTheMethod = null;

                    // search on method @ValidateOnExecution
                    Collections.reverse(classHierarchy);
                    ValidateOnExecution validateOnExecution = null;
                    for (final Class<?> c : classHierarchy) {
                        try {
                            validateOnExecution = c.getDeclaredMethod(method.getName(), method.getParameterTypes()).getAnnotation(ValidateOnExecution.class);
                            if (lastClassWithTheMethod == null) {
                                lastClassWithTheMethod = c;
                            }
                            if (validateOnExecution != null) {
                                lastClassWithTheMethod = null;
                                break;
                            }
                        } catch (final Throwable h) {
                            // no-op
                        }
                    }

                    // if not found look in the class declaring the method
                    if (validateOnExecution == null && lastClassWithTheMethod != null) {
                        validateOnExecution = lastClassWithTheMethod.getAnnotation(ValidateOnExecution.class);
                    }

                    if (validateOnExecution == null) {
                        methodConfig = doValidMethod(method, classConfiguration);
                    } else {
                        final Collection<ExecutableType> config = new HashSet<ExecutableType>();
                        for (final ExecutableType type : validateOnExecution.type()) {
                            if (ExecutableType.IMPLICIT.equals(type)) { // on method it just means validate, even on getters
                                config.add(ExecutableType.NON_GETTER_METHODS);
                                if (lastClassWithTheMethod == null) {
                                    config.add(ExecutableType.GETTER_METHODS);
                                } // else the annotation was not on the method so implicit doesn't mean getters
View Full Code Here

        if (classConfiguration == null) {
            synchronized (this) {
                if (classConfiguration == null) {
                    classConfiguration = new CopyOnWriteArraySet<ExecutableType>();

                    final ValidateOnExecution annotation = targetClass.getAnnotation(ValidateOnExecution.class);
                    if (annotation == null) {
                        classConfiguration.addAll(globalConfiguration.getGlobalExecutableTypes());
                    } else {
                        for (final ExecutableType type : annotation.type()) {
                            if (ExecutableType.IMPLICIT.equals(type)) {
                                classConfiguration.add(ExecutableType.CONSTRUCTORS);
                                classConfiguration.add(ExecutableType.NON_GETTER_METHODS);
                            } else if (ExecutableType.ALL.equals(type)) {
                                classConfiguration.add(ExecutableType.CONSTRUCTORS);
View Full Code Here

    return executableTypes;
  }

  private EnumSet<ExecutableType> executableTypesDefinedOnMethod(Method method, boolean isGetter) {
    ValidateOnExecution validateOnExecutionAnnotation = method.getAnnotation( ValidateOnExecution.class );
    EnumSet<ExecutableType> executableTypes = commonExecutableTypeChecks( validateOnExecutionAnnotation );

    if ( executableTypes.contains( ExecutableType.IMPLICIT ) ) {
      if ( isGetter ) {
        executableTypes.add( ExecutableType.GETTER_METHODS );
View Full Code Here

TOP

Related Classes of javax.validation.executable.ValidateOnExecution

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.