com.memority.citadel.shared.api.im.HasAttributeValuesMapLike Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of citadel-api Show documentation
Show all versions of citadel-api Show documentation
This artifact provides the API classes that are necessary to implement general configuration Rules on the Memority IM platform.
/*
* Copyright (c) 2016-2023 Memority. All Rights Reserved.
*
* This file is part of Memority Citadel API , a Memority project.
*
* This file is released under the Memority Public Artifacts End-User License Agreement,
* see
* Unauthorized copying of this file, via any medium is strictly prohibited.
*/
package com.memority.citadel.shared.api.im;
import org.apache.commons.lang3.Validate;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* {@link HasAttributeValues} extension also implementing {@code Map Map}, so that SpEL syntactic sugar
* is available ({@code OBJECT.attributes['firstName']} instead of {@code OBJECT.attributes.value('firstName')})/
*/
@SuppressWarnings("NullableProblems")
public interface HasAttributeValuesMapLike extends HasAttributeValues, Map {
/*
* Map implementation for SpEL syntactic sugar.
*/
@Override
default int size() {
return attributeValueMap().size();
}
@Override
default boolean isEmpty() {
return attributeValueMap().isEmpty();
}
@Override
default boolean containsKey(Object key) {
return has((String) key);
}
@Override
default boolean containsValue(Object value) {
return attributeValueMap().keySet().stream().anyMatch(attrId -> Objects.equals(HasAttributeValueHelper.doGet(this, attrId), value));
}
@Override
default Object get(Object key) {
return HasAttributeValueHelper.doGet(this, (String)key);
}
@Override
default Object put(String key, Object value) {
throw new UnsupportedOperationException();
}
@Override
default Object remove(Object key) {
throw new UnsupportedOperationException();
}
@Override
default void putAll(Map extends String, ?> m) {
throw new UnsupportedOperationException();
}
@Override
default void clear() {
throw new UnsupportedOperationException();
}
@Override
default Set keySet() {
return attributeValueMap().keySet();
}
@Override
default Collection