Inherits java::util::Comparator.
Public Member Functions | |
BeanComparatorAdapter (Comparator beanComparator) | |
final int | compare (Object o1, Object o2) |
final boolean | equals (Object obj) |
This class adapts a Comparator
able to compare bean objects, to a Comparator
able to compare nodes based on those bean objects.
The nodes will be sorted as the underlying bean objects are sorted by the bean comparator passed in the constructor of this object.
A typical use of the BeanComparatorAdapter
will be inside a ChildrenManager
. The method getComparator()
must return a Comparator
that compares nodes. But as a user you may prefer to compare at the bean level as each node represents a given bean. You can therefore write a Comparator
that compares your beans and use the BeanComparatorAdapter
to return a node Comparator
based on your bean Comparator
:
public Comparator getComparator() { return new BeanComparatorAdapter(new MyBeanComparator()); }
In this example, MyBeanComparator
is a class that you write to compare the beans that are used to create the node. MyBeanComparator
only knows how to compare two bean objects, instead of comparing two nodes based on those bean objects.
cern.gp.nodes.children.BeanComparatorAdapter.BeanComparatorAdapter | ( | Comparator | beanComparator | ) |
Creates a new GPBeanNode based on the given bean with no children The new node is therefore a leaf.
final int cern.gp.nodes.children.BeanComparatorAdapter.compare | ( | Object | o1, | |
Object | o2 | |||
) |
References cern.gp.nodes.GPNode.getBean().
final boolean cern.gp.nodes.children.BeanComparatorAdapter.equals | ( | Object | obj | ) |