import java.util.Comparator;
@SuppressWarnings("rawtypes")
public class ExtendRangeCondiiton implements Comparable {
private Object maxSys;
@Override
public int compareTo(Object o) {
int result = 3;
UserInput userinput = (UserInput) o;
Object object = userinput.getUserInput();
if (object instanceof Integer && maxSys instanceof Integer) {
Integer userInput = (Integer) object;
Integer maxSys1 = (Integer) maxSys;
result = maxSys1.compareTo(userInput);
}
if (object instanceof Float && maxSys instanceof Float) {
Float userInput = (Float) object;
Float maxSys1 = (Float) maxSys;
result = maxSys1.compareTo(userInput);
}
if (object instanceof Double && maxSys instanceof Double) {
Double userInput = (Double) object;
Double maxSys1 = (Double) maxSys;
result = maxSys1.compareTo(userInput);
}
if (object instanceof BigDecimal && maxSys instanceof BigDecimal) {
BigDecimal userInput = (BigDecimal) object;
BigDecimal maxSys1 = (BigDecimal) maxSys;
result = maxSys1.compareTo(userInput);
}
return result;
}
public Object getMaxSys() {
return maxSys;
}
public void setMaxSys(BigDecimal maxSys) {
this.maxSys = maxSys;
}
}
class UserInput {
private Object userInput;
UserInput(Object userInput) {
this.userInput = userInput;
}
public Object getUserInput() {
return userInput;
}
public void setUserInput(Object userInput) {
this.userInput = userInput;
}
}
class ComaprisionPoint {
private Object upperbound;
private Object lowerbound;
private Comparator comparator;
public ComaprisionPoint(Object upperbound, Object lowerbound,
Comparator comparator) {
this.upperbound = upperbound;
this.lowerbound = lowerbound;
this.comparator = comparator;
}
int getMaxRangeComparision(Object o) {
int i = upperbound.compareTo(o);
if (i < 0) {
// Max is less than o;
}
if (i == 0) {
// Max is Equal to o;
}
if (i > 0) {
// Max is Greater than o;
}
return i;
}
public ComaprisionPoint(Comparable comparable) {
this.comparable = comparable;
}
}
class ComparableComparator implements Comparator {
public ComparableComparator() {
}
public int compare(Comparable o1, Comparable o2) {
return o1.compareTo(o2);
}
public int compare(Object x0, Object x1) {
return compare((Comparable) x0, (Comparable) x1);
}
}
No comments:
Post a Comment