cern::gp::nodes::children::BeanComparatorAdapter Class Reference

Inheritance diagram for cern::gp::nodes::children::BeanComparatorAdapter:
Inheritance graph
[legend]
Collaboration diagram for cern::gp::nodes::children::BeanComparatorAdapter:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 BeanComparatorAdapter (Comparator beanComparator)
final int compare (Object o1, Object o2)
final boolean equals (Object obj)

Private Attributes

final Comparator beanComparator

Detailed Description

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.

Version:
Revision
1.2
Date
2006/09/25 08:52:36
Author:
Lionel Mestre

Constructor & Destructor Documentation

cern::gp::nodes::children::BeanComparatorAdapter::BeanComparatorAdapter ( Comparator  beanComparator  )  [inline]

Creates a new GPBeanNode based on the given bean with no children The new node is therefore a leaf.


Member Function Documentation

final int cern::gp::nodes::children::BeanComparatorAdapter::compare ( Object  o1,
Object  o2 
) [inline]
final boolean cern::gp::nodes::children::BeanComparatorAdapter::equals ( Object  obj  )  [inline]

Member Data Documentation

Referenced by compare().


The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2