Package google.registry.model
Class ModelUtils
- java.lang.Object
-
- google.registry.model.ModelUtils
-
public class ModelUtils extends java.lang.Object
A collection of static methods that deal with reflection on model classes.
-
-
Constructor Summary
Constructors Constructor Description ModelUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static <T extends ImmutableObject>
TcloneEmptyToNull(T obj)
Returns a clone of the object and sets empty collections, arrays, maps and strings to null.static java.util.Map<java.lang.String,java.lang.reflect.Field>
getAllFields(java.lang.Class<?> clazz)
Lists all instance fields on an object, including non-public and inherited fields.static java.util.Map<java.lang.reflect.Field,java.lang.Object>
getFieldValues(java.lang.Object instance)
Returns a map from Field objects (including non-public and inherited fields) to values.
-
-
-
Method Detail
-
getAllFields
public static java.util.Map<java.lang.String,java.lang.reflect.Field> getAllFields(java.lang.Class<?> clazz)
Lists all instance fields on an object, including non-public and inherited fields.
-
getFieldValues
public static java.util.Map<java.lang.reflect.Field,java.lang.Object> getFieldValues(java.lang.Object instance)
Returns a map from Field objects (including non-public and inherited fields) to values.This turns arrays into
List
objects so that ImmutableObject can more easily use the returned map in its implementation ofImmutableObject.toString()
andImmutableObject.equals(java.lang.Object)
, which work by comparing and printing these maps.
-
cloneEmptyToNull
protected static <T extends ImmutableObject> T cloneEmptyToNull(T obj)
Returns a clone of the object and sets empty collections, arrays, maps and strings to null.
-
-