public class PojoUtils
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
PojoUtils.FieldNaming |
Constructor and Description |
---|
PojoUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
arraysEquals(java.lang.Object a,
java.lang.Object b)
Helper for Arrays.equals().
|
static void |
copyProperties(java.lang.Object dest,
java.lang.Object origin,
PojoUtils.FieldNaming field_naming)
Copy properties "of the same name" from one POJO to the other.
|
static void |
copyProperties(java.lang.Object dest,
java.lang.Object origin,
PojoUtils.FieldNaming field_naming,
java.lang.String[] skip_fields)
Copy properties "of the same name" from one POJO to the other.
|
static void |
copyProperties(java.lang.Object dest,
java.lang.Object origin,
PojoUtils.FieldNaming field_naming,
java.lang.String[] skip_fields,
java.lang.String[] only_fields)
Copy properties "of the same name" from one POJO to the other.
|
static boolean |
equals(java.lang.Object a,
java.lang.reflect.Field fa,
java.lang.Object b,
java.lang.reflect.Field fb) |
static boolean |
equals(java.lang.Object a,
java.lang.Object b)
Same as Objects.equals(a, b) -- copied here because Objects class does not exist in Java6 (if we ever drop
support for Java6, this method can be removed).
|
static void |
filterFields(java.lang.Object o,
java.lang.String includes,
java.lang.String excludes)
Null out fields in this schema and its children as specified by parameters __exclude_fields and __include_fields.
|
static java.lang.Object |
getFieldValue(java.lang.Object o,
java.lang.String name,
PojoUtils.FieldNaming fieldNaming)
Returns field value.
|
static void |
setField(java.lang.Object o,
java.lang.String fieldName,
java.lang.Object value)
Set given field to given value on given object.
|
static void |
setField(java.lang.Object o,
java.lang.String fieldName,
java.lang.Object value,
PojoUtils.FieldNaming objectNamingConvention) |
public static void copyProperties(java.lang.Object dest, java.lang.Object origin, PojoUtils.FieldNaming field_naming)
dest
- Destination POJOorigin
- Origin POJOfield_naming
- Are the fields named consistently, or does one side have underscores?public static void copyProperties(java.lang.Object dest, java.lang.Object origin, PojoUtils.FieldNaming field_naming, java.lang.String[] skip_fields)
dest
- Destination POJOorigin
- Origin POJOfield_naming
- Are the fields named consistently, or does one side have underscores?skip_fields
- Array of origin or destination field names to skippublic static void copyProperties(java.lang.Object dest, java.lang.Object origin, PojoUtils.FieldNaming field_naming, java.lang.String[] skip_fields, java.lang.String[] only_fields)
dest
- Destination POJOorigin
- Origin POJOfield_naming
- Are the fields named consistently, or does one side have underscores?skip_fields
- Array of origin or destination field names to skiponly_fields
- Array of origin or destination field names to include; ones not in this list will be skippedpublic static void filterFields(java.lang.Object o, java.lang.String includes, java.lang.String excludes)
public static boolean equals(java.lang.Object a, java.lang.reflect.Field fa, java.lang.Object b, java.lang.reflect.Field fb)
public static void setField(java.lang.Object o, java.lang.String fieldName, java.lang.Object value, PojoUtils.FieldNaming objectNamingConvention)
public static void setField(java.lang.Object o, java.lang.String fieldName, java.lang.Object value)
o
- object to modifyfieldName
- name of field to setvalue
- value to write the the fieldpublic static java.lang.Object getFieldValue(java.lang.Object o, java.lang.String name, PojoUtils.FieldNaming fieldNaming)
o
- object to read field value fromname
- name of field to readjava.lang.IllegalArgumentException
- when o is null
, or field is not found,
or field cannot be read.public static boolean arraysEquals(java.lang.Object a, java.lang.Object b)
public static boolean equals(java.lang.Object a, java.lang.Object b)