package ru.gravit.utils; import java.util.HashSet; import java.util.Set; public class BiHookSet { public Set> list = new HashSet<>(); @FunctionalInterface public interface Hook { boolean hook(V object, R context) throws HookException; } public void registerHook(Hook hook) { list.add(hook); } public boolean unregisterHook(Hook hook) { return list.remove(hook); } public boolean hook(V context, R object) throws HookException { for(Hook hook : list) { if(hook.hook(context, object)) return true; } return false; } }