package book.stock;
|
|
import java.math.BigDecimal;
|
|
import foundation.util.Util;
|
|
public enum FreezeCondition {
|
|
None, Positive, Negative;
|
|
public static FreezeCondition parse(String value) {
|
if (Util.isEmpty(value)) {
|
return None;
|
}
|
|
if ("+".equals(value) || "+".equals(value)) {
|
return Positive;
|
}
|
else if ("-".equals(value) || "-".equals(value)) {
|
return Negative;
|
}
|
|
return None;
|
}
|
|
public boolean isCompatible(BigDecimal value) {
|
if (value == null) {
|
return false;
|
}
|
|
if (None == this) {
|
return true;
|
}
|
|
if (Positive == this) {
|
return value.compareTo(BigDecimal.ZERO) >= 0;
|
}
|
|
if (Negative == this) {
|
return value.compareTo(BigDecimal.ZERO) <= 0;
|
}
|
|
return true;
|
}
|
}
|