FilterHelper { public static String getFullFilter(String objectClass, String filter) { if (objectClass == null) { return filter; } String nameFilter = String.format("(objectClass=%s)", objectClass); return (filter == null) ? nameFilter : String.format("(&%s%s)", nameFilter, filter); } private  FilterHelper(); static String getObjectClass(String filter); static boolean isClassExcluded(String className); static String getFullFilter(String objectClass, String filter);  }
@Test public void testGetFullFilter() { String filter = "(a=b)"; String objectClass = "my.Test"; Assert.assertEquals(filter, FilterHelper.getFullFilter(null, filter)); Assert.assertEquals("(objectClass=my.Test)", FilterHelper.getFullFilter(objectClass, null)); Assert.assertEquals("(&(objectClass=my.Test)(a=b))", FilterHelper.getFullFilter(objectClass, filter)); }