autofixture.generators.time.ZoneIdGenerator Maven / Gradle / Ivy
package autofixture.generators.time;
import autofixture.implementationdetails.CircularList;
import autofixture.interfaces.FixtureContract;
import autofixture.interfaces.InstanceGenerator;
import autofixture.interfaces.InstanceType;
import java.time.ZoneId;
import java.util.Set;
/**
* Created by astral on 08.02.15.
*/
public class ZoneIdGenerator implements InstanceGenerator {
private final CircularList zoneIds;
public ZoneIdGenerator() {
final Set availableIds = ZoneId.getAvailableZoneIds();
zoneIds = new CircularList<>(availableIds.toArray(arrayFor(availableIds)));
}
private String[] arrayFor(final Set availableIds) {
return new String[availableIds.size()];
}
@Override
public boolean appliesTo(final InstanceType instanceType) {
return instanceType.isRawTypeAssignableFrom(ZoneId.class);
}
@Override
public T next(final InstanceType instanceType, final FixtureContract fixture) {
return (T) ZoneId.of(zoneIds.next());
}
@Override
public T nextEmpty(final InstanceType instanceType, final FixtureContract fixture) {
return next(instanceType, fixture);
}
@Override
public void setOmittingAutoProperties(final boolean isOn) {
}
}