[New] Added tx.findParameterOnHierarchy() override

This commit is contained in:
Robert von Burg 2020-10-27 11:36:35 +01:00
parent 8a34f5330d
commit 9f47a72168
2 changed files with 27 additions and 0 deletions

View File

@ -557,6 +557,12 @@ public abstract class AbstractTransaction implements StrolchTransaction {
throw new StrolchModelException(MessageFormat.format(msg, locator, stateOrBagOrActivity));
}
@Override
public <U, T extends Parameter<U>> Optional<T> findParameterOnHierarchy(StrolchRootElement element,
String parentParamKey, String paramKey) {
return findParameterOnHierarchy(element, parentParamKey, BAG_PARAMETERS, paramKey);
}
@Override
public <U, T extends Parameter<U>> Optional<T> findParameterOnHierarchy(StrolchRootElement element,
String parentParamKey, String bagKey, String paramKey) {

View File

@ -630,6 +630,27 @@ public interface StrolchTransaction extends AutoCloseable {
<T extends StrolchElement> T findElement(Locator locator, boolean allowNull)
throws StrolchModelException, ClassCastException;
/**
* <p>Finds a parameter with the {@link StrolchConstants#BAG_PARAMETERS} and @paramKey on the given @element, but if
* it does not exists
* on the element, then it retrieves the elements parent by using the bag {@link
* StrolchModelConstants#BAG_RELATIONS} and the param @parentParamKey.</p>
*
* <p>In Strolch relationships are usually defined on the parameter bag with the id {@link
* StrolchModelConstants#BAG_RELATIONS}</p>
*
* @param element
* the element on which to search for the parameter
* @param parentParamKey
* the id of the parameter with which to find the parent
* @param paramKey
* the id of the parameter to find
*
* @return the {@link Optional} with the parameter which was found, following the hierarchy up the chain
*/
<U, T extends Parameter<U>> Optional<T> findParameterOnHierarchy(StrolchRootElement element, String parentParamKey,
String paramKey);
/**
* <p>Finds a parameter with the given @bagKey and @paramKey on the given @element, but if it does not exists
* on the element, then it retrieves the elements parent by using the bag {@link