[New] Added ParameterBagContainer.addParameter() and .removeParameter() without BagId
This commit is contained in:
parent
875382608a
commit
7df625cfdf
|
@ -331,6 +331,31 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
|
||||||
return streamOfParametersByInterpretationAndUom(bagKey, interpretation, uom).collect(toList());
|
return streamOfParametersByInterpretationAndUom(bagKey, interpretation, uom).collect(toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a new {@link Parameter} to the {@link ParameterBag} with the key {@link
|
||||||
|
* StrolchModelConstants#BAG_PARAMETERS}
|
||||||
|
*
|
||||||
|
* @param parameter
|
||||||
|
* the {@link Parameter} to be added to the {@link ParameterBag}
|
||||||
|
*
|
||||||
|
* @throws StrolchException
|
||||||
|
* if the {@link ParameterBag} does not exist
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void addParameter(Parameter<?> parameter) throws StrolchException {
|
||||||
|
assertNotReadonly();
|
||||||
|
if (this.parameterBagMap == null)
|
||||||
|
this.parameterBagMap = new HashMap<>(1, 1.0F);
|
||||||
|
ParameterBag bag = this.parameterBagMap.get(BAG_PARAMETERS);
|
||||||
|
if (bag == null) {
|
||||||
|
String msg = "No parameter bag exists with key {0}"; //$NON-NLS-1$
|
||||||
|
msg = MessageFormat.format(msg, BAG_PARAMETERS);
|
||||||
|
throw new StrolchException(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
bag.addParameter(parameter);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a new {@link Parameter} to the {@link ParameterBag} with the given key
|
* Adds a new {@link Parameter} to the {@link ParameterBag} with the given key
|
||||||
*
|
*
|
||||||
|
@ -357,6 +382,28 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
|
||||||
bag.addParameter(parameter);
|
bag.addParameter(parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the {@link Parameter} with the given paramKey from the {@link ParameterBag} with the key {@link
|
||||||
|
* StrolchModelConstants#BAG_PARAMETERS}
|
||||||
|
*
|
||||||
|
* @param paramKey
|
||||||
|
* the key of the {@link Parameter} which is to be removed
|
||||||
|
*
|
||||||
|
* @return the removed {@link Parameter} or null if it did not exist
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public <U, T extends Parameter<U>> T removeParameter(String paramKey) {
|
||||||
|
assertNotReadonly();
|
||||||
|
if (this.parameterBagMap == null)
|
||||||
|
return null;
|
||||||
|
ParameterBag bag = this.parameterBagMap.get(BAG_PARAMETERS);
|
||||||
|
if (bag == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bag.removeParameter(paramKey);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the {@link Parameter} with the given paramKey from the {@link ParameterBag} with the given bagKey
|
* Removes the {@link Parameter} with the given paramKey from the {@link ParameterBag} with the given bagKey
|
||||||
*
|
*
|
||||||
|
|
|
@ -186,6 +186,18 @@ public interface ParameterBagContainer extends StrolchElement {
|
||||||
*/
|
*/
|
||||||
List<Parameter<?>> getParametersByInterpretationAndUom(String bagKey, String interpretation, String uom);
|
List<Parameter<?>> getParametersByInterpretationAndUom(String bagKey, String interpretation, String uom);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a new {@link Parameter} to the {@link ParameterBag} with the given key {@link
|
||||||
|
* StrolchModelConstants#BAG_PARAMETERS}
|
||||||
|
*
|
||||||
|
* @param parameter
|
||||||
|
* the {@link Parameter} to be added to the {@link ParameterBag}
|
||||||
|
*
|
||||||
|
* @throws StrolchException
|
||||||
|
* if the {@link ParameterBag} does not exist
|
||||||
|
*/
|
||||||
|
void addParameter(Parameter<?> parameter) throws StrolchException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a new {@link Parameter} to the {@link ParameterBag} with the given key
|
* Adds a new {@link Parameter} to the {@link ParameterBag} with the given key
|
||||||
*
|
*
|
||||||
|
@ -199,6 +211,17 @@ public interface ParameterBagContainer extends StrolchElement {
|
||||||
*/
|
*/
|
||||||
void addParameter(String bagKey, Parameter<?> parameter) throws StrolchException;
|
void addParameter(String bagKey, Parameter<?> parameter) throws StrolchException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the {@link Parameter} with the given paramKey from the {@link ParameterBag} with the key {@link
|
||||||
|
* StrolchModelConstants#BAG_PARAMETERS}
|
||||||
|
*
|
||||||
|
* @param paramKey
|
||||||
|
* the key of the {@link Parameter} which is to be removed
|
||||||
|
*
|
||||||
|
* @return the removed {@link Parameter} or null if it did not exist
|
||||||
|
*/
|
||||||
|
<U, T extends Parameter<U>> T removeParameter(String paramKey);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the {@link Parameter} with the given paramKey from the {@link ParameterBag} with the given bagKey
|
* Removes the {@link Parameter} with the given paramKey from the {@link ParameterBag} with the given bagKey
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue