diff --git a/ipaacalib/java/src/ipaaca/IUEventHandler.java b/ipaacalib/java/src/ipaaca/IUEventHandler.java index 25f2135f70f7a46e527653fd1347c90d8b5c509d..263c9c6fc26cf178266f3532bb7487539f3ec924 100644 --- a/ipaacalib/java/src/ipaaca/IUEventHandler.java +++ b/ipaacalib/java/src/ipaaca/IUEventHandler.java @@ -1,6 +1,7 @@ package ipaaca; import java.util.EnumSet; +import java.util.HashSet; import java.util.Set; /** @@ -32,6 +33,27 @@ public class IUEventHandler // self._for_categories = ( // None if for_categories is None else // (for_categories[:] if hasattr(for_categories, '__iter__') else [for_categories])) + + public IUEventHandler(HandlerFunctor func) + { + this.handleFunctor = func; + this.categories = new HashSet<String>(); + this.eventTypes = EnumSet.allOf(IUEventType.class); + } + + public IUEventHandler(HandlerFunctor func, Set<String> categories) + { + this.handleFunctor = func; + this.categories = categories; + this.eventTypes = EnumSet.allOf(IUEventType.class); + } + + public IUEventHandler(HandlerFunctor func, EnumSet<IUEventType> eventTypes) + { + this.handleFunctor = func; + this.eventTypes = eventTypes; + this.categories = new HashSet<String>(); + } public IUEventHandler(HandlerFunctor func, EnumSet<IUEventType> eventTypes, Set<String> categories) { @@ -57,7 +79,13 @@ public class IUEventHandler */ private boolean conditionMet(IUEventType type, String category) { - return eventTypes.contains(type) && categories.contains(category); + if (this.categories.isEmpty()) { // match any category + return this.eventTypes.contains(type); + } + else + { + return this.eventTypes.contains(type) && this.categories.contains(category); + } } // def call(self, buffer, iu_uid, local, event_type, category):