au.gov.tas.dpiwe.mr.bean
Class BeanMethodComparator

java.lang.Object
  extended by au.gov.tas.dpiwe.mr.bean.BeanMethodComparator
All Implemented Interfaces:
Comparator

public class BeanMethodComparator
extends Object
implements Comparator

A comparator which orders bean methods on their names, but placing the primary key getter and setter methods first and second respectively.

Since:
Mr Architecture 1.8
Version:
1.0.0.1
Author:
Kade Hansson

Field Summary
protected  Method primaryKeyGetter
           
protected  Method primaryKeySetter
           
 
Constructor Summary
BeanMethodComparator(Method primaryKeyGetter, Method primaryKeySetter)
          Construct a new bean method comparator.
 
Method Summary
 int compare(Object first, Object second)
          Compares two bean methods.
 boolean equals(Object other)
          Compares two bean method comparators.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

primaryKeyGetter

protected Method primaryKeyGetter

primaryKeySetter

protected Method primaryKeySetter
Constructor Detail

BeanMethodComparator

public BeanMethodComparator(Method primaryKeyGetter,
                            Method primaryKeySetter)
Construct a new bean method comparator.

Parameters:
primaryKeyGetter - method to place first in the ordering.
primaryKeySetter - method to place second in the ordering.
Method Detail

compare

public int compare(Object first,
                   Object second)
Compares two bean methods.

Specified by:
compare in interface Comparator
Parameters:
first - the first bean method.
second - the second bean method.
Returns:
-1 if first before second, 0 if first equals second, or 1 if first after second.

equals

public boolean equals(Object other)
Compares two bean method comparators.

Specified by:
equals in interface Comparator
Overrides:
equals in class Object
Returns:
true.