gov.sandia.cognition.collection.DefaultComparator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cognitive-foundry Show documentation
Show all versions of cognitive-foundry Show documentation
A single jar with all the Cognitive Foundry components.
/*
* File: DefaultComparator.java
* Authors: Justin Basilico
* Company: Sandia National Laboratories
* Project: Cognitive Foundry
*
* Copyright September 30, 2008, Sandia Corporation.
* Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
* license for use of this work by or on behalf of the U.S. Government. Export
* of this program may require a license from the United States Government.
* See CopyrightHistory.txt for complete details.
*
*/
package gov.sandia.cognition.collection;
import gov.sandia.cognition.annotation.CodeReview;
import gov.sandia.cognition.util.AbstractCloneableSerializable;
import java.util.Comparator;
/**
* A default comparator that just calls compare on the comparable generic
* it uses. Thus, it creates the natural ordering according to the compareTo
* method on the {@code Comparable} objects it is given.
*
* @param The type being compared. Must be {@code Comparable}.
* @author Justin Basilico
* @since 2.1
*/
@CodeReview(
reviewer="Kevin R. Dixon",
date="2008-12-02",
changesNeeded=false,
comments="Looks good."
)
public class DefaultComparator>
extends AbstractCloneableSerializable
implements Comparator
{
/**
* Creates a new {@code DefaultComparator}.
*/
public DefaultComparator()
{
super();
}
public int compare(
final T o1,
final T o2)
{
return o1.compareTo(o2);
}
}