Class ModelUtils

java.lang.Object
google.registry.model.ModelUtils

public class ModelUtils extends Object
A collection of static methods that deal with reflection on model classes.
  • Constructor Details

    • ModelUtils

      public ModelUtils()
  • Method Details

    • getAllFields

      public static Map<String,Field> getAllFields(Class<?> clazz)
      Lists all instance fields on an object, including non-public and inherited fields.
    • getFieldValues

      public static Map<Field,Object> getFieldValues(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 of ImmutableObject.toString() and ImmutableObject.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.