com.memority.citadel.shared.api.im.HasMutableAttributeValuesMapLike 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 java.util.Map;
/**
* A mutable version of {@link HasAttributeValuesMapLike}, where the object attributes can be modified.
*/
public interface HasMutableAttributeValuesMapLike extends HasMutableAttributeValues, HasAttributeValuesMapLike {
/**
* Merge the given {@link HasAttributeValuesMapLike} into this one. Attribute Values are added or replaced.
*
* @param values the values to merge
*/
default void merge(HasAttributeValuesMapLike values) {
values.attributeValues().forEach(this::setAttributeValue);
}
/**
* Replace this object's values with those of the given {@link HasAttributeValuesMapLike}.
*
* @param values the new values
*/
default void replace(HasAttributeValuesMapLike values) {
this.clearAttributeValues();
this.merge(values);
}
@Override
default Object put(String key, Object value) {
return HasAttributeValueHelper.doPut(this, key, value);
}
@Override
default void putAll(Map extends String, ?> m) {
m.forEach(this::put);
}
@Override
default Object remove(Object key) {
Object obj = get(key);
this.attributeValueMap().remove(key);
return obj;
}
@Override
default void clear() {
clearAttributeValues();
}
}