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); } public void registerHook(Hook hook) { list.add(hook); } public boolean unregisterHook(Hook hook) { return list.remove(hook); } public boolean hook(V object, R context) { for(Hook hook : list) { if(hook.hook(object, context)) return true; } return false; } }