From 85a2c268737943bdae3c2f42a661d5609aa9dee6 Mon Sep 17 00:00:00 2001
From: Hendrik Buschmeier <hbuschme@uni-bielefeld.de>
Date: Wed, 19 Jun 2013 14:20:55 +0200
Subject: [PATCH] Category and IUEventType filters now optional in
 IUEventHandler (ipaaca/java).

---
 ipaacalib/java/src/ipaaca/IUEventHandler.java | 30 ++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/ipaacalib/java/src/ipaaca/IUEventHandler.java b/ipaacalib/java/src/ipaaca/IUEventHandler.java
index 25f2135..263c9c6 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):
-- 
GitLab