net.sf.aguacate.model.FieldDynamicDate Maven / Gradle / Ivy
package net.sf.aguacate.model;
import java.util.Date;
import net.sf.aguacate.util.time.TimeUtil;
public class FieldDynamicDate extends FieldDateTime {
private final String minValue;
private final String maxValue;
public FieldDynamicDate(String name, FieldType type, boolean optional, String minValue, String maxValue) {
super(name, type, optional);
this.minValue = minValue;
this.maxValue = maxValue;
}
@Override
public Date getMinValue() {
if ("TODAY".equalsIgnoreCase(minValue)) {
return TimeUtil.today();
} else {
throw new IllegalStateException(minValue);
}
}
@Override
public Date getMaxValue() {
if("FUTURE".equalsIgnoreCase(maxValue)) {
return TimeUtil.limit();
} else {
throw new IllegalStateException(maxValue);
}
}
}