CompositeCredentialsSupport implements CredentialsSupport { @Override @NotNull public Set<Class> getCredentialClasses() { Collection<CredentialsSupport> all = this.credentialSupplier.get(); if (all.isEmpty()) { return ImmutableSet.of(); } else if (all.size() == 1) { return all.iterator().next().getCredentialClasses(); } else { Set<Class> classes = newHashSet(); for (CredentialsSupport c : all) { classes.addAll(c.getCredentialClasses()); } return classes; } } private  CompositeCredentialsSupport(@NotNull Supplier<Collection<CredentialsSupport>> credentialSupplier); static CredentialsSupport newInstance(@NotNull Supplier<Collection<CredentialsSupport>> credentialSupplier); @Override @NotNull Set<Class> getCredentialClasses(); @Override @Nullable String getUserId(@NotNull Credentials credentials); @Override @NotNull Map<String, ?> getAttributes(@NotNull Credentials credentials); @Override boolean setAttributes(@NotNull Credentials credentials, @NotNull Map<String, ?> attributes);  }
@Test public void testGetCredentialClasses() { Set<Class> supported = credentialsSupport.getCredentialClasses(); assertNotNull(supported); assertEquals(2, supported.size()); assertTrue(supported.contains(TestCredentials.class)); assertTrue(supported.contains(SimpleCredentials.class)); }