private void createPropertyPeersFromAccessors(final List<Method> propertyAccessors, final List<NakedObjectAssociationPeer> associationPeerListToAppendto) throws ReflectionException { for (final Method accessorMethod : propertyAccessors) { LOG.debug(" identified 1-1 association method " + accessorMethod); final String capitalizedName = NameUtils.javaBaseName(accessorMethod.getName()); final String beanName = Introspector.decapitalize(capitalizedName); final Class<?> returnType = accessorMethod.getReturnType(); // skip if class strategy says so. if (getClassSubstitutor().getClass(returnType) == null) { continue; } if (LOG.isDebugEnabled()) { LOG.debug("one-to-one association " + capitalizedName + " ->" + accessorMethod); } final Identifier identifier = Identifier.propertyOrCollectionIdentifier(className, beanName); // create a 1:1 association peer final JavaOneToOneAssociationPeer associationPeer = new JavaOneToOneAssociationPeer(identifier, returnType, getSpecificationLoader()); // process facets for the 1:1 association getFacetProcessor().process(accessorMethod, new JavaIntrospectorMethodRemover(), associationPeer, NakedObjectFeatureType.PROPERTY); associationPeerListToAppendto.add(associationPeer); } }
@Override public boolean process(final Method actionMethod, final MethodRemover methodRemover, final FacetHolder action) { final String capitalizedName = NameUtils.capitalizeName(actionMethod.getName()); final Class<?> type = actionMethod.getDeclaringClass(); final Class<?> returnType = actionMethod.getReturnType();
@Override public boolean process(Class<?> cls, final Method actionMethod, final MethodRemover methodRemover, final FacetHolder action) { final String capitalizedName = NameUtils.capitalizeName(actionMethod.getName()); final Class<?> returnType = actionMethod.getReturnType(); final Class<?>[] paramTypes = actionMethod.getParameterTypes();
private void createPropertyPeersFromAccessors(final List<Method> propertyAccessors, final List<NakedObjectAssociationPeer> associationPeerListToAppendto) throws ReflectionException { for (final Method accessorMethod : propertyAccessors) { LOG.debug(" identified 1-1 association method " + accessorMethod); final String capitalizedName = NameUtils.javaBaseName(accessorMethod.getName()); final String beanName = Introspector.decapitalize(capitalizedName); final Class<?> returnType = accessorMethod.getReturnType(); // skip if class strategy says so. if (getClassSubstitutor().getClass(returnType) == null) { continue; } if (LOG.isDebugEnabled()) { LOG.debug("one-to-one association " + capitalizedName + " ->" + accessorMethod); } final Identifier identifier = Identifier.propertyOrCollectionIdentifier(className, beanName); // create a 1:1 association peer final JavaOneToOneAssociationPeer associationPeer = new JavaOneToOneAssociationPeer(identifier, returnType, getSpecificationLoader()); // process facets for the 1:1 association getFacetProcessor().process(type, accessorMethod, new JavaIntrospectorMethodRemover(), associationPeer, NakedObjectFeatureType.PROPERTY); associationPeerListToAppendto.add(associationPeer); } }
private void createCollectionPeersFromAccessors(final List<Method> collectionAccessors, final List<NakedObjectAssociationPeer> associationPeerListToAppendto) { for (final Method getMethod : collectionAccessors) { LOG.debug(" identified one-many association method " + getMethod); final String capitalizedName = NameUtils.javaBaseName(getMethod.getName()); final String collectionNameName = Introspector.decapitalize(capitalizedName); final Identifier identifier = Identifier.propertyOrCollectionIdentifier(className(), collectionNameName); // create property and add facets final JavaOneToManyAssociationPeer collection = new JavaOneToManyAssociationPeer(identifier, getSpecificationLoader()); getFacetProcessor().process(getMethod, new JavaIntrospectorMethodRemover(), collection, NakedObjectFeatureType.COLLECTION); // figure out what the type is Class<?> elementType = Object.class; final TypeOfFacet typeOfFacet = collection.getFacet(TypeOfFacet.class); if (typeOfFacet != null) { elementType = typeOfFacet.value(); } collection.setElementType(elementType); // skip if class strategy says so. if (getClassSubstitutor().getClass(elementType) == null) { continue; } associationPeerListToAppendto.add(collection); } }
private void createCollectionPeersFromAccessors(final List<Method> collectionAccessors, final List<NakedObjectAssociationPeer> associationPeerListToAppendto) { for (final Method getMethod : collectionAccessors) { LOG.debug(" identified one-many association method " + getMethod); final String capitalizedName = NameUtils.javaBaseName(getMethod.getName()); final String collectionNameName = Introspector.decapitalize(capitalizedName); final Identifier identifier = Identifier.propertyOrCollectionIdentifier(className(), collectionNameName); // create property and add facets final JavaOneToManyAssociationPeer collection = new JavaOneToManyAssociationPeer(identifier, getSpecificationLoader()); getFacetProcessor().process(type, getMethod, new JavaIntrospectorMethodRemover(), collection, NakedObjectFeatureType.COLLECTION); // figure out what the type is Class<?> elementType = Object.class; final TypeOfFacet typeOfFacet = collection.getFacet(TypeOfFacet.class); if (typeOfFacet != null) { elementType = typeOfFacet.value(); } collection.setElementType(elementType); // skip if class strategy says so. if (getClassSubstitutor().getClass(elementType) == null) { continue; } associationPeerListToAppendto.add(collection); } }
@Override public boolean process(final Method collectionAccessor, final MethodRemover methodRemover, final FacetHolder collection) { final String capitalizedName = NameUtils.javaBaseName(collectionAccessor.getName()); final Class<?> returnType = collectionAccessor.getReturnType(); final Class<?> cls = collectionAccessor.getDeclaringClass(); final List<Facet> facets = new ArrayList<Facet>(); removeMethod(methodRemover, collectionAccessor); facets.add(new PropertyAccessorFacetViaAccessor(collectionAccessor, collection)); final Class<?> addToType = findAndRemoveAddToMethod(facets, methodRemover, cls, collectionAccessor, capitalizedName, collection); final Class<?> removeFromType = findAndRemoveRemoveFromMethod(facets, methodRemover, cls, collectionAccessor, capitalizedName, collection); final Class<?> collectionType = inferTypeOfIfPossible(facets, collectionAccessor, addToType, removeFromType, collection); findAndRemoveClearMethod(facets, methodRemover, cls, collectionAccessor, capitalizedName, collection); findAndRemoveValidateAddToMethod(facets, methodRemover, cls, collectionType, capitalizedName, returnType, collection); findAndRemoveValidateRemoveFromMethod(facets, methodRemover, cls, collectionType, capitalizedName, returnType, collection); findAndRemoveNameMethod(facets, methodRemover, cls, capitalizedName, collection); findAndRemoveDescriptionMethod(facets, methodRemover, cls, capitalizedName, collection); findAndRemoveAlwaysHideMethod(facets, methodRemover, cls, capitalizedName, collection); findAndRemoveProtectMethod(facets, methodRemover, cls, capitalizedName, collection); findAndRemoveHideForSessionMethod(facets, methodRemover, cls, capitalizedName, UserMemento.class, collection); findAndRemoveDisableForSessionMethod(facets, methodRemover, cls, capitalizedName, UserMemento.class, collection); findAndRemoveHideMethod(facets, methodRemover, cls, OBJECT, capitalizedName, collection); findAndRemoveDisableMethod(facets, methodRemover, cls, OBJECT, capitalizedName, collection); return FacetUtil.addFacets(facets); }
@Override public boolean process(final Method getMethod, final MethodRemover methodRemover, final FacetHolder property) { final String capitalizedName = NameUtils.javaBaseName(getMethod.getName()); final Class<?> returnType = getMethod.getReturnType(); final Class<?>[] paramTypes = new Class[] { returnType }; final Class<?> cls = getMethod.getDeclaringClass(); final List<Facet> facets = new ArrayList<Facet>(); removeMethod(methodRemover, getMethod); facets.add(new PropertyAccessorFacetViaAccessor(getMethod, property)); final Method setMethod = findAndRemoveSetterMethod(facets, methodRemover, cls, capitalizedName, paramTypes, property); findAndRemoveModifyMethod(facets, methodRemover, cls, capitalizedName, paramTypes, property); final Method clearMethod = findAndRemoveClearMethod(facets, methodRemover, cls, capitalizedName, paramTypes, property); ensureClearViaSetterIfRequired(facets, property, clearMethod, setMethod); findAndRemoveChoicesMethod(facets, methodRemover, cls, capitalizedName, returnType, property); findAndRemoveDefaultMethod(facets, methodRemover, cls, capitalizedName, returnType, property); findAndRemoveValidateMethod(facets, methodRemover, cls, paramTypes, capitalizedName, returnType, property); findAndRemoveNameMethod(facets, methodRemover, cls, capitalizedName, property); findAndRemoveDescriptionMethod(facets, methodRemover, cls, capitalizedName, property); findAndRemoveAlwaysHideMethod(facets, methodRemover, cls, capitalizedName, property); findAndRemoveProtectMethod(facets, methodRemover, cls, capitalizedName, property); findAndRemoveOptionalMethod(facets, methodRemover, cls, capitalizedName, returnType, property); findAndRemoveHideForSessionMethod(facets, methodRemover, cls, capitalizedName, paramTypes, property); findAndRemoveDisableForSessionMethod(facets, methodRemover, cls, capitalizedName, paramTypes, property); findAndRemoveHideMethod(facets, methodRemover, cls, OBJECT, capitalizedName, paramTypes, property); findAndRemoveHideMethod(facets, methodRemover, cls, OBJECT, capitalizedName, new Class[] {}, property); findAndRemoveDisableMethod(facets, methodRemover, cls, OBJECT, capitalizedName, paramTypes, property); findAndRemoveDisableMethod(facets, methodRemover, cls, OBJECT, capitalizedName, new Class[] {}, property); return FacetUtil.addFacets(facets); }
@Override public boolean process( Class<?> cls, final Method collectionAccessor, final MethodRemover methodRemover, final FacetHolder collection) { final String capitalizedName = NameUtils.javaBaseName(collectionAccessor.getName()); final Class<?> returnType = collectionAccessor.getReturnType(); final List<Facet> facets = new ArrayList<Facet>(); removeMethod(methodRemover, collectionAccessor); facets.add(new PropertyAccessorFacetViaAccessor(collectionAccessor, collection)); final Class<?> addToType = findAndRemoveAddToMethod(facets, methodRemover, cls, collectionAccessor, capitalizedName, collection); final Class<?> removeFromType = findAndRemoveRemoveFromMethod(facets, methodRemover, cls, collectionAccessor, capitalizedName, collection); final Class<?> collectionType = inferTypeOfIfPossible(facets, collectionAccessor, addToType, removeFromType, collection); findAndRemoveClearMethod(facets, methodRemover, cls, collectionAccessor, capitalizedName, collection); findAndRemoveValidateAddToMethod(facets, methodRemover, cls, collectionType, capitalizedName, returnType, collection); findAndRemoveValidateRemoveFromMethod(facets, methodRemover, cls, collectionType, capitalizedName, returnType, collection); findAndRemoveNameMethod(facets, methodRemover, cls, capitalizedName, collection); findAndRemoveDescriptionMethod(facets, methodRemover, cls, capitalizedName, collection); findAndRemoveAlwaysHideMethod(facets, methodRemover, cls, capitalizedName, collection); findAndRemoveProtectMethod(facets, methodRemover, cls, capitalizedName, collection); findAndRemoveHideForSessionMethod(facets, methodRemover, cls, capitalizedName, UserMemento.class, collection); findAndRemoveDisableForSessionMethod(facets, methodRemover, cls, capitalizedName, UserMemento.class, collection); findAndRemoveHideMethod(facets, methodRemover, cls, OBJECT, capitalizedName, collection); findAndRemoveDisableMethod(facets, methodRemover, cls, OBJECT, capitalizedName, collection); return FacetUtil.addFacets(facets); }
@Override public boolean process(Class<?> cls, final Method getMethod, final MethodRemover methodRemover, final FacetHolder property) { final String capitalizedName = NameUtils.javaBaseName(getMethod.getName()); final Class<?> returnType = getMethod.getReturnType(); final Class<?>[] paramTypes = new Class[] { returnType }; final List<Facet> facets = new ArrayList<Facet>(); removeMethod(methodRemover, getMethod); facets.add(new PropertyAccessorFacetViaAccessor(getMethod, property)); final Method setMethod = findAndRemoveSetterMethod(facets, methodRemover, cls, capitalizedName, paramTypes, property); findAndRemoveModifyMethod(facets, methodRemover, cls, capitalizedName, paramTypes, property); final Method clearMethod = findAndRemoveClearMethod(facets, methodRemover, cls, capitalizedName, paramTypes, property); ensureClearViaSetterIfRequired(facets, property, clearMethod, setMethod); findAndRemoveChoicesMethod(facets, methodRemover, cls, capitalizedName, returnType, property); findAndRemoveDefaultMethod(facets, methodRemover, cls, capitalizedName, returnType, property); findAndRemoveValidateMethod(facets, methodRemover, cls, paramTypes, capitalizedName, returnType, property); findAndRemoveNameMethod(facets, methodRemover, cls, capitalizedName, property); findAndRemoveDescriptionMethod(facets, methodRemover, cls, capitalizedName, property); findAndRemoveAlwaysHideMethod(facets, methodRemover, cls, capitalizedName, property); findAndRemoveProtectMethod(facets, methodRemover, cls, capitalizedName, property); findAndRemoveOptionalMethod(facets, methodRemover, cls, capitalizedName, returnType, property); findAndRemoveHideForSessionMethod(facets, methodRemover, cls, capitalizedName, paramTypes, property); findAndRemoveDisableForSessionMethod(facets, methodRemover, cls, capitalizedName, paramTypes, property); findAndRemoveHideMethod(facets, methodRemover, cls, OBJECT, capitalizedName, paramTypes, property); findAndRemoveHideMethod(facets, methodRemover, cls, OBJECT, capitalizedName, new Class[] {}, property); findAndRemoveDisableMethod(facets, methodRemover, cls, OBJECT, capitalizedName, paramTypes, property); findAndRemoveDisableMethod(facets, methodRemover, cls, OBJECT, capitalizedName, new Class[] {}, property); return FacetUtil.addFacets(facets); }