public boolean add(ConstrainedElement constrainedElement) { boolean added = false; if (methodBuilder != null && methodBuilder.accepts(constrainedElement)) { methodBuilder.add(constrainedElement); added = true; } if (propertyBuilder != null && propertyBuilder.accepts(constrainedElement)) { propertyBuilder.add(constrainedElement); if (!added && constrainedElement.getKind() == ConstrainedElementKind.METHOD && methodBuilder == null) { ConstrainedExecutable constrainedMethod = (ConstrainedExecutable) constrainedElement; methodBuilder = new ExecutableMetaData.Builder( beanClass, constrainedMethod, constraintHelper, executableHelper); } added = true; } return added; }
public BuilderDelegate( Class<?> beanClass, ConstrainedElement constrainedElement, ConstraintHelper constraintHelper, ExecutableHelper executableHelper) { this.beanClass = beanClass; this.constraintHelper = constraintHelper; this.executableHelper = executableHelper; switch (constrainedElement.getKind()) { case FIELD: ConstrainedField constrainedField = (ConstrainedField) constrainedElement; propertyBuilder = new PropertyMetaData.Builder(beanClass, constrainedField, constraintHelper); break; case CONSTRUCTOR: case METHOD: ConstrainedExecutable constrainedExecutable = (ConstrainedExecutable) constrainedElement; methodBuilder = new ExecutableMetaData.Builder( beanClass, constrainedExecutable, constraintHelper, executableHelper); if (constrainedExecutable.isGetterMethod()) { propertyBuilder = new PropertyMetaData.Builder(beanClass, constrainedExecutable, constraintHelper); } break; case TYPE: ConstrainedType constrainedType = (ConstrainedType) constrainedElement; propertyBuilder = new PropertyMetaData.Builder(beanClass, constrainedType, constraintHelper); break; } }