All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.memority.citadel.shared.api.im.HasMutableAttributeValuesMapLike Maven / Gradle / Ivy

Go to download

This artifact provides the API classes that are necessary to implement general configuration Rules on the Memority IM platform.

There is a newer version: 3.43.1
Show newest version
/*
 * 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 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();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy