1 20 21 package net.innig.macker.util; 22 23 import net.innig.macker.rule.RulesException; 24 25 public class IncludeExcludeLogic 26 { 27 public static boolean apply(IncludeExcludeNode node) 28 throws RulesException 29 { 30 return applyNext( 31 node, 32 node.isInclude() 33 ? false : true); } 36 37 private static boolean applyNext( 38 IncludeExcludeNode node, 39 boolean prevMatches) 40 throws RulesException 41 { 42 IncludeExcludeNode child = node.getChild(), next = node.getNext(); 43 boolean curMatches = node.matches(); 44 boolean matchesSoFar = 45 node.isInclude() 46 ? prevMatches || ( curMatches && (child == null || apply(child))) 47 : prevMatches && (!curMatches || (child != null && apply(child))); 48 return 49 (next == null) 50 ? matchesSoFar 51 : applyNext(next, matchesSoFar); 52 } 53 } | Popular Tags |