Search in sources :

Example 1 with BaseAdditiveAttributeMerger

use of org.apereo.services.persondir.support.merger.BaseAdditiveAttributeMerger in project cas by apereo.

the class CoreAuthenticationUtils method getAttributeMerger.

/**
 * Gets attribute merger.
 *
 * @param mergingPolicy the merging policy
 * @return the attribute merger
 */
public static IAttributeMerger getAttributeMerger(final PrincipalAttributesCoreProperties.MergingStrategyTypes mergingPolicy) {
    switch(mergingPolicy) {
        case MULTIVALUED:
            val merger = new MultivaluedAttributeMerger();
            merger.setDistinctValues(true);
            return merger;
        case ADD:
            return new NoncollidingAttributeAdder();
        case NONE:
            return new BaseAdditiveAttributeMerger() {

                @Override
                protected Map<String, List<Object>> mergePersonAttributes(final Map<String, List<Object>> toModify, final Map<String, List<Object>> toConsider) {
                    return new LinkedHashMap<>(toModify);
                }
            };
        case REPLACE:
        default:
            return new ReplacingAttributeAdder();
    }
}
Also used : lombok.val(lombok.val) ReplacingAttributeAdder(org.apereo.services.persondir.support.merger.ReplacingAttributeAdder) BaseAdditiveAttributeMerger(org.apereo.services.persondir.support.merger.BaseAdditiveAttributeMerger) List(java.util.List) ArrayList(java.util.ArrayList) NoncollidingAttributeAdder(org.apereo.services.persondir.support.merger.NoncollidingAttributeAdder) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) MultivaluedAttributeMerger(org.apereo.services.persondir.support.merger.MultivaluedAttributeMerger) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 lombok.val (lombok.val)1 BaseAdditiveAttributeMerger (org.apereo.services.persondir.support.merger.BaseAdditiveAttributeMerger)1 MultivaluedAttributeMerger (org.apereo.services.persondir.support.merger.MultivaluedAttributeMerger)1 NoncollidingAttributeAdder (org.apereo.services.persondir.support.merger.NoncollidingAttributeAdder)1 ReplacingAttributeAdder (org.apereo.services.persondir.support.merger.ReplacingAttributeAdder)1