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();
}
}
Aggregations