private Property modelFor(final ObjectSpecification specification) { if (specification == null) { return new ObjectProperty(); } // no "simple" representation for void or values final Class<?> correspondingClass = specification.getCorrespondingClass(); if (correspondingClass == void.class || correspondingClass == Void.class) { return new ObjectProperty(); } // no "simple" representation for values final Property property = valuePropertyFactory.newProperty(correspondingClass); if (property != null) { // was recognized as a value return new ObjectProperty(); } if (specification.isParentedOrFreeCollection()) { TypeOfFacet typeOfFacet = specification.getFacet(TypeOfFacet.class); if (typeOfFacet != null) { ObjectSpecification elementSpec = typeOfFacet.valueSpec(); if (elementSpec != null) { return arrayPropertyOf(elementSpec); } } } if (specification.getCorrespondingClass() == java.lang.Object.class) { return new ObjectProperty(); } if (specification.getCorrespondingClass() == java.lang.Enum.class) { return new StringProperty(); } return newRefProperty(objectTypeFor(specification) + "Repr"); }
Property actionReturnTypeFor(final ObjectAction objectAction) { final ObjectSpecification specification = objectAction.getReturnType(); TypeOfFacet typeOfFacet = objectAction.getFacet(TypeOfFacet.class); if (typeOfFacet != null) { ObjectSpecification elementSpec = typeOfFacet.valueSpec(); if (elementSpec != null) { return arrayPropertyOf(elementSpec); } } return modelFor(specification); }
private void addIfReturnsSubtype( final ObjectAction serviceAction, final List<ObjectAction> matchingActionsToAppendTo) { final ObjectSpecification returnType = serviceAction.getReturnType(); if (returnType == null) { return; } if (returnType.isParentedOrFreeCollection()) { final TypeOfFacet facet = serviceAction.getFacet(TypeOfFacet.class); if (facet != null) { final ObjectSpecification elementType = facet.valueSpec(); addIfReturnsSubtype(serviceAction, elementType, matchingActionsToAppendTo); } } else { addIfReturnsSubtype(serviceAction, returnType, matchingActionsToAppendTo); } }