/** Returns true if {@code identifier} or any of its enclosing identifiers is excluded. */ private boolean exclude(String identifier) { String excludeMatch = null; for (String rule = identifier; rule != null; rule = enclosing(rule)) { if (excludes.contains(rule)) { excludeMatch = rule; } } if (excludeMatch != null) { usedExcludes.add(excludeMatch); return true; } return false; }
@Test public void enclosing() throws Exception { assertThat(IdentifierSet.enclosing("a.b.Outer#member")).isEqualTo("a.b.Outer"); assertThat(IdentifierSet.enclosing("a.b.Outer")).isEqualTo("a.b.*"); assertThat(IdentifierSet.enclosing("a.b.*")).isEqualTo("a.*"); assertThat(IdentifierSet.enclosing("a.*")).isEqualTo("*"); assertThat(IdentifierSet.enclosing("*")).isNull(); }
/** * Returns true if {@code identifier} or any of its enclosing identifiers is included. If any * enclosing identifier is excluded, that takes precedence and this returns false. */ private boolean includes(String identifier) { if (includes.isEmpty()) return !exclude(identifier); String includeMatch = null; String excludeMatch = null; for (String rule = identifier; rule != null; rule = enclosing(rule)) { if (excludes.contains(rule)) { excludeMatch = rule; } if (includes.contains(rule)) { includeMatch = rule; } } if (excludeMatch != null) { usedExcludes.add(excludeMatch); return false; } if (includeMatch != null) { usedIncludes.add(includeMatch); return true; } return false; }
@Test public void enclosingOnNestedClass() throws Exception { assertThat(IdentifierSet.enclosing("a.b.Outer.Inner#member")).isEqualTo("a.b.Outer.Inner"); assertThat(IdentifierSet.enclosing("a.b.Outer.Inner")).isEqualTo("a.b.Outer.*"); assertThat(IdentifierSet.enclosing("a.b.Outer.*")).isEqualTo("a.b.*"); }
/** Returns true if {@code identifier} or any of its enclosing identifiers is excluded. */ private boolean exclude(String identifier) { String excludeMatch = null; for (String rule = identifier; rule != null; rule = enclosing(rule)) { if (excludes.contains(rule)) { excludeMatch = rule; } } if (excludeMatch != null) { usedExcludes.add(excludeMatch); return true; } return false; }
/** Returns true if {@code identifier} or any of its enclosing identifiers is excluded. */ private boolean exclude(String identifier) { String excludeMatch = null; for (String rule = identifier; rule != null; rule = enclosing(rule)) { if (excludes.contains(rule)) { excludeMatch = rule; } } if (excludeMatch != null) { usedExcludes.add(excludeMatch); return true; } return false; }
/** * Returns true if {@code identifier} or any of its enclosing identifiers is included. If any * enclosing identifier is excluded, that takes precedence and this returns false. */ private boolean includes(String identifier) { if (includes.isEmpty()) return !exclude(identifier); String includeMatch = null; String excludeMatch = null; for (String rule = identifier; rule != null; rule = enclosing(rule)) { if (excludes.contains(rule)) { excludeMatch = rule; } if (includes.contains(rule)) { includeMatch = rule; } } if (excludeMatch != null) { usedExcludes.add(excludeMatch); return false; } if (includeMatch != null) { usedIncludes.add(includeMatch); return true; } return false; }
/** * Returns true if {@code identifier} or any of its enclosing identifiers is included. If any * enclosing identifier is excluded, that takes precedence and this returns false. */ private boolean includes(String identifier) { if (includes.isEmpty()) return !exclude(identifier); String includeMatch = null; String excludeMatch = null; for (String rule = identifier; rule != null; rule = enclosing(rule)) { if (excludes.contains(rule)) { excludeMatch = rule; } if (includes.contains(rule)) { includeMatch = rule; } } if (excludeMatch != null) { usedExcludes.add(excludeMatch); return false; } if (includeMatch != null) { usedIncludes.add(includeMatch); return true; } return false; }