|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.pojomatic.Pojomatic
public class Pojomatic
Static methods for implementing the Object.equals(Object),
Object.hashCode() and Object.toString() methods on a
annotated POJO. The actual work for a given class is done by a Pojomator created for
that class. This class is careful to create only a single Pojomator per POJO class.
The overhead for looking up the Pojomator by POJO class is light, so a typical use in a
POJO class would be
@Override public int hashCode() {
return Pojomatic.hashCode(this);
}
@Override public boolean equals(Object other) {
return Pojomatic.equals(this, other);
}
@Override public String toString() {
return Pojomatic.toString(this);
}
Pojomator instance
which is created lazily and cached on a per-class basis. The performance penalty for this is
negligible, but if profiling suggests that it is a bottleneck, one can do this by hand:
private final static Pojomator<Manual> POJOMATOR = Pojomatic.pojomator(Manual.class);
@Override public boolean equals(Object other) {
return POJOMATOR.doEquals(this, other);
}
@Override public int hashCode() {
return POJOMATOR.doHashCode(this);
}
@Override public String toString() {
return POJOMATOR.doToString(this);
}
Pojomator| Method Summary | ||
|---|---|---|
static
|
diff(T pojo,
S other)
Compute the differences between pojo and other among the properties
examined by equals(Object, Object) for type T. |
|
static
|
equals(T pojo,
java.lang.Object other)
Compute whether pojo and other are equal to each other in the sense of
Object's equals method. |
|
static
|
hashCode(T pojo)
Compute the hashCode for a POJO. |
|
static
|
pojomator(java.lang.Class<T> pojoClass)
Get the Pojomator for pojoClass. |
|
static
|
toString(T pojo)
Compute the toString representation for a POJO. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static <T> java.lang.String toString(T pojo)
throws java.lang.IllegalArgumentException
toString representation for a POJO.
T - the type of the POJOpojo - the POJO - must not be null
toString representation of pojo.
java.lang.IllegalArgumentException - if pojo's class has no properties annotated for use
with PojomaticPojomator.doToString(Object)
public static <T> int hashCode(T pojo)
throws java.lang.IllegalArgumentException
hashCode for a POJO.
T - the type of the POJOpojo - the POJO - must not be null
hashCode for pojo.
java.lang.IllegalArgumentException - if pojo's class has no properties annotated for use
with PojomaticPojomator.doHashCode(Object)
public static <T> boolean equals(T pojo,
java.lang.Object other)
throws java.lang.IllegalArgumentException
pojo and other are equal to each other in the sense of
Object's equals method.
T - the type of the POJOpojo - the POJO - must not be nullother - the object to compare to for equality
pojo and other are equal to each other in the sense of
Object's equals method.
java.lang.IllegalArgumentException - if pojo's class has no properties annotated for use
with PojomaticPojomator.doEquals(Object, Object)
public static <T,S extends T> Differences diff(T pojo,
S other)
throws java.lang.IllegalArgumentException
pojo and other among the properties
examined by equals(Object, Object) for type T.
T - the static type of the first object to compareS - the static type of the first object to comparepojo - the instance to diff against - must not be nullother - the instance to diff
instance and other
among the properties examined by equals(Object, Object) for type T.
java.lang.IllegalArgumentException - if pojo's class has no properties annotated for use
with Pojomatic
public static <T> Pojomator<T> pojomator(java.lang.Class<T> pojoClass)
throws java.lang.IllegalArgumentException
Pojomator for pojoClass. The same instance will be returned every time
for a given value of pojoClass.
T - the type represented by pojoClasspojoClass - the class to create a Pojomator for.
Pojomator<T>
java.lang.IllegalArgumentException - if pojoClass has no properties annotated for use
with Pojomatic
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||