spring-hateoas-ext/src/main/java/de/escalon/hypermedia/spring/uber/UberUtils.java
public static void toUberData(AbstractUberNode objectNode, Object object) {
        Set<String> filtered = FILTER_RESOURCE_SUPPORT;
        if (object == null) {
            return;
        }

        try {
            // TODO: move all returns to else branch of property descriptor handling
            if (object instanceof Resource) {
                Resource<?> resource = (Resource<?>) object;
                objectNode.addLinks(resource.getLinks());
                toUberData(objectNode, resource.getContent());
                return;
            } else if (object instanceof Resources) {
                Resources<?> resources = (Resources<?>) object;

                // TODO set name using EVO see HypermediaSupportBeanDefinitionRegistrar

                objectNode.addLinks(resources.getLinks());

                Collection<?> content = resources.getContent();
                toUberData(objectNode, content);
                return;
            } else if (object instanceof ResourceSupport) {
                ResourceSupport resource = (ResourceSupport) object;

                objectNode.addLinks(resource.getLinks());

                // wrap object attributes below to avoid endless loop

            } else if (object instanceof Collection) {
                Collection<?> collection = (Collection<?>) object;
                for (Object item : collection) {
                    // TODO name must be repeated for each collection item
                    UberNode itemNode = new UberNode();
                    objectNode.addData(itemNode);
                    toUberData(itemNode, item);
                }
                return;
            }
            if (object instanceof Map) {
                Map<?, ?> map = (Map<?, ?>) object;
                for (Entry<?, ?> entry : map.entrySet()) {
                    String key = entry.getKey()
                            .toString();
                    Object content = entry.getValue();
                    Object value = getContentAsScalarValue(content);
                    UberNode entryNode = new UberNode();
                    objectNode.addData(entryNode);
                    entryNode.setName(key);
                    if (value != null) {
                        entryNode.setValue(value);
                    } else {
                        toUberData(entryNode, content);
                    }
                }
            } else {
                Map<String, PropertyDescriptor> propertyDescriptors = PropertyUtils.getPropertyDescriptors(object);
                for (PropertyDescriptor propertyDescriptor : propertyDescriptors.values()) {
                    String name = propertyDescriptor.getName();
                    if (filtered.contains(name)) {
                        continue;
                    }
                    UberNode propertyNode = new UberNode();
                    Object content = propertyDescriptor.getReadMethod()
                            .invoke(object);

                    if (isEmptyCollectionOrMap(content, propertyDescriptor.getPropertyType())) {
                        continue;
                    }

                    Object value = getContentAsScalarValue(content);
                    propertyNode.setName(name);
                    objectNode.addData(propertyNode);
                    if (value != null) {
                        // for each scalar property of a simple bean, add valuepair nodes to data
                        propertyNode.setValue(value);
                    } else {
                        toUberData(propertyNode, content);
                    }
                }

                Field[] fields = object.getClass()
                        .getFields();
                for (Field field : fields) {
                    String name = field.getName();
                    if (!propertyDescriptors.containsKey(name)) {
                        Object content = field.get(object);
                        Class<?> type = field.getType();
                        if (isEmptyCollectionOrMap(content, type)) {
                            continue;
                        }
                        UberNode propertyNode = new UberNode();

                        Object value = getContentAsScalarValue(content);
                        propertyNode.setName(name);
                        objectNode.addData(propertyNode);
                        if (value != null) {
                            // for each scalar property of a simple bean, add valuepair nodes to data
                            propertyNode.setValue(value);
                        } else {
                            toUberData(propertyNode, content);
                        }

                    }
                }
            }
        } catch (Exception ex) {
            throw new RuntimeException("failed to transform object " + object, ex);
        }
    }
public static void toUberData(AbstractUberNode objectNode, Object object) {
        Set<String> filtered = FILTER_RESOURCE_SUPPORT;
        if (object == null) {
            return;
        }

        try {
            // TODO: move all returns to else branch of property descriptor handling
            if (object instanceof Resource) {
                Resource<?> resource = (Resource<?>) object;
                objectNode.addLinks(resource.getLinks());
                toUberData(objectNode, resource.getContent());
                return;
            } else if (object instanceof Resources) {
                Resources<?> resources = (Resources<?>) object;

                // TODO set name using EVO see HypermediaSupportBeanDefinitionRegistrar

                objectNode.addLinks(resources.getLinks());

                Collection<?> content = resources.getContent();
                toUberData(objectNode, content);
                return;
            } else if (object instanceof ResourceSupport) {
                ResourceSupport resource = (ResourceSupport) object;

                objectNode.addLinks(resource.getLinks());

                // wrap object attributes below to avoid endless loop

            } else if (object instanceof Collection) {
                Collection<?> collection = (Collection<?>) object;
                for (Object item : collection) {
                    // TODO name must be repeated for each collection item
                    UberNode itemNode = new UberNode();
                    objectNode.addData(itemNode);
                    toUberData(itemNode, item);
                }
                return;
            }
            if (object instanceof Map) {
                Map<?, ?> map = (Map<?, ?>) object;
                for (Entry<?, ?> entry : map.entrySet()) {
                    String key = entry.getKey()
                            .toString();
                    Object content = entry.getValue();
                    Object value = getContentAsScalarValue(content);
                    UberNode entryNode = new UberNode();
                    objectNode.addData(entryNode);
                    entryNode.setName(key);
                    if (value != null) {
                        entryNode.setValue(value);
                    } else {
                        toUberData(entryNode, content);
                    }
                }
            } else {
                Map<String, PropertyDescriptor> propertyDescriptors = PropertyUtils.getPropertyDescriptors(object);
                for (PropertyDescriptor propertyDescriptor : propertyDescriptors.values()) {
                    String name = propertyDescriptor.getName();
                    if (filtered.contains(name)) {
                        continue;
                    }
                    UberNode propertyNode = new UberNode();
                    Object content = propertyDescriptor.getReadMethod()
                            .invoke(object);

                    if (isEmptyCollectionOrMap(content, propertyDescriptor.getPropertyType())) {
                        continue;
                    }

                    Object value = getContentAsScalarValue(content);
                    propertyNode.setName(name);
                    objectNode.addData(propertyNode);
                    if (value != null) {
                        // for each scalar property of a simple bean, add valuepair nodes to data
                        propertyNode.setValue(value);
                    } else {
                        toUberData(propertyNode, content);
                    }
                }

                Field[] fields = object.getClass()
                        .getFields();
                for (Field field : fields) {
                    String name = field.getName();
                    if (!propertyDescriptors.containsKey(name)) {
                        Object content = field.get(object);
                        Class<?> type = field.getType();
                        if (isEmptyCollectionOrMap(content, type)) {
                            continue;
                        }
                        UberNode propertyNode = new UberNode();

                        Object value = getContentAsScalarValue(content);
                        propertyNode.setName(name);
                        objectNode.addData(propertyNode);
                        if (value != null) {
                            // for each scalar property of a simple bean, add valuepair nodes to data
                            propertyNode.setValue(value);
                        } else {
                            toUberData(propertyNode, content);
                        }

                    }
                }
            }
        } catch (Exception ex) {
            throw new RuntimeException("failed to transform object " + object, ex);
        }
    }
public static void toUberData ( AbstractUberNode objectNode , Object object ) { Set < String > filtered = FILTER_RESOURCE_SUPPORT ; if ( object == null ) { return ; } try { // TODO: move all returns to else branch of property descriptor handling if ( object instanceof Resource ) { Resource < ? > resource = ( Resource < ? > ) object ; objectNode . addLinks ( resource . getLinks ( ) ) ; toUberData ( objectNode , resource . getContent ( ) ) ; return ; } else if ( object instanceof Resources ) { Resources < ? > resources = ( Resources < ? > ) object ; // TODO set name using EVO see HypermediaSupportBeanDefinitionRegistrar objectNode . addLinks ( resources . getLinks ( ) ) ; Collection < ? > content = resources . getContent ( ) ; toUberData ( objectNode , content ) ; return ; } else if ( object instanceof ResourceSupport ) { ResourceSupport resource = ( ResourceSupport ) object ; objectNode . addLinks ( resource . getLinks ( ) ) ; // wrap object attributes below to avoid endless loop } else if ( object instanceof Collection ) { Collection < ? > collection = ( Collection < ? > ) object ; for ( Object item : collection ) { // TODO name must be repeated for each collection item UberNode itemNode = new UberNode ( ) ; objectNode . addData ( itemNode ) ; toUberData ( itemNode , item ) ; } return ; } if ( object instanceof Map ) { Map < ? , ? > map = ( Map < ? , ? > ) object ; for ( Entry < ? , ? > entry : map . entrySet ( ) ) { String key = entry . getKey ( ) . toString ( ) ; Object content = entry . getValue ( ) ; Object value = getContentAsScalarValue ( content ) ; UberNode entryNode = new UberNode ( ) ; objectNode . addData ( entryNode ) ; entryNode . setName ( key ) ; if ( value != null ) { entryNode . setValue ( value ) ; } else { toUberData ( entryNode , content ) ; } } } else { Map < String , PropertyDescriptor > propertyDescriptors = PropertyUtils . getPropertyDescriptors ( object ) ; for ( PropertyDescriptor propertyDescriptor : propertyDescriptors . values ( ) ) { String name = propertyDescriptor . getName ( ) ; if ( filtered . contains ( name ) ) { continue ; } UberNode propertyNode = new UberNode ( ) ; Object content = propertyDescriptor . getReadMethod ( ) . invoke ( object ) ; if ( isEmptyCollectionOrMap ( content , propertyDescriptor . getPropertyType ( ) ) ) { continue ; } Object value = getContentAsScalarValue ( content ) ; propertyNode . setName ( name ) ; objectNode . addData ( propertyNode ) ; if ( value != null ) { // for each scalar property of a simple bean, add valuepair nodes to data propertyNode . setValue ( value ) ; } else { toUberData ( propertyNode , content ) ; } } Field [ ] fields = object . getClass ( ) . getFields ( ) ; for ( Field field : fields ) { String name = field . getName ( ) ; if ( ! propertyDescriptors . containsKey ( name ) ) { Object content = field . get ( object ) ; Class < ? > type = field . getType ( ) ; if ( isEmptyCollectionOrMap ( content , type ) ) { continue ; } UberNode propertyNode = new UberNode ( ) ; Object value = getContentAsScalarValue ( content ) ; propertyNode . setName ( name ) ; objectNode . addData ( propertyNode ) ; if ( value != null ) { // for each scalar property of a simple bean, add valuepair nodes to data propertyNode . setValue ( value ) ; } else { toUberData ( propertyNode , content ) ; } } } } } catch ( Exception ex ) { throw new RuntimeException ( "failed to transform object " + object , ex ) ; } }
Recursively converts object to nodes of uber data.

@param objectNode
to append to
@param object
to convert
Recursively converts object to nodes of uber data .