XPathQueryBuilder implements QueryBuilder<Condition> { @Override public void setSelector(@NotNull Class<? extends Authorizable> selector) { if (User.class.isAssignableFrom(selector)) { selectorType = AuthorizableType.USER; } else if (Group.class.isAssignableFrom(selector)) { selectorType = AuthorizableType.GROUP; } else { selectorType = AuthorizableType.AUTHORIZABLE; } }  @Override void setSelector(@NotNull Class<? extends Authorizable> selector); @Override void setScope(@NotNull String groupID, boolean declaredOnly); @Override void setCondition(@NotNull Condition condition); @Override void setSortOrder(@NotNull String propertyName, @NotNull Direction direction, boolean ignoreCase); @Override void setSortOrder(@NotNull String propertyName, @NotNull Direction direction); @Override void setLimit(@Nullable Value bound, long maxCount); @Override void setLimit(long offset, long maxCount); @NotNull @Override Condition nameMatches(@NotNull String pattern); @NotNull @Override Condition neq(@NotNull String relPath, @NotNull Value value); @NotNull @Override Condition eq(@NotNull String relPath, @NotNull Value value); @NotNull @Override Condition lt(@NotNull String relPath, @NotNull Value value); @NotNull @Override Condition le(@NotNull String relPath, @NotNull Value value); @NotNull @Override Condition gt(@NotNull String relPath, @NotNull Value value); @NotNull @Override Condition ge(@NotNull String relPath, @NotNull Value value); @NotNull @Override Condition exists(@NotNull String relPath); @NotNull @Override Condition like(@NotNull String relPath, @NotNull String pattern); @NotNull @Override Condition contains(@NotNull String relPath, @NotNull String searchExpr); @NotNull @Override Condition impersonates(@NotNull String name); @NotNull @Override Condition not(@NotNull Condition condition); @NotNull @Override Condition and(@NotNull Condition condition1, @NotNull Condition condition2); @NotNull @Override Condition or(@NotNull Condition condition1, @NotNull Condition condition2);  }
@Test public void testSetSelector() throws Exception { Map<Class<? extends Authorizable>, AuthorizableType> m = new HashMap<>(); m.put(User.class, AuthorizableType.USER); m.put(getTestUser().getClass(), AuthorizableType.USER); m.put(Authorizable.class, AuthorizableType.AUTHORIZABLE); m.put(Group.class, AuthorizableType.GROUP); m.put(getUserManager(root).createGroup("testGroup").getClass(), AuthorizableType.GROUP); for (Class<? extends Authorizable> cl : m.keySet()) { builder.setSelector(cl); assertSame(m.get(cl), builder.getSelectorType()); } }