@Override public ConstraintFinder lookingAt(Scope scope) { if (scope.equals(Scope.LOCAL_ELEMENT)) { definedInSet.remove(ConstraintOrigin.DEFINED_IN_HIERARCHY); } return this; }
/** * Create a new ConstraintFinderImpl instance. * * @param metaBean * @param constraintDescriptors */ ConstraintFinderImpl(MetaBean metaBean, Set<ConstraintValidation<?>> constraintDescriptors) { this.metaBean = metaBean; this.constraintDescriptors = constraintDescriptors; this.findInScopes = new HashSet<Scope>(Arrays.asList(Scope.values())); }
private boolean isInScope(ConstraintValidation<?> descriptor) { if (findInScopes.size() == Scope.values().length) return true; // all scopes if (metaBean != null) { Class<?> owner = descriptor.getOwner(); for (Scope scope : findInScopes) { switch (scope) { case LOCAL_ELEMENT: if (owner.equals(metaBean.getBeanClass())) return true; break; case HIERARCHY: if (!owner.equals(metaBean.getBeanClass())) return true; break; } } } return false; }
@Override public ConstraintFinder lookingAt(final Scope scope) { if (scope.equals(Scope.LOCAL_ELEMENT)) { definedInSet.remove(ConstraintOrigin.DEFINED_IN_HIERARCHY); } return this; }
@Override public ConstraintFinder lookingAt(Scope visibility) { if ( visibility.equals( Scope.LOCAL_ELEMENT ) ) { definedInSet.remove( ConstraintOrigin.DEFINED_IN_HIERARCHY ); } return this; }
@Override public ConstraintFinder lookingAt(Scope scope) { if (scope.equals(Scope.LOCAL_ELEMENT)) { definedInSet.remove(ConstraintOrigin.DEFINED_IN_HIERARCHY); } return this; }
@Override public ConstraintFinder lookingAt(Scope scope) { if (scope.equals(Scope.LOCAL_ELEMENT)) { definedInSet.remove(ConstraintOrigin.DEFINED_IN_HIERARCHY); } return this; }
@Override public ConstraintFinder lookingAt(Scope visibility) { if ( visibility.equals( Scope.LOCAL_ELEMENT ) ) { definedInSet.remove( ConstraintOrigin.DEFINED_IN_HIERARCHY ); } return this; }
/** * {@inheritDoc} */ public ElementDescriptor.ConstraintFinder lookingAt(Scope scope) { if (scope.equals(Scope.LOCAL_ELEMENT)) { findInScopes.remove(Scope.HIERARCHY); for (Iterator<ConstraintValidation<?>> it = constraintDescriptors.iterator(); it.hasNext();) { ConstraintValidation<?> cv = it.next(); if (cv.getOwner() != metaBean.getBeanClass()) { it.remove(); } } } return this; }
@Override public Set<ConstraintDescriptor<?>> getConstraintDescriptors(Scope scope) { Set<ConstraintDescriptor<?>> outputSet = new HashSet<ConstraintDescriptor<?>>(); for(Set<ConstraintDescriptor<?>> partialSet : this.constraintDescriptors.values()) { outputSet.addAll(partialSet); } if(Scope.HIERARCHY.equals(scope)) { if(this.superReflector != null) { outputSet.addAll(this.superReflector.getConstraintDescriptors()); } for(IReflector iface : this.reflectorInterfaces) { if(iface != null) { outputSet.addAll(iface.getConstraintDescriptors()); } } } return outputSet; }
@Override public Set<ConstraintDescriptor<?>> getClassConstraintDescriptors(Scope scope) { Set<ConstraintDescriptor<?>> classDescriptors = this.constraintDescriptors.get(this.targetClass.getName()); if(classDescriptors == null) { classDescriptors = new HashSet<ConstraintDescriptor<?>>(); this.constraintDescriptors.put(this.targetClass.getName(), classDescriptors); } if(Scope.HIERARCHY.equals(scope)) { if(this.superReflector != null) { classDescriptors.addAll(this.superReflector.getClassConstraintDescriptors()); } for(IReflector iface : this.reflectorInterfaces) { classDescriptors.addAll(iface.getClassConstraintDescriptors()); } } return classDescriptors; }
@Override public Set<ConstraintDescriptor<?>> getConstraintDescriptors(String name, Scope scope) { Set<ConstraintDescriptor<?>> descriptors = this.constraintDescriptors.get(name); if(descriptors == null) { descriptors = new HashSet<ConstraintDescriptor<?>>(); this.constraintDescriptors.put(name, descriptors); } if(Scope.HIERARCHY.equals(scope)) { if(this.superReflector != null) { descriptors.addAll(this.superReflector.getConstraintDescriptors(name)); } for(IReflector iface : this.reflectorInterfaces) { descriptors.addAll(iface.getConstraintDescriptors(name)); } } return this.constraintDescriptors.get(name); }
@Override public Set<ElementType> declaredOn(Scope scope, String property, ConstraintDescriptor<?> descriptor) { Set<ElementType> results = new LinkedHashSet<ElementType>(); if(this.declaredOnField.get(property) != null && this.declaredOnField.get(property).contains(descriptor)) { results.add(ElementType.FIELD); } if(this.declaredOnMethod.get(property) != null && this.declaredOnMethod.get(property).contains(descriptor)) { results.add(ElementType.METHOD); } //walk the chain if need be if(Scope.HIERARCHY.equals(scope)) { if(this.superReflector != null) { results.addAll(this.superReflector.declaredOn(scope,property,descriptor)); } for(IReflector iface : this.reflectorInterfaces) { if(iface != null) { results.addAll(iface.declaredOn(scope,property,descriptor)); } } } return results; }
if(Scope.HIERARCHY.equals(scope)) { if(this.superReflector != null) { results.addAll(this.superReflector.declaredOn(scope, property, descriptor));