private MetaInformation newMetaInformation() { if (listMetaClass != null) { return ClassUtils.newInstance(listMetaClass); } else { return null; } }
private LinksInformation newLinksInformation() { if (listLinksClass != null) { return ClassUtils.newInstance(listLinksClass); } else { return null; } }
@Override public T buildResource(Resource body) { return (T) ClassUtils.newInstance(resourceClass); }
private Object parseEmbeddableString(MetaDataObject embType, String idString) { String[] keyElements = idString.split(MetaKey.ID_ELEMENT_SEPARATOR); Object id = ClassUtils.newInstance(embType.getImplementationClass()); List<? extends MetaAttribute> embAttrs = embType.getAttributes(); if (keyElements.length != embAttrs.size()) { throw new UnsupportedOperationException("failed to parse " + idString + " for " + embType.getId()); } for (int i = 0; i < keyElements.length; i++) { MetaAttribute embAttr = embAttrs.get(i); Object idElement = fromKeyString(embAttr.getType(), keyElements[i]); embAttr.setValue(id, idElement); } return id; }
public DefaultResourceList<T> newResultList() { DefaultResourceList<T> list = ClassUtils.newInstance(listClass); list.setMeta(newMetaInformation()); list.setLinks(newLinksInformation()); return list; }
@Override public <T> T createResourceProxy(Class<T> clazz, Object id) { T instance = ClassUtils.newInstance(clazz); ResourceRegistry resourceRegistry = context.getModuleRegistry().getResourceRegistry(); RegistryEntry entry = resourceRegistry.findEntry(clazz); ResourceInformation resourceInformation = entry.getResourceInformation(); resourceInformation.setId(instance, id); return instance; }
@SuppressWarnings({ "unchecked", "rawtypes" }) private Object createTypesafeList(Object result, Class<?> returnType) { DefaultResourceList defaultList = (DefaultResourceList) result; Class<?>[] typeArguments = TypeResolver.resolveRawArguments(ResourceListBase.class, returnType); Class<?> metaType = typeArguments[1]; Class<?> linksType = typeArguments[2]; ResourceListBase typedList = (ResourceListBase) ClassUtils.newInstance(returnType); typedList.addAll(defaultList); typedList.setMeta(defaultList.getMeta(metaType)); typedList.setLinks(defaultList.getLinks(linksType)); return typedList; }