
com.oracle.coherence.common.util.MutableOptions Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of coherence Show documentation
Show all versions of coherence Show documentation
Oracle Coherence Community Edition
/*
* Copyright (c) 2020 Oracle and/or its affiliates.
*
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
package com.oracle.coherence.common.util;
/**
* A mutable collection of zero or more values, typically called an option,
* internally arranged as a map, keyed by the concrete type of each option in
* the collection.
*
* @param the base type of the options in the collection
*
* @author Jonathan Knight 2020.11.04
* @since 20.12
*/
public class MutableOptions
extends Options
{
// ----- constructors ---------------------------------------------------
/**
* Create an options collection of the specified option type.
*
* @param clsType the type of option this in this options collection
*/
public MutableOptions(Class clsType)
{
super(clsType);
}
// ----- MutableOptions methods ------------------------------------------------
/**
* Adds an option to the collection, replacing an
* existing option of the same concrete type if one exists.
*
* @param option the option to add
*
* @return the {@link Options} to permit fluent-style method calls
*/
public MutableOptions add(T option)
{
Class clz = getClassOf(option);
m_mapOptions.put(clz, option);
return this;
}
/**
* Adds an array of options to the collection, replacing
* existing options of the same concrete type where they exist.
*
* @param aOptions the options to add
*
* @return the {@link Options} to permit fluent-style method calls
*/
public Options addAll(T[] aOptions)
{
if (aOptions != null)
{
for (T option : aOptions)
{
add(option);
}
}
return this;
}
/**
* Adds all of the options in the specified {@link Options}
* to this collection, replacing existing options of the same concrete
* type where they exist.
*
* @param options the {@link Options} to add
*
* @return the {@link Options} to permit fluent-style method calls
*/
public Options addAll(Options extends T> options)
{
for (T option : options.asArray())
{
add(option);
}
return this;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy