JavaBeanPropertyComparator (Hyperic HQ Plugin API)
Keywords: org.hyperic.util.JavaBeanPropertyComparator class

Overview | Package | Class | Tree | Deprecated | Index | Help
| Hyperic HQ Plugin API v. 4.4.0.2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.hyperic.util
Class JavaBeanPropertyComparator

    java.lang.Object
      org.hyperic.util.JavaBeanPropertyComparator

All Implemented Interfaces:
  java.util.Comparator

    public final class JavaBeanPropertyComparator

extends java.lang.Object
implements java.util.Comparator

This is a comparator that can be used for in-process sorting of a collection of java beans.

Field Summary
`static int` | `ASCENDING` Constant value representing an ascending sort.
`static int` | `DESCENDING` Constant value representing a descending sort.

Constructor Summary
`JavaBeanPropertyComparator(java.lang.String propertyName)` Construct a comparator with ``ASCENDING`` sort order and the given property name.
`JavaBeanPropertyComparator(java.lang.String propertyName, int sortOrder)` Construct a comparator with the given sort order and property name.

Method Summary
`int` | `compare(java.lang.Object o1, java.lang.Object o2)` If both `o1` and `o2` have the appropriate java bean property, compare the String representation of that property value on each.
`boolean` | `equals(java.lang.Object obj)` Return true if the passed-in `obj` is the same as this.
`static void` | `main(java.lang.String[] args)`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### ASCENDING

    public static final int ASCENDING

  Constant value representing an ascending sort.

  See Also:
    Constant Field Values

### DESCENDING

    public static final int DESCENDING

  Constant value representing a descending sort.

  See Also:
    Constant Field Values

Constructor Detail

### JavaBeanPropertyComparator

    public JavaBeanPropertyComparator(java.lang.String propertyName)

  Construct a comparator with ``ASCENDING`` sort order and the given property name.

  Parameters:
    `propertyName` - the name of the property to use for sorting

### JavaBeanPropertyComparator

    public JavaBeanPropertyComparator(java.lang.String propertyName,
                                      int sortOrder)

  Construct a comparator with the given sort order and property name.

  Parameters:
    `propertyName` - the name of the property to use for sorting
    `sortOrder` - ``ASCENDING`` or ``DESCENDING``

Method Detail

### compare

    public int compare(java.lang.Object o1,
                       java.lang.Object o2)

  If both `o1` and `o2` have the appropriate java bean property, compare the String representation of that property value on each.

  If one of the objects has the property and the other doesn't, the one with the property will be considered "less" than the one without the property. If neither object has the property, 0 will be returned.

  If the sort order is `DESCENDING`, the value returned will be negated.

  Specified by:
    `compare` in interface `java.util.Comparator`
  Parameters:
    `o1` - the first java bean to compare
    `o2` - the second java bean to compare
  Returns:
    the value of the string-comparison of the two bean's property values

### equals

    public boolean equals(java.lang.Object obj)

  Return true if the passed-in `obj` is the same as this.

  Specified by:
    `equals` in interface `java.util.Comparator`
  Overrides:
    `equals` in class `java.lang.Object`
  Parameters:
    `obj` - the object being tested for equality to this
  Returns:
    true if the object is the same as this, false otherwise

### main

    public static void main(java.lang.String[] args)

Overview | Package | Class | Tree | Deprecated | Index | Help
| Hyperic HQ Plugin API v. 4.4.0.2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2004-2006 Hyperic, Inc. support@hyperic.net, All Rights Reserved.