@Test public void testMultiplePackages() { PackageFilter filter = new PackageFilter("org.ocpsoft,de.chkal"); assertEquals(true, filter.isAllowedPackage("org.ocpsoft.pretty.faces")); assertEquals(true, filter.isAllowedPackage("org.ocpsoft")); assertEquals(true, filter.isAllowedPackage("de.chkal.bla")); assertEquals(true, filter.isAllowedPackage("de.chkal")); assertEquals(false, filter.isAllowedPackage("com")); assertEquals(false, filter.isAllowedPackage("com.google")); assertEquals(false, filter.isAllowedPackage("de")); assertEquals(true, new PackageFilter(" org.ocpsoft , de.chkal ").isAllowedPackage("org.ocpsoft.pretty.faces")); assertEquals(true, new PackageFilter(" , org.ocpsoft, de.chkal ,,").isAllowedPackage("de.chkal.bla")); }
public boolean isAllowedPackage(String packageName) { if (packageSet.isEmpty()) { return true; } for (String validPackage : packageSet) { if (packageName.startsWith(validPackage)) { return true; } } return false; }
PackageFilter { public boolean isAllowedPackage(String packageName) { if (packageSet.isEmpty()) { return true; } for (String validPackage : packageSet) { if (packageName.startsWith(validPackage)) { return true; } } return false; } }
PackageFilter { public boolean isAllowedPackage(String packageName) { if (packageSet.isEmpty()) { return true; } for (String validPackage : packageSet) { if (packageName.startsWith(validPackage)) { return true; } } return false; } PackageFilter(String config); }
PackageFilter { public boolean isAllowedPackage(String packageName) { if (packageSet.isEmpty()) { return true; } for (String validPackage : packageSet) { if (packageName.startsWith(validPackage)) { return true; } } return false; } PackageFilter(String config); boolean isAllowedPackage(String packageName); int getNumberOfBasePackages(); @Override String toString(); }
PackageFilter { public boolean isAllowedPackage(String packageName) { if (packageSet.isEmpty()) { return true; } for (String validPackage : packageSet) { if (packageName.startsWith(validPackage)) { return true; } } return false; } PackageFilter(String config); boolean isAllowedPackage(String packageName); int getNumberOfBasePackages(); @Override String toString();  }