Adding String lazy caching
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@899895 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5be7671ea1
commit
8860c37b9d
|
@ -28,12 +28,32 @@
|
||||||
*/
|
*/
|
||||||
public final class Range<T> implements Serializable {
|
public final class Range<T> implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Required for serialization support.
|
||||||
|
*
|
||||||
|
* @see java.io.Serializable
|
||||||
|
*/
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The ordering scheme used in this range.
|
||||||
|
*/
|
||||||
private final Comparator<T> comparator;
|
private final Comparator<T> comparator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The minimum value in this range (inclusive).
|
||||||
|
*/
|
||||||
private final T minimum;
|
private final T minimum;
|
||||||
|
/**
|
||||||
|
* The maximum value in this range (inclusive).
|
||||||
|
*/
|
||||||
private final T maximum;
|
private final T maximum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cached output toString (class is immutable).
|
||||||
|
*/
|
||||||
|
private transient String toString = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Constructs a new <code>Range</code> using the specified
|
* <p>Constructs a new <code>Range</code> using the specified
|
||||||
* element as both the minimum and maximum in this range.</p>
|
* element as both the minimum and maximum in this range.</p>
|
||||||
|
@ -320,16 +340,18 @@ public int hashCode() {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder buf = new StringBuilder(32);
|
if (toString == null) {
|
||||||
buf.append("Range[");
|
StringBuilder buf = new StringBuilder(32);
|
||||||
buf.append(this.minimum);
|
buf.append("Range[");
|
||||||
buf.append(',');
|
buf.append(this.minimum);
|
||||||
buf.append(this.maximum);
|
buf.append(',');
|
||||||
buf.append(']');
|
buf.append(this.maximum);
|
||||||
return buf.toString();
|
buf.append(']');
|
||||||
|
toString = buf.toString();
|
||||||
|
}
|
||||||
|
return toString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Taken from Commons Collections - documentation removed as not a public class
|
// Taken from Commons Collections - documentation removed as not a public class
|
||||||
private static class ComparableComparator<E extends Comparable<? super E>> implements Comparator<E>, Serializable {
|
private static class ComparableComparator<E extends Comparable<? super E>> implements Comparator<E>, Serializable {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue