Checkstyle and trailing spaces.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1083206 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oliver Heger 2011-03-19 16:07:20 +00:00
parent c509d13abe
commit 32fd2eeb29
1 changed files with 53 additions and 26 deletions

View File

@ -69,6 +69,7 @@ public final class Range<T> implements Serializable {
* <p>The range uses the natural ordering of the elements to * <p>The range uses the natural ordering of the elements to
* determine where values lie in the range.</p> * determine where values lie in the range.</p>
* *
* @param <T> the type of this {@code Range}
* @param element the value to use for this range, must not be {@code null} * @param element the value to use for this range, must not be {@code null}
* @return the new range object * @return the new range object
* @throws IllegalArgumentException if the value is {@code null} * @throws IllegalArgumentException if the value is {@code null}
@ -87,6 +88,7 @@ public final class Range<T> implements Serializable {
* <p>The arguments may be passed in the order (min,max) or (max,min). The * <p>The arguments may be passed in the order (min,max) or (max,min). The
* getMinimum and getMaximum methods will return the correct values.</p> * getMinimum and getMaximum methods will return the correct values.</p>
* *
* @param <T> the type of this {@code Range}
* @param element1 first value that defines the edge of the range, inclusive * @param element1 first value that defines the edge of the range, inclusive
* @param element2 second value that defines the edge of the range, inclusive * @param element2 second value that defines the edge of the range, inclusive
* @return the new range object * @return the new range object
@ -103,6 +105,7 @@ public final class Range<T> implements Serializable {
* <p>The range uses the passed in {@code Comparator} to * <p>The range uses the passed in {@code Comparator} to
* determine where values lie in the range.</p> * determine where values lie in the range.</p>
* *
* @param <T> the type of this {@code Range}
* @param element the value to use for this range, must not be {@code null} * @param element the value to use for this range, must not be {@code null}
* @param c comparator to be used * @param c comparator to be used
* @return the new range object * @return the new range object
@ -121,6 +124,7 @@ public final class Range<T> implements Serializable {
* <p>The arguments may be passed in the order (min,max) or (max,min). The * <p>The arguments may be passed in the order (min,max) or (max,min). The
* getMinimum and getMaximum methods will return the correct values.</p> * getMinimum and getMaximum methods will return the correct values.</p>
* *
* @param <T> the type of this {@code Range}
* @param element1 first value that defines the edge of the range, inclusive * @param element1 first value that defines the edge of the range, inclusive
* @param element2 second value that defines the edge of the range, inclusive * @param element2 second value that defines the edge of the range, inclusive
* @param c comparator to be used * @param c comparator to be used
@ -131,6 +135,13 @@ public final class Range<T> implements Serializable {
return new Range<T>(element1, element2, c); return new Range<T>(element1, element2, c);
} }
/**
* Creates a new instance of {@code Range}.
*
* @param element1 the first element
* @param element2 the second element
* @param c the comparator to be used
*/
private Range(T element1, T element2, Comparator<T> c) { private Range(T element1, T element2, Comparator<T> c) {
if(element1 == null || element2 == null) { if(element1 == null || element2 == null) {
throw new IllegalArgumentException("Elements in a range must not be null: element1=" + throw new IllegalArgumentException("Elements in a range must not be null: element1=" +
@ -379,15 +390,31 @@ public final class Range<T> implements Serializable {
@SuppressWarnings("rawtypes") // Comparator works for all types @SuppressWarnings("rawtypes") // Comparator works for all types
public static final ComparableComparator<?> INSTANCE = new ComparableComparator(); public static final ComparableComparator<?> INSTANCE = new ComparableComparator();
/**
* Returns a comparator for the specified {@code Comparable} type.
*
* @param <E> the {@code Comparable} type
* @return the comparator for this type
*/
@SuppressWarnings("unchecked") // OK to cast, because comparator works for all types @SuppressWarnings("unchecked") // OK to cast, because comparator works for all types
public static <E extends Comparable<? super E>> ComparableComparator<E> getInstance() { public static <E extends Comparable<? super E>> ComparableComparator<E> getInstance() {
return (ComparableComparator<E>) INSTANCE; return (ComparableComparator<E>) INSTANCE;
} }
/**
* Creates a new instance of {@code ComparableComparator}.
*/
public ComparableComparator() { public ComparableComparator() {
super(); super();
} }
/**
* Compares two objects.
*
* @param obj1 the first object
* @param obj2 the second object
* @return the result of the comparison
*/
public int compare(E obj1, E obj2) { public int compare(E obj1, E obj2) {
return obj1.compareTo(obj2); return obj1.compareTo(obj2);
} }