com.softicar.platform.common.core.immutable.ImmutableIntWrapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of platform-common Show documentation
Show all versions of platform-common Show documentation
The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.
package com.softicar.platform.common.core.immutable;
/**
* Base class for integer wrapper classes.
*
* Same as {@link ImmutableStringWrapper} for integers.
*
* @author Oliver Richers
*/
public class ImmutableIntWrapper implements Comparable {
private final int value;
protected ImmutableIntWrapper(int value) {
this.value = value;
}
public int toInt() {
return value;
}
@Override
public String toString() {
return "" + value;
}
@Override
public int hashCode() {
return value;
}
@Override
public boolean equals(Object other) {
if (other instanceof ImmutableIntWrapper) {
return value == ((ImmutableIntWrapper) other).value;
}
return false;
}
@Override
public int compareTo(ImmutableIntWrapper other) {
return value - other.value;
}
}