dev.vality.woody.api.proxy.SpawnTargetProvider Maven / Gradle / Ivy
package dev.vality.woody.api.proxy;
import java.util.function.Supplier;
public class SpawnTargetProvider implements InvocationTargetProvider {
private final Class targetType;
private final Supplier supplier;
public SpawnTargetProvider(Class targetType, Supplier supplier) {
this.targetType = targetType;
this.supplier = supplier;
}
@Override
public T getTarget() {
return createTarget();
}
@Override
public Class getTargetType() {
return targetType;
}
@Override
public void releaseTarget(T target) {
}
@Override
public boolean isSingleTarget() {
return false;
}
protected T createTarget() {
return supplier.get();
}
}