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

autofixture.generators.objects.implementationdetails.MethodsInvocationResultCache Maven / Gradle / Ivy

The newest version!
package autofixture.generators.objects.implementationdetails;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;

public class MethodsInvocationResultCache {

  private final Map> data = new HashMap<>();

  public boolean containAResultFor(final Object proxy, final Method mtd) {
    return data.containsKey(proxy) && data.get(proxy).containsKey(mtd);
  }

  public Object getResultFor(final Object proxy, final Method method) {
    return data.get(proxy).get(method);
  }

  public void setFor(final Object proxy, final Method method, final Object freshReturnValue) {
    if (!data.containsKey(proxy)) {
      data.put(proxy, new HashMap<>());
    }

    data.get(proxy).put(method, freshReturnValue);
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy