@@ -0,0 +1,1860 @@
+/*%0A * Copyright (C) 2014, C. Ramakrishnan / Auracle.%0A * All rights reserved.%0A *%0A * This code is licensed under the BSD 3-Clause license.%0A * See file LICENSE (or LICENSE.html) for more information.%0A */%0A%0Apackage com.illposed.osc.messageselector;%0A%0Aimport com.illposed.osc.MessageSelector;%0Aimport com.illposed.osc.OSCMessage;%0A%0A/**%0A * Checks whether a certain logical combination of two message selectors matches.%0A */%0Apublic class CombinedMessageSelector implements MessageSelector %7B%0A%0A%09public static enum LogicOperator %7B%0A%09%09AND %7B%0A%09%09%09@Override%0A%09%09%09public boolean matches(final boolean matches1, final boolean matches2) %7B%0A%09%09%09%09return (matches1 && matches2);%0A%09%09%09%7D%0A%09%09%7D,%0A%09%09OR %7B%0A%09%09%09@Override%0A%09%09%09public boolean matches(final boolean matches1, final boolean matches2) %7B%0A%09%09%09%09return (matches1 %7C%7C matches2);%0A%09%09%09%7D%0A%09%09%7D,%0A%09%09XOR %7B%0A%09%09%09@Override%0A%09%09%09public boolean matches(final boolean matches1, final boolean matches2) %7B%0A%09%09%09%09return ((matches1 && !matches2) %7C%7C (!matches1 && matches2));%0A%09%09%09%7D%0A%09%09%7D;%0A%0A%09%09public abstract boolean matches(boolean matches1, boolean matches2);%0A%09%7D%0A%0A%09private final MessageSelector selector1;%0A%09private final MessageSelector selector2;%0A%09private final LogicOperator logicOperator;%0A%0A%09public CombinedMessageSelector(%0A%09%09%09final MessageSelector selector1,%0A%09%09%09final MessageSelector selector2,%0A%09%09%09final LogicOperator logicOperator)%0A%09%7B%0A%09%09this.selector1 = selector1;%0A%09%09this.selector2 = selector2;%0A%09%09this.logicOperator = logicOperator;%0A%09%7D%0A%0A%09public CombinedMessageSelector(%0A%09%09%09final MessageSelector selector1,%0A%09%09%09final MessageSelector selector2)%0A%09%7B%0A%09%09this(selector1, selector2, LogicOperator.AND);%0A%09%7D%0A%0A%09@Override%0A%09public boolean isInfoRequired() %7B%0A%09%09return (selector1.isInfoRequired() %7C%7C selector2.isInfoRequired());%0A%09%7D%0A%0A%09@Override%0A%09public boolean matches(final OSCMessage message) %7B%0A%09%09return logicOperator.matches(selector1.matches(message), selector2.matches(message));%0A%09%7D%0A%7D%0A

introduce `CombinedMessageSelector`