All Downloads are FREE. Search and download functionalities are using the official Maven repository.

autofixture.generators.time.CalendarGenerator 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.GregorianCalendar;

public class CalendarGenerator implements InstanceGenerator {
  private int secondsToAdd = 0;

  @Override
  public  boolean appliesTo(final InstanceType typeToken) {
    return typeToken.isRawTypeAssignableFrom(Calendar.class);
  }

  @SuppressWarnings("unchecked")
  @Override
  public  T next(final InstanceType typeToken, final FixtureContract fixture) {
    final Calendar calendar = new GregorianCalendar();
    calendar.add(Calendar.SECOND, secondsToAdd++);
    return (T) calendar;
  }

  @Override
  public void setOmittingAutoProperties(final boolean isOn) {
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy