Example usage for org.springframework.util ClassUtils isPrimitiveArray

List of usage examples for org.springframework.util ClassUtils isPrimitiveArray

Introduction

In this page you can find the example usage for org.springframework.util ClassUtils isPrimitiveArray.

Prototype

public static boolean isPrimitiveArray(Class<?> clazz) 

Source Link

Document

Check if the given class represents an array of primitives, i.e.

Usage

From source file:org.LexGrid.LexBIG.caCore.utils.LexEVSCaCoreUtils.java

public static <T> T recurseReflect(final T obj, final DoInReflectionCallback callback) {
    if (obj == null) {
        return null;
    }/*from  w  w w  .ja  v a  2  s .c om*/
    ReflectionUtils.doWithFields(obj.getClass(), new FieldCallback() {

        public void doWith(Field arg0) throws IllegalArgumentException, IllegalAccessException {

            if (!ClassUtils.isPrimitiveOrWrapper(arg0.getType()) && !ClassUtils.isPrimitiveArray(arg0.getType())
                    && !ClassUtils.isPrimitiveWrapperArray(arg0.getType()) && !arg0.getType().isEnum()
                    && (isLexBigClass(arg0.getType()) || Collection.class.isAssignableFrom(arg0.getType())
                            || Map.class.isAssignableFrom(arg0.getType()))) {

                arg0.setAccessible(true);
                Object recurse = arg0.get(obj);

                if (recurse != null) {

                    if (CycleDetectingCallback.class.isAssignableFrom(recurse.getClass())) {
                        System.out.println("ere");
                    }

                    if (Collection.class.isAssignableFrom(recurse.getClass())) {
                        Collection collection = (Collection) recurse;
                        for (Object o : collection) {
                            if (callback.actionRequired(o)) {
                                collection.remove(o);
                                collection.add(recurseReflect(o, callback));
                            } else {
                                recurseReflect(o, callback);
                            }
                        }
                    } else if (Map.class.isAssignableFrom(recurse.getClass())) {
                        Map map = (Map) recurse;
                        for (Object key : map.keySet()) {
                            Object value = map.get(key);
                            if (callback.actionRequired(key) || callback.actionRequired(value)) {
                                map.remove(key);
                                map.put(recurseReflect(key, callback), recurseReflect(value, callback));
                            } else {
                                recurseReflect(key, callback);
                                recurseReflect(value, callback);
                            }
                        }
                    } else {
                        if (callback.actionRequired(recurse)) {
                            Object newObject = recurseReflect(recurse, callback);
                            arg0.set(obj, newObject);
                        } else {
                            recurseReflect(recurse, callback);
                        }
                    }
                }
            }
        }
    });

    return callback.doInReflection(obj);
}