[New] Added ParameterBagContainer.getRelationI() etc.

This commit is contained in:
Robert von Burg 2020-05-13 08:55:20 +02:00
parent 3a60e720d8
commit c56cf9fcd5
2 changed files with 120 additions and 291 deletions

View File

@ -539,38 +539,11 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
return bag.getLongListP(paramKey);
}
/**
* Returns the {@link Parameter} with the given key from the {@link ParameterBag} with the given bagKey, or null if
* the {@link Parameter} or the {@link ParameterBag} does not exist
*
* @param bagKey
* the key of the {@link ParameterBag} from which the {@link Parameter} is to be returned
* @param paramKey
* the key of the {@link Parameter} which is to be returned
*
* @return the found {@link Parameter} or null if it was not found
*/
@Override
public <U, T extends Parameter<U>> T getParameter(String bagKey, String paramKey) {
return getParameter(bagKey, paramKey, false);
}
/**
* Returns the {@link Parameter} with the given key from the {@link ParameterBag} with the given bagKey, or null if
* the {@link Parameter} or the {@link ParameterBag} does not exist
*
* @param bagKey
* the key of the {@link ParameterBag} from which the {@link Parameter} is to be returned
* @param paramKey
* the key of the {@link Parameter} which is to be returned
* @param assertExists
* if set to true, and the parameter does not exist, a {@link StrolchModelException} is thrown
*
* @return the found {@link Parameter} or null if it was not found
*
* @throws StrolchModelException
* if the element does not exist and {@code assertExists} is true
*/
@Override
public <U, T extends Parameter<U>> T getParameter(String bagKey, String paramKey, boolean assertExists)
throws StrolchModelException {
@ -602,110 +575,66 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
return parameter;
}
/**
* Returns the {@link Parameter} with the given key from the {@link ParameterBag} with the ID {@link
* StrolchModelConstants#BAG_PARAMETERS}, or null if the {@link Parameter} or the {@link ParameterBag} does not
* exist
*
* @param paramKey
* the key of the {@link Parameter} which is to be returned
*
* @return the found {@link Parameter} or null if it was not found
*/
@Override
public <U, T extends Parameter<U>> T getParameter(String paramKey) {
return getParameter(BAG_PARAMETERS, paramKey, false);
}
/**
* Returns the {@link Parameter} with the given key from the {@link ParameterBag} with the ID {@link
* StrolchModelConstants#BAG_PARAMETERS}, or null if the {@link Parameter} or the {@link ParameterBag} does not
* exist
*
* @param paramKey
* the key of the {@link Parameter} which is to be returned
* @param assertExists
* if set to true, and the parameter does not exist, a {@link StrolchModelException} is thrown
*
* @return the found {@link Parameter} or null if it was not found
*/
@Override
public <U, T extends Parameter<U>> T getParameter(String paramKey, boolean assertExists) {
return getParameter(BAG_PARAMETERS, paramKey, assertExists);
}
/**
* Returns the {@link StringParameter} with the given key from the {@link ParameterBag} with the ID {@link
* StrolchModelConstants#BAG_RELATIONS}, or null if the {@link Parameter} or the {@link ParameterBag} does not
* exist
*
* @param paramKey
* the key of the {@link Parameter} which is to be returned
*
* @return the found {@link Parameter} or null if it was not found
*/
@Override
public String getRelationId(String paramKey) throws StrolchModelException {
return getRelationParam(paramKey, true).getValue();
}
@Override
public List<String> getRelationIds(String paramKey) throws StrolchModelException {
return getRelationsParam(paramKey, true).getValue();
}
@Override
public void setRelationId(String paramKey, String id) throws StrolchModelException {
getRelationParam(paramKey, true).setValue(id);
}
@Override
public void setRelationIds(String paramKey, List<String> ids) throws StrolchModelException {
getRelationsParam(paramKey, true).setValue(ids);
}
@Override
public StringParameter getRelationParam(String paramKey) {
return getParameter(BAG_RELATIONS, paramKey, false);
}
/**
* Returns the {@link StringParameter} with the given key from the {@link ParameterBag} with the ID {@link
* StrolchModelConstants#BAG_RELATIONS}, or null if the {@link Parameter} or the {@link ParameterBag} does not
* exist
*
* @param paramKey
* the key of the {@link Parameter} which is to be returned
* @param assertExists
* if set to true, and the parameter does not exist, a {@link StrolchModelException} is thrown
*
* @return the found {@link Parameter} or null if it was not found
*/
@Override
public StringParameter getRelationP(String paramKey) {
return getParameter(BAG_RELATIONS, paramKey, true);
}
@Override
public StringParameter getRelationParam(String paramKey, boolean assertExists) {
return getParameter(BAG_RELATIONS, paramKey, assertExists);
}
/**
* Returns the {@link StringListParameter} with the given key from the {@link ParameterBag} with the ID {@link
* StrolchModelConstants#BAG_RELATIONS}, or null if the {@link Parameter} or the {@link ParameterBag} does not
* exist
*
* @param paramKey
* the key of the {@link Parameter} which is to be returned
*
* @return the found {@link Parameter} or null if it was not found
*/
@Override
public StringListParameter getRelationsParam(String paramKey) {
return getParameter(BAG_RELATIONS, paramKey, false);
}
/**
* Returns the {@link StringListParameter} with the given key from the {@link ParameterBag} with the ID {@link
* StrolchModelConstants#BAG_RELATIONS}, or null if the {@link Parameter} or the {@link ParameterBag} does not
* exist
*
* @param paramKey
* the key of the {@link Parameter} which is to be returned
* @param assertExists
* if set to true, and the parameter does not exist, a {@link StrolchModelException} is thrown
*
* @return the found {@link Parameter} or null if it was not found
*/
@Override
public StringListParameter getRelationsP(String paramKey) {
return getParameter(BAG_RELATIONS, paramKey, true);
}
@Override
public StringListParameter getRelationsParam(String paramKey, boolean assertExists) {
return getParameter(BAG_RELATIONS, paramKey, assertExists);
}
/**
* Returns a {@link Stream} of all the {@link Parameter Parameters}
*
* @param bagKey
* the key of the {@link ParameterBag} from which the {@link Parameter} is to be returned
*
* @return the parameters with the given interpretation
*/
@Override
public Stream<Parameter<?>> streamOfParameters(String bagKey) {
ParameterBag bag = getParameterBag(bagKey);
@ -715,16 +644,6 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
return bag.streamOfParameters();
}
/**
* Returns a {@link Stream} of all the {@link Parameter Parameters} with the given interpretation
*
* @param bagKey
* the key of the {@link ParameterBag} from which the {@link Parameter} is to be returned
* @param interpretation
* the interpretation for which the parameters are to be returned
*
* @return the parameters with the given interpretation
*/
@Override
public Stream<Parameter<?>> streamOfParametersByInterpretation(String bagKey, String interpretation) {
ParameterBag bag = getParameterBag(bagKey);
@ -734,18 +653,6 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
return bag.streamOfParametersByInterpretation(interpretation);
}
/**
* Returns a {@link Stream} of all the {@link Parameter Parameters} with the given interpretation
*
* @param bagKey
* the key of the {@link ParameterBag} from which the {@link Parameter} is to be returned
* @param interpretation
* the interpretation for which the parameters are to be returned
* @param uom
* the uom for which the parameters are to be returned
*
* @return the parameters with the given interpretation
*/
@Override
public Stream<Parameter<?>> streamOfParametersByInterpretationAndUom(String bagKey, String interpretation,
String uom) {
@ -756,48 +663,16 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
return bag.streamOfParametersByInterpretationAndUom(interpretation, uom);
}
/**
* Returns a list of all the {@link Parameter Parameters} with the given interpretation
*
* @param bagKey
* the key of the {@link ParameterBag} from which the {@link Parameter} is to be returned
* @param interpretation
* the interpretation for which the parameters are to be returned
*
* @return the parameters with the given interpretation
*/
@Override
public List<Parameter<?>> getParametersByInterpretation(String bagKey, String interpretation) {
return streamOfParametersByInterpretation(bagKey, interpretation).collect(toList());
}
/**
* Returns a list of all the {@link Parameter Parameters} with the given interpretation
*
* @param bagKey
* the key of the {@link ParameterBag} from which the {@link Parameter} is to be returned
* @param interpretation
* the interpretation for which the parameters are to be returned
* @param uom
* the uom for which the parameters are to be returned
*
* @return the parameters with the given interpretation
*/
@Override
public List<Parameter<?>> getParametersByInterpretationAndUom(String bagKey, String interpretation, String uom) {
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();
@ -813,17 +688,6 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
bag.addParameter(parameter);
}
/**
* Adds a new {@link Parameter} to the {@link ParameterBag} with the given key
*
* @param bagKey
* the key of the {@link ParameterBag} to which the {@link Parameter} should be added
* @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(String bagKey, Parameter<?> parameter) throws StrolchException {
assertNotReadonly();
@ -839,15 +703,6 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
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();
@ -861,16 +716,6 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
return bag.removeParameter(paramKey);
}
/**
* Removes the {@link Parameter} with the given paramKey from the {@link ParameterBag} with the given bagKey
*
* @param bagKey
* the key of the {@link ParameterBag} from which the {@link Parameter} is to be removed
* @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 bagKey, String paramKey) {
assertNotReadonly();
@ -884,29 +729,11 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
return bag.removeParameter(paramKey);
}
/**
* Returns the {@link ParameterBag} with the given key, or null if it does not exist
*
* @param key
* the key of the {@link ParameterBag} to return
*
* @return the {@link ParameterBag} with the given key, or null if it does not exist
*/
@Override
public ParameterBag getParameterBag(String key) {
return getParameterBag(key, false);
}
/**
* Returns the {@link ParameterBag} with the given key, or null if it does not exist
*
* @param key
* the key of the {@link ParameterBag} to return
* @param assertExists
* if set to true, and the parameter bag does not exist, a {@link StrolchModelException} is thrown
*
* @return the {@link ParameterBag} with the given key, or null if it does not exist
*/
@Override
public ParameterBag getParameterBag(String key, boolean assertExists) {
if (this.parameterBagMap == null) {
@ -926,11 +753,6 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
return parameterBag;
}
/**
* Returns a {@link Stream} of {@link ParameterBag ParameterBags}
*
* @return the {@link ParameterBag ParameterBags}
*/
@Override
public Stream<ParameterBag> streamOfParameterBags() {
if (this.parameterBagMap == null || this.parameterBagMap.isEmpty())
@ -938,14 +760,6 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
return this.parameterBagMap.values().stream();
}
/**
* Returns a {@link Stream} of {@link ParameterBag ParameterBags} of the given type
*
* @param type
* the type of {@link ParameterBag} to return
*
* @return the {@link ParameterBag ParameterBags} of the given type
*/
@Override
public Stream<ParameterBag> streamOfParameterBagsByType(String type) {
if (this.parameterBagMap == null || this.parameterBagMap.isEmpty())
@ -955,25 +769,11 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
.filter(map -> map.getType().equals(type));
}
/**
* Returns the {@link ParameterBag ParameterBags} of the given type
*
* @param type
* the type of {@link ParameterBag} to return
*
* @return the {@link ParameterBag ParameterBags} of the given type
*/
@Override
public List<ParameterBag> getParameterBagsByType(String type) {
return streamOfParameterBagsByType(type).collect(toList());
}
/**
* Adds the given {@link ParameterBag} to this {@link GroupedParameterizedElement}
*
* @param bag
* the {@link ParameterBag} to add
*/
@Override
public void addParameterBag(ParameterBag bag) {
assertNotReadonly();
@ -989,14 +789,6 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
bag.setParent(this);
}
/**
* Removes the {@link ParameterBag} with the given key
*
* @param key
* the key of the {@link ParameterBag} to remove
*
* @return the removed {@link ParameterBag}, or null if it does not exist
*/
@Override
public ParameterBag removeParameterBag(String key) {
assertNotReadonly();
@ -1006,40 +798,16 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
return this.parameterBagMap.remove(key);
}
/**
* Returns true if this {@link GroupedParameterizedElement} has any {@link ParameterBag ParameterBag}
*
* @return true if this {@link GroupedParameterizedElement} has any {@link ParameterBag ParameterBag}
*/
@Override
public boolean hasParameterBags() {
return this.parameterBagMap != null && !this.parameterBagMap.isEmpty();
}
/**
* Returns true if the {@link ParameterBag} with the given key exists on this {@link GroupedParameterizedElement}.
*
* @param bagKey
* the key of the {@link ParameterBag} which is to be checked for existence
*
* @return true if the {@link ParameterBag} with the given key exists on this {@link GroupedParameterizedElement}.
*/
@Override
public boolean hasParameterBag(String bagKey) {
return this.parameterBagMap != null && this.parameterBagMap.containsKey(bagKey);
}
/**
* Returns true if the {@link Parameter} with the given paramKey exists on the {@link ParameterBag} with the id
* {@link StrolchModelConstants#BAG_PARAMETERS}
*
* @param paramKey
* the key of the {@link Parameter} to be found
*
* @return true if the {@link Parameter} with the given paramKey exists on the {@link ParameterBag} with the given
* bagKey. False is returned if the {@link ParameterBag} does not exist, or the {@link Parameter} does not exist on
* the {@link ParameterBag}
*/
@Override
public boolean hasParameter(String paramKey) {
if (this.parameterBagMap == null) {
@ -1053,17 +821,6 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
return bag.hasParameter(paramKey);
}
/**
* Returns true if the {@link Parameter} with the given paramKey exists on the {@link ParameterBag} with the id
* {@link StrolchModelConstants#BAG_RELATIONS}
*
* @param paramKey
* the key of the {@link Parameter} to be found
*
* @return true if the {@link Parameter} with the given paramKey exists on the {@link ParameterBag} with the given
* bagKey. False is returned if the {@link ParameterBag} does not exist, or the {@link Parameter} does not exist on
* the {@link ParameterBag}
*/
@Override
public boolean hasRelation(String paramKey) {
if (this.parameterBagMap == null) {
@ -1077,19 +834,6 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
return bag.hasParameter(paramKey);
}
/**
* Returns true if the {@link Parameter} with the given paramKey exists on the {@link ParameterBag} with the given
* bagKey
*
* @param bagKey
* the key of the {@link ParameterBag} on which to find the {@link Parameter}
* @param paramKey
* the key of the {@link Parameter} to be found
*
* @return true if the {@link Parameter} with the given paramKey exists on the {@link ParameterBag} with the given
* bagKey. False is returned if the {@link ParameterBag} does not exist, or the {@link Parameter} does not exist on
* the {@link ParameterBag}
*/
@Override
public boolean hasParameter(String bagKey, String paramKey) {
if (this.parameterBagMap == null) {
@ -1103,11 +847,6 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
return bag.hasParameter(paramKey);
}
/**
* Returns the {@link Set} of keys for the {@link ParameterBag}s on this {@link GroupedParameterizedElement}
*
* @return the {@link Set} of keys for the {@link ParameterBag}s on this {@link GroupedParameterizedElement}
*/
@Override
public Set<String> getParameterBagKeySet() {
if (this.parameterBagMap == null) {

View File

@ -1178,6 +1178,81 @@ public interface ParameterBagContainer extends StrolchElement {
*/
<U, T extends Parameter<U>> T getParameter(String paramKey, boolean assertExists);
/**
* Returns the value of the {@link StringParameter} with the given key from the {@link ParameterBag} with the ID
* {@link StrolchModelConstants#BAG_RELATIONS}, if the {@link Parameter} or the {@link ParameterBag} does not exist,
* then a {@link StrolchModelException} is thrown
*
* @param paramKey
* the key of the {@link StringParameter} for which the value is to be returned
*
* @return the parameter's value
*
* @throws StrolchModelException
* if the parameter does not exist
*/
String getRelationId(String paramKey) throws StrolchModelException;
/**
* Returns the value of the {@link StringListParameter} with the given key from the {@link ParameterBag} with the ID
* {@link StrolchModelConstants#BAG_RELATIONS}, if the {@link Parameter} or the {@link ParameterBag} does not exist,
* then a {@link StrolchModelException} is thrown
*
* @param paramKey
* the key of the {@link StringParameter} for which the value is to be returned
*
* @return the parameter's value
*
* @throws StrolchModelException
* if the parameter does not exist
*/
List<String> getRelationIds(String paramKey) throws StrolchModelException;
/**
* Sets the value of the {@link StringParameter} with the given key on the {@link ParameterBag} with the ID {@link
* StrolchModelConstants#BAG_RELATIONS}, if the {@link Parameter} or the {@link ParameterBag} does not exist, then a
* {@link StrolchModelException} is thrown
*
* @param paramKey
* the key of the {@link StringParameter} for which the value is to be returned
* @param id
* the id of the relation to set
*
* @throws StrolchModelException
* if the parameter does not exist
*/
void setRelationId(String paramKey, String id) throws StrolchModelException;
/**
* Sets the value of the {@link StringListParameter} with the given key on the {@link ParameterBag} with the ID
* {@link StrolchModelConstants#BAG_RELATIONS}, if the {@link Parameter} or the {@link ParameterBag} does not exist,
* then a {@link StrolchModelException} is thrown
*
* @param paramKey
* the key of the {@link StringParameter} for which the value is to be returned
* @param ids
* the ids of the relation to set
*
* @throws StrolchModelException
* if the parameter does not exist
*/
void setRelationIds(String paramKey, List<String> ids) throws StrolchModelException;
/**
* Returns the {@link StringParameter} with the given key from the {@link ParameterBag} with the ID {@link
* StrolchModelConstants#BAG_RELATIONS}, if the {@link Parameter} or the {@link ParameterBag} does not exist, then a
* {@link StrolchModelException} is thrown
*
* @param paramKey
* the key of the {@link Parameter} which is to be returned
*
* @return the found {@link Parameter}
*
* @throws StrolchModelException
* if the parameter does not exist
*/
StringParameter getRelationP(String paramKey) throws StrolchModelException;
/**
* Returns the {@link StringParameter} with the given key from the {@link ParameterBag} with the ID {@link
* StrolchModelConstants#BAG_RELATIONS}, or null if the {@link Parameter} or the {@link ParameterBag} does not
@ -1216,6 +1291,21 @@ public interface ParameterBagContainer extends StrolchElement {
*/
StringListParameter getRelationsParam(String paramKey);
/**
* Returns the {@link StringListParameter} with the given key from the {@link ParameterBag} with the ID {@link
* StrolchModelConstants#BAG_RELATIONS}, if the {@link Parameter} or the {@link ParameterBag} does not exist, then a
* {@link StrolchModelException} is thrown
*
* @param paramKey
* the key of the {@link Parameter} which is to be returned
*
* @return the found {@link Parameter}
*
* @throws StrolchModelException
* if the parameter does not exist
*/
StringListParameter getRelationsP(String paramKey) throws StrolchModelException;
/**
* Returns the {@link StringListParameter} with the given key from the {@link ParameterBag} with the ID {@link
* StrolchModelConstants#BAG_RELATIONS}, or null if the {@link Parameter} or the {@link ParameterBag} does not