Settle on interface w/ default methods. Fixes #8

This commit is contained in:
Justin Abrahms 2022-05-27 20:52:25 -07:00
parent b57e55436d
commit f5546691a3
No known key found for this signature in database
GPG Key ID: 599E2E12011DC474
1 changed files with 5 additions and 6 deletions

View File

@ -4,12 +4,11 @@ import com.google.common.collect.ImmutableMap;
import java.util.Optional; import java.util.Optional;
// TODO: interface? or abstract class? public interface Hook<T> {
public abstract class Hook<T> { default Optional<EvaluationContext> before(HookContext<T> ctx, ImmutableMap<String, Object> hints) {
public Optional<EvaluationContext> before(HookContext<T> ctx, ImmutableMap<String, Object> hints) {
return Optional.empty(); return Optional.empty();
} }
public void after(HookContext<T> ctx, FlagEvaluationDetails<T> details, ImmutableMap<String, Object> hints) {} default void after(HookContext<T> ctx, FlagEvaluationDetails<T> details, ImmutableMap<String, Object> hints) {}
public void error(HookContext<T> ctx, Exception error, ImmutableMap<String, Object> hints) {} default void error(HookContext<T> ctx, Exception error, ImmutableMap<String, Object> hints) {}
public void finallyAfter(HookContext<T> ctx, ImmutableMap<String, Object> hints) {} default void finallyAfter(HookContext<T> ctx, ImmutableMap<String, Object> hints) {}
} }