CompositePrincipalProvider implements PrincipalProvider { public static PrincipalProvider of(@NotNull List<PrincipalProvider> providers) { PrincipalProvider pp; switch (providers.size()) { case 0 : pp = EmptyPrincipalProvider.INSTANCE; break; case 1 : pp = providers.get(0); break; default : pp = new CompositePrincipalProvider(providers); } return pp; } CompositePrincipalProvider(List<PrincipalProvider> providers); static PrincipalProvider of(@NotNull List<PrincipalProvider> providers); @Nullable @Override Principal getPrincipal(@NotNull String principalName); @Nullable @Override ItemBasedPrincipal getItemBasedPrincipal(@NotNull String principalOakPath); @NotNull @Override Set<Principal> getMembershipPrincipals(@NotNull Principal principal); @NotNull @Override Set<Principal> getPrincipals(@NotNull String userID); @NotNull @Override Iterator<Principal> findPrincipals(@Nullable String nameHint, int searchType); @NotNull @Override Iterator<? extends Principal> findPrincipals(int searchType); @NotNull @Override Iterator<? extends Principal> findPrincipals(@Nullable String nameHint, boolean fullText, int searchType,
            long offset, long limit);  }
@Test public void testOfEmptyList() { assertSame(EmptyPrincipalProvider.INSTANCE, CompositePrincipalProvider.of(ImmutableList.<PrincipalProvider>of())); }
@Test public void testOfSingletonList() { PrincipalProvider pp = new TestPrincipalProvider(true); assertSame(pp, CompositePrincipalProvider.of(ImmutableList.of(pp))); }