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

autofixture.generators.enums.InMemoryEnumCache Maven / Gradle / Ivy

package autofixture.generators.enums;

import autofixture.implementationdetails.CircularList;
import autofixture.interfaces.InstanceType;

import java.util.HashMap;
import java.util.Map;

public class InMemoryEnumCache implements EnumCache {

  private final Map, CircularList> sequences = new HashMap<>();

  @Override
  public  void registerIfNotPresent(final InstanceType instanceType) {
    if (!sequences.containsKey(instanceType)) {
      sequences.put(instanceType, CircularList.createFromEnum(instanceType));
    }
  }

  @SuppressWarnings("unchecked")
  @Override
  public  T retrieveNextValueOf(final InstanceType instanceType) {
    return (T) sequences.get(instanceType).next();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy