private void syncAnnotatedPropertyDefaultAttributes( HashSet<OrmPersistentAttribute> contextAttributes) { Collection<JavaResourceMethod> resourceMethods = CollectionTools.collection(this.getJavaResourceMethods()); // iterate through all resource methods searching for persistable getters for (JavaResourceMethod getterMethod : this.getJavaResourcePropertyGetters()) { JavaResourceMethod setterMethod = JavaResourceMethod.SET_METHOD_TRANSFORMER.transform(getterMethod); if (javaResourcePropertyIsDefault(getterMethod, setterMethod)) { if (getterMethod.isAnnotated() || (setterMethod != null && setterMethod.isAnnotated())) { boolean match = false; for (Iterator<OrmPersistentAttribute> stream = contextAttributes.iterator(); stream.hasNext(); ) { OrmPersistentAttribute contextAttribute = stream.next(); if (contextAttribute.isFor(getterMethod, setterMethod)) { match = true; contextAttribute.update(); stream.remove(); break; } } if (!match) { this.addDefaultAttribute( getDefaultAttributesSize(), this.buildVirtualAttribute(getterMethod, setterMethod)); } } } resourceMethods.remove(getterMethod); resourceMethods.remove(setterMethod); } this.syncRemainingResourceDefaultMethods(contextAttributes, resourceMethods); }
/** * Initialize the attributes for XmlAccessType.PROPERTY 1. all getter/setter javabeans pairs 2. * all annotated fields 3. all annotated methods getters/setters that don't have a matching pair */ private void syncPropertyAccessDefaultAttributes() { HashSet<OrmPersistentAttribute> contextAttributes = CollectionTools.set(this.getDefaultAttributes()); if (!getMapping().isMetadataComplete()) { this.syncFieldDefaultAttributes(contextAttributes, JavaResourceAnnotatedElement.IS_ANNOTATED); } Collection<JavaResourceMethod> resourceMethods = CollectionTools.collection(this.getJavaResourceMethods()); // iterate through all resource methods searching for persistable getters for (JavaResourceMethod getterMethod : this.getJavaResourcePropertyGetters()) { JavaResourceMethod setterMethod = JavaResourceMethod.SET_METHOD_TRANSFORMER.transform(getterMethod); if (javaResourcePropertyIsDefault(getterMethod, setterMethod)) { if (this.methodPairIsProperty(getterMethod, setterMethod)) { boolean match = false; for (Iterator<OrmPersistentAttribute> stream = contextAttributes.iterator(); stream.hasNext(); ) { OrmPersistentAttribute contextAttribute = stream.next(); if (contextAttribute.isFor(getterMethod, setterMethod)) { match = true; contextAttribute.update(); stream.remove(); break; } } if (!match) { this.addDefaultAttribute( getDefaultAttributesSize(), this.buildVirtualAttribute(getterMethod, setterMethod)); } } } resourceMethods.remove(getterMethod); resourceMethods.remove(setterMethod); } this.syncRemainingResourceDefaultMethods(contextAttributes, resourceMethods); // remove any leftover context attributes for (OrmPersistentAttribute contextAttribute : contextAttributes) { this.removeDefaultAttribute(contextAttribute); } }