
com.helger.commons.collection.multimap.IMultiMapMapBased Maven / Gradle / Ivy
/**
* Copyright (C) 2014-2015 Philip Helger (www.helger.com)
* philip[at]helger[dot]com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.helger.commons.collection.multimap;
import java.util.Map;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.helger.commons.annotation.ReturnsMutableObject;
import com.helger.commons.state.EChange;
/**
* Base interface for a multi map (one key with several values).
*
* @author Philip Helger
* @param
* Key type of outer map
* @param
* Key type of inner map
* @param
* Element type
*/
public interface IMultiMapMapBased extends Map >
{
/**
* Get or create the collection of the specified key.
*
* @param aKey
* The key to use. May not be null
.
* @return The mutable map that can be modified later on. Never
* null
.
*/
@Nonnull
@ReturnsMutableObject ("design")
Map getOrCreate (@Nonnull KEYTYPE1 aKey);
/**
* Add a single value into the container identified by the passed key.
*
* @param aKey
* The key to use. May not be null
.
* @param aInnerKey
* The key for the inner map to use. May not be null
.
* @param aValue
* The value to be added. May be null
.
* @return {@link EChange}
*/
@Nonnull
EChange putSingle (@Nonnull KEYTYPE1 aKey, @Nonnull KEYTYPE2 aInnerKey, @Nullable VALUETYPE aValue);
/**
* Add all values into the container identified by the passed key-value-map.
*
* @param aMap
* The key-value-map to use. May not be null
.
* @return {@link EChange}
*/
@Nonnull
EChange putAllIn (@Nonnull Map extends KEYTYPE1, ? extends Map > aMap);
/**
* Remove a single element from the container identified by the passed key.
*
* @param aKey
* The key to use. May not be null
.
* @param aInnerKey
* The key for the inner map to be removed. May be null
.
* @return {@link EChange}
*/
@Nonnull
EChange removeSingle (@Nonnull KEYTYPE1 aKey, @Nonnull KEYTYPE2 aInnerKey);
/**
* Get a single value from the container identified by the passed keys.
*
* @param aKey
* The key to use. May not be null
.
* @param aInnerKey
* The key for the inner map to use. May not be null
.
* @return null
if no such value exists.
*/
@Nullable
VALUETYPE getSingle (@Nonnull KEYTYPE1 aKey, @Nonnull KEYTYPE2 aInnerKey);
/**
* Check a single element from the container identified by the passed keys is
* present.
*
* @param aKey
* The key to use. May not be null
.
* @param aInnerKey
* The key of the inner map to be checked. May be null
.
* @return true
if contained, false
otherwise.
*/
boolean containsSingle (@Nonnull KEYTYPE1 aKey, @Nonnull KEYTYPE2 aInnerKey);
/**
* @return The total number of contained values recursively over all contained
* maps. Always ≥ 0.
*/
@Nonnegative
long getTotalValueCount ();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy