|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.m2technologies.open_arm.utilities.generic_object_functions.GenericObjectFunctions
Copyright 2005 Mark Masterson
Licensed under the Apache License, Version 2.0 (the "License");
you may
not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS
OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Description:
Constructor Summary | |
GenericObjectFunctions()
|
Method Summary | |
boolean |
equals(java.lang.Object objectA,
java.lang.Object objectB)
Will compare the two Object parameters, to determine if they are a) instances of the same Class, or type, and b) if yes, then if the values of their declared fields are all identical. |
java.util.Comparator |
getGenericComparator()
Returns an implementation of the java.util.Comparator interface that uses the Reflection API to determine the sort order. |
int |
hashCode(java.lang.Object objectA)
Will compute a hash code for the Object passed as a parameter, using the same basic technique as the equals() method of this class. |
java.lang.String |
toString(java.lang.Object object)
Returns a String containing the name of the Class of the Object paramter, the name of the super class (if any), and the names and values of all declared fields found in the Object. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public GenericObjectFunctions()
Method Detail |
public java.lang.String toString(java.lang.Object object)
public String toString() {
return GenericObjectFunctions.toString(this);
}
public boolean equals(java.lang.Object objectA, java.lang.Object objectB)
public boolean equals(Object objectA) {
return
GenericObjectFunctions.equals(objectA, this);
}
public int hashCode(java.lang.Object objectA)
public int hashCode() {
return GenericObjectFunctions.hashCode(this);
}
public java.util.Comparator getGenericComparator()
java.util.TreeSet baum = new java.util.TreeSet(GenericObjectFunctions.getGenericComparator());
baum.add(a2);
baum.add(a1);
Assuming that a1 is intended to be before a2 in the sort order, and
assuming that the Reflection API generated hash-code actually produced such a sort order, then the objects should
be found in the TreeSet so sorted. Generally, one would use this technique rather than writing a compareTo()
method in each of your classes.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |