de.hpi.fgis.dude.util
Class OrderedPair<T extends Comparable<T>>

java.lang.Object
  extended by de.hpi.fgis.dude.util.Pair<T,T>
      extended by de.hpi.fgis.dude.util.OrderedPair<T>
Type Parameters:
T - The type of both elements. has to implement Comparable.
All Implemented Interfaces:
AutoJsonable
Direct Known Subclasses:
DuDeObjectPair

public class OrderedPair<T extends Comparable<T>>
extends Pair<T,T>

OrderedPair extends Pair in this way that both elements has to have the same type. Additionally both elements should be Comparable in order to set the smaller element at position 1.

Author:
Matthias Pohl

Constructor Summary
OrderedPair()
          Initializes an empty pair.
OrderedPair(T elem1, T elem2)
          Creates a OrderedPair instance with the passed objects.
 
Method Summary
 void copyPropertiesFrom(OrderedPair<T> pair)
          Copies the properties from the passed pair into the current instance.
 Object getProperty(String key)
          Returns the value of the passed property.
 boolean hasProperty(String key)
          Checks whether the passed property is set.
 void setElements(T elem1, T elem2)
          Resets the pair's elements.
 void setFirstElement(T elem)
          Sets the first element.
 Object setProperty(String key, Object value)
          Sets the passed property.
 void setSecondElement(T elem)
          Sets the second element.
 
Methods inherited from class de.hpi.fgis.dude.util.Pair
equals, getFirstElement, getSecondElement, hashCode, isReflexive, isSymmetricTo, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OrderedPair

public OrderedPair()
Initializes an empty pair.


OrderedPair

public OrderedPair(T elem1,
                   T elem2)
Creates a OrderedPair instance with the passed objects. The order of the elements does not matter since they are stored depending on which of the elements is the smaller one.

Parameters:
elem1 - The first element.
elem2 - The second element.
Method Detail

hasProperty

public boolean hasProperty(String key)
Checks whether the passed property is set.

Parameters:
key - The name of the property.
Returns:
true, if the property is set; otherwise false.

getProperty

public Object getProperty(String key)
Returns the value of the passed property.

Parameters:
key - The name of the property.
Returns:
The value of the property or null, if the property is not set.

setProperty

public Object setProperty(String key,
                          Object value)
Sets the passed property.

Parameters:
key - The name of the property.
value - The value of the property.
Returns:
The old value of the property or null, if it was not set, yet.

copyPropertiesFrom

public void copyPropertiesFrom(OrderedPair<T> pair)
Copies the properties from the passed pair into the current instance. Properties that were already set are not removed unless another value is stored in the property list that shall be copied.

Parameters:
pair - The DuDeObjectPair whose properties shall be copied.

setElements

public void setElements(T elem1,
                        T elem2)
Resets the pair's elements. The order of the passed element may vary depending on the compareTo result.

Parameters:
elem1 - The new element no #1.
elem2 - The new element no #2.

setFirstElement

public void setFirstElement(T elem)
Description copied from class: Pair
Sets the first element.

Overrides:
setFirstElement in class Pair<T extends Comparable<T>,T extends Comparable<T>>
Parameters:
elem - The new first element.

setSecondElement

public void setSecondElement(T elem)
Description copied from class: Pair
Sets the second element.

Overrides:
setSecondElement in class Pair<T extends Comparable<T>,T extends Comparable<T>>
Parameters:
elem - The new second element.


Copyright © 2011 Hasso Plattner Institute - Chair of Information Systems. All Rights Reserved.