autofixture.generators.time.DateGenerator Maven / Gradle / Ivy
package autofixture.generators.time;
import autofixture.interfaces.FixtureContract;
import autofixture.interfaces.InstanceGenerator;
import autofixture.interfaces.InstanceType;
import java.util.Calendar;
import java.util.Date;
public class DateGenerator implements InstanceGenerator {
private final Calendar calendar = Calendar.getInstance();
@Override
public boolean appliesTo(final InstanceType typeToken) {
return typeToken.isRawTypeAssignableFrom(Date.class);
}
@SuppressWarnings("unchecked")
@Override
public T next(final InstanceType typeToken, final FixtureContract fixture) {
calendar.add(Calendar.SECOND, 1);
return (T) calendar.getTime();
}
@Override
public void setOmittingAutoProperties(final boolean isOn) {
}
}