code: public static <T extends Serializable> PrincipalProvider<T> getOnePrincipalByType(
              Collection<PrincipalProvider<?>> principalProviders, Class<T> principalClass) {
          Collection<PrincipalProvider<T>> pps = getPrincipalsByType(principalProviders, principalClass);
          if (!pps.isEmpty()) {
              return pps.iterator().next();
          } else {
              return null;
          }
      }
docs: Gets one PrincipalProvider corresponding to a type of PrincipalProvider.<br>
  <br>
  For example, you can use this method to get the LDAPUser by calling :<br>
  <code>getOnePrincipalsByType(principals, LDAPUserPrincipalProvider.class)</code> .<br>
  <br>
  Then : <br>
  <code>LDAPUser user =
  ldapUserPrincipalProvider.getPrincipal()</code>.
  
  @param <T>                type of the PrincipalProvider
  @param principalProviders the principals to find the type.
  @param principalClass     the PrincipalProvider type, not null
  @return The user's PrincipalProvider of type principalProviderClass. Null if none.