/** * Returns a list of all of the fields on the given class and any * super-class. It includes fields of all access modifiers. * * @param c * The class to get all the fields from. * @return The * list of fields on the given class or any of its super classes. */ public static LinkedList<Field> getAllFields( final Class<?> c) { // A null class has no fields. // Also, don't get fields from Object. if ( c == null || Object.class.equals( c ) ) { return new LinkedList<Field>(); } // Get the fields from the super class. final LinkedList<Field> fields = ObjectUtil.getAllFields(c.getSuperclass()); // Declared fields include both public and private members fields.addAll( Arrays.asList( c.getDeclaredFields() ) ); return fields; }
/** * Returns a String representing the values of all public/private/protected * fields in the given Class, e.g., "protected double myField" * @param c * Class from which to inspect the fields * @return * The String containing the name, type, and modifier of all fields. */ public static String inspectFields( final Class<?> c ) { StringBuilder retval = new StringBuilder(); for( Field f : ObjectUtil.getAllFields( c ) ) { retval.append( Modifier.toString( f.getModifiers() ) + " " ); retval.append( f.getType().getSimpleName() + " " ); retval.append( f.getName() ); retval.append( "\n" ); } return retval.toString(); }
/** * Returns a list of all of the fields on the given class and any * super-class. It includes fields of all access modifiers. * * @param c * The class to get all the fields from. * @return The * list of fields on the given class or any of its super classes. */ public static LinkedList<Field> getAllFields( final Class<?> c) { // A null class has no fields. // Also, don't get fields from Object. if ( c == null || Object.class.equals( c ) ) { return new LinkedList<Field>(); } // Get the fields from the super class. final LinkedList<Field> fields = ObjectUtil.getAllFields(c.getSuperclass()); // Declared fields include both public and private members fields.addAll( Arrays.asList( c.getDeclaredFields() ) ); return fields; }
/** * Returns a String representing the values of all public/private/protected * fields in the given Class, e.g., "protected double myField" * @param c * Class from which to inspect the fields * @return * The String containing the name, type, and modifier of all fields. */ public static String inspectFields( final Class<?> c ) { StringBuilder retval = new StringBuilder(); for( Field f : ObjectUtil.getAllFields( c ) ) { retval.append( Modifier.toString( f.getModifiers() ) + " " ); retval.append( f.getType().getSimpleName() + " " ); retval.append( f.getName() ); retval.append( "\n" ); } return retval.toString(); }
/** * Returns a String representing the values of all public/private/protected * fields in the given Class, e.g., "protected double myField" * @param c * Class from which to inspect the fields * @return * The String containing the name, type, and modifier of all fields. */ public static String inspectFields( final Class<?> c ) { StringBuilder retval = new StringBuilder(); for( Field f : ObjectUtil.getAllFields( c ) ) { retval.append( Modifier.toString( f.getModifiers() ) + " " ); retval.append( f.getType().getSimpleName() + " " ); retval.append( f.getName() ); retval.append( "\n" ); } return retval.toString(); }
/** * Returns a list of all of the fields on the given class and any * super-class. It includes fields of all access modifiers. * * @param c * The class to get all the fields from. * @return The * list of fields on the given class or any of its super classes. */ public static LinkedList<Field> getAllFields( final Class<?> c) { // A null class has no fields. // Also, don't get fields from Object. if ( c == null || Object.class.equals( c ) ) { return new LinkedList<Field>(); } // Get the fields from the super class. final LinkedList<Field> fields = ObjectUtil.getAllFields(c.getSuperclass()); // Declared fields include both public and private members fields.addAll( Arrays.asList( c.getDeclaredFields() ) ); return fields; }
/** * Returns an ArrayList of field/value pairs * @param o * Object to get the field/value pairs * @return * ArrayList of field/value pairs. The value component of the DefaultPair will * be null if the field is protected by the security manager */ public static ArrayList<DefaultPair<Field,Object>> getAllFieldValues( final Object o ) { LinkedList<Field> fields = ObjectUtil.getAllFields( o.getClass() ); ArrayList<Object> values = ObjectUtil.getFieldValues( o, fields ); return DefaultPair.mergeCollections( fields, values ); }
/** * Returns an ArrayList of field/value pairs * @param o * Object to get the field/value pairs * @return * ArrayList of field/value pairs. The value component of the DefaultPair will * be null if the field is protected by the security manager */ public static ArrayList<DefaultPair<Field,Object>> getAllFieldValues( final Object o ) { LinkedList<Field> fields = ObjectUtil.getAllFields( o.getClass() ); ArrayList<Object> values = ObjectUtil.getFieldValues( o, fields ); return DefaultPair.mergeCollections( fields, values ); }
/** * Returns an ArrayList of field/value pairs * @param o * Object to get the field/value pairs * @return * ArrayList of field/value pairs. The value component of the DefaultPair will * be null if the field is protected by the security manager */ public static ArrayList<DefaultPair<Field,Object>> getAllFieldValues( final Object o ) { LinkedList<Field> fields = ObjectUtil.getAllFields( o.getClass() ); ArrayList<Object> values = ObjectUtil.getFieldValues( o, fields ); return DefaultPair.mergeCollections( fields, values ); }
LinkedList<Field> allFields = ObjectUtil.getAllFields( dataClass );
LinkedList<Field> allFields = ObjectUtil.getAllFields( dataClass );
LinkedList<Field> allFields = ObjectUtil.getAllFields( dataClass );