@JsonIgnore
    default <T> T getSingleValuedAttribute(final String name, final Class<T> expectedType) {
        if (containsAttribute(name)) {
            val values = getAttributes().get(name);
            return values
                .stream()
                .filter(Objects::nonNull)
                .findFirst()
                .map(expectedType::cast)
                .orElse(null);
        }
        return null;
    }
Gets attribute.

@param <T>          the type parameter
@param name         the name
@param expectedType the expected type
@return the attribute
api/cas-server-core-api-authentication/src/main/java/org/apereo/cas/authentication/principal/Principal.java