[New] Added StrolchRootElement.ensureReadOnly() and .readOnly()

This commit is contained in:
Robert von Burg 2023-07-20 16:30:03 +02:00
parent 6787b00f06
commit 7cf17f0876
Signed by: eitch
GPG Key ID: 75DB9C85C74331F7
4 changed files with 195 additions and 240 deletions

View File

@ -15,11 +15,6 @@
*/
package li.strolch.model;
import java.text.MessageFormat;
import java.time.*;
import java.util.Date;
import java.util.Objects;
import li.strolch.exception.StrolchPolicyException;
import li.strolch.model.Locator.LocatorBuilder;
import li.strolch.model.policy.PolicyDef;
@ -29,6 +24,11 @@ import li.strolch.model.xml.StrolchXmlHelper;
import li.strolch.utils.dbc.DBC;
import li.strolch.utils.iso8601.ISO8601;
import java.text.MessageFormat;
import java.time.*;
import java.util.Date;
import java.util.Objects;
/**
* The Order is an object used in the EDF to transfer data from one range to another. Orders are not to be thought of as
* Resources. Resources are supposed to be thought of as things i.e. a table, a machine and so forth, where a order is
@ -57,12 +57,9 @@ public class Order extends AbstractStrolchRootElement implements StrolchRootElem
/**
* Default Constructor
*
* @param id
* the id
* @param name
* the name
* @param type
* the type
* @param id the id
* @param name the name
* @param type the type
*/
public Order(String id, String name, String type) {
super(id, name, type);
@ -74,16 +71,11 @@ public class Order extends AbstractStrolchRootElement implements StrolchRootElem
/**
* Extended Constructor for date and {@link State}
*
* @param id
* the id
* @param name
* the name
* @param type
* the type
* @param date
* the date
* @param state
* the state
* @param id the id
* @param name the name
* @param type the type
* @param date the date
* @param state the state
*/
public Order(String id, String name, String type, Date date, State state) {
super(id, name, type);
@ -258,6 +250,19 @@ public class Order extends AbstractStrolchRootElement implements StrolchRootElem
return this;
}
@Override
public Order ensureReadOnly() {
if (isReadOnly())
return this;
return getClone(true).readOnly();
}
@Override
public Order readOnly() {
setReadOnly();
return this;
}
@Override
protected void fillLocator(LocatorBuilder lb) {
lb.append(Tags.ORDER).append(getType()).append(getId());
@ -311,8 +316,8 @@ public class Order extends AbstractStrolchRootElement implements StrolchRootElem
@Override
public String toString() {
return "Order [id=" + this.id + ", name=" + this.name + ", type=" + this.type + ", state=" + this.state
+ ", date=" + ISO8601.toString(this.date) + ", version=" + this.version + "]";
return "Order [id=" + this.id + ", name=" + this.name + ", type=" + this.type + ", state=" + this.state +
", date=" + ISO8601.toString(this.date) + ", version=" + this.version + "]";
}
@Override
@ -323,10 +328,8 @@ public class Order extends AbstractStrolchRootElement implements StrolchRootElem
/**
* Creates a {@link Locator} for orders of the given type and id
*
* @param type
* the type of order
* @param id
* the id of the order
* @param type the type of order
* @param id the id of the order
*
* @return the locator
*/
@ -337,10 +340,8 @@ public class Order extends AbstractStrolchRootElement implements StrolchRootElem
/**
* Parses the given XML and returns the order with the given ID
*
* @param xml
* the xml to parse
* @param id
* the id of the order to return from the parsed elements
* @param xml the xml to parse
* @param id the id of the order to return from the parsed elements
*
* @return the order, or null if it does not exist
*/

View File

@ -15,12 +15,6 @@
*/
package li.strolch.model;
import static java.util.stream.Collectors.toList;
import java.text.MessageFormat;
import java.util.*;
import java.util.stream.Stream;
import li.strolch.exception.StrolchException;
import li.strolch.exception.StrolchModelException;
import li.strolch.exception.StrolchPolicyException;
@ -33,6 +27,12 @@ import li.strolch.model.visitor.StrolchElementVisitor;
import li.strolch.model.xml.StrolchXmlHelper;
import li.strolch.utils.dbc.DBC;
import java.text.MessageFormat;
import java.util.*;
import java.util.stream.Stream;
import static java.util.stream.Collectors.toList;
/**
* @author Robert von Burg <eitch@eitchnet.ch>
*/
@ -53,12 +53,9 @@ public class Resource extends AbstractStrolchRootElement implements StrolchRootE
/**
* Default constructor
*
* @param id
* the id
* @param name
* the name
* @param type
* the type
* @param id the id
* @param name the name
* @param type the type
*/
public Resource(String id, String name, String type) {
super(id, name, type);
@ -123,8 +120,7 @@ public class Resource extends AbstractStrolchRootElement implements StrolchRootE
return null;
}
@SuppressWarnings("unchecked")
T timedState = (T) this.timedStateMap.get(id);
@SuppressWarnings("unchecked") T timedState = (T) this.timedStateMap.get(id);
if (timedState == null && assertExists) {
String msg = "The TimedState {0} does not exist";
throw new StrolchModelException(MessageFormat.format(msg, getLocator().append(Tags.STATE, id)));
@ -133,7 +129,7 @@ public class Resource extends AbstractStrolchRootElement implements StrolchRootE
return timedState;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@SuppressWarnings({"unchecked", "rawtypes"})
public <T extends StrolchTimedState> T removeTimedState(String id) {
assertNotReadonly();
if (this.timedStateMap == null) {
@ -171,8 +167,7 @@ public class Resource extends AbstractStrolchRootElement implements StrolchRootE
/**
* Returns a {@link Stream} of all the {@link StrolchTimedState StrolchTimedStates} with the given interpretation
*
* @param interpretation
* the interpretation for which the timed states are to be returned
* @param interpretation the interpretation for which the timed states are to be returned
*
* @return the timed states with the given interpretation
*/
@ -186,10 +181,8 @@ public class Resource extends AbstractStrolchRootElement implements StrolchRootE
/**
* Returns a {@link Stream} of all the {@link StrolchTimedState StrolchTimedStates} with the given interpretation
*
* @param interpretation
* the interpretation for which the timed states are to be returned
* @param uom
* the uom for which the timed states are to be returned
* @param interpretation the interpretation for which the timed states are to be returned
* @param uom the uom for which the timed states are to be returned
*
* @return the timed states with the given interpretation
*/
@ -198,16 +191,14 @@ public class Resource extends AbstractStrolchRootElement implements StrolchRootE
if (this.timedStateMap == null || this.timedStateMap.isEmpty())
return Stream.empty();
return this.timedStateMap.values()
.stream()
return this.timedStateMap.values().stream()
.filter(s -> s.getInterpretation().equals(interpretation) && s.getUom().equals(uom));
}
/**
* Returns a list of all the {@link StrolchTimedState StrolchTimedStates} with the given interpretation
*
* @param interpretation
* the interpretation for which the timed states are to be returned
* @param interpretation the interpretation for which the timed states are to be returned
*
* @return the timed states with the given interpretation
*/
@ -218,10 +209,8 @@ public class Resource extends AbstractStrolchRootElement implements StrolchRootE
/**
* Returns a list of all the {@link StrolchTimedState StrolchTimedStates} with the given interpretation
*
* @param interpretation
* the interpretation for which the timed states are to be returned
* @param uom
* the uom for which the timed states are to be returned
* @param interpretation the interpretation for which the timed states are to be returned
* @param uom the uom for which the timed states are to be returned
*
* @return the timed states with the given interpretation
*/
@ -345,6 +334,19 @@ public class Resource extends AbstractStrolchRootElement implements StrolchRootE
return this;
}
@Override
public Resource ensureReadOnly() {
if (isReadOnly())
return this;
return getClone(true).readOnly();
}
@Override
public Resource readOnly() {
setReadOnly();
return this;
}
@Override
public void fillLocator(LocatorBuilder lb) {
lb.append(Tags.RESOURCE).append(getType()).append(getId());
@ -409,10 +411,8 @@ public class Resource extends AbstractStrolchRootElement implements StrolchRootE
/**
* Creates a {@link Locator} for resources of the given type and id
*
* @param type
* the type of resource
* @param id
* the id of the resource
* @param type the type of resource
* @param id the id of the resource
*
* @return the locator
*/
@ -423,10 +423,8 @@ public class Resource extends AbstractStrolchRootElement implements StrolchRootE
/**
* Parses the given XML and returns the resource with the given ID
*
* @param xml
* the xml to parse
* @param id
* the id of the resource to return from the parsed elements
* @param xml the xml to parse
* @param id the id of the resource to return from the parsed elements
*
* @return the resource, or null if it does not exist
*/

View File

@ -53,8 +53,7 @@ public interface StrolchRootElement extends StrolchElement, PolicyContainer, Par
* Set the type of this {@link StrolchRootElement}. Not that this method should only be called for new elements, not
* if this element has already been persisted!
*
* @param type
* the new type
* @param type the new type
*/
void setType(String type);
@ -77,11 +76,9 @@ public interface StrolchRootElement extends StrolchElement, PolicyContainer, Par
* Sets the version of this object
* </p>
*
* @param version
* the version to set
* @param version the version to set
*
* @throws IllegalArgumentException
* if the given version's locator is not equal to the current element's locator
* @throws IllegalArgumentException if the given version's locator is not equal to the current element's locator
*/
void setVersion(Version version) throws IllegalArgumentException;
@ -89,10 +86,8 @@ public interface StrolchRootElement extends StrolchElement, PolicyContainer, Par
* Set a relation to the given element by using the given param. Should the {@link StringParameter} not exist, then
* it will be created
*
* @param param
* the parameter ID on which to set the relations
* @param element
* the element for which to set the relation to
* @param param the parameter ID on which to set the relations
* @param element the element for which to set the relation to
*/
void setRelation(String param, StrolchRootElement element);
@ -100,10 +95,8 @@ public interface StrolchRootElement extends StrolchElement, PolicyContainer, Par
* Set relations to the given elements by using the given param. Should the parameter not exist, then it will be
* created
*
* @param param
* the parameter ID on which to set the relations
* @param elements
* the elements for which to set the relations to
* @param param the parameter ID on which to set the relations
* @param elements the elements for which to set the relations to
*/
void setRelations(String param, Collection<? extends StrolchRootElement> elements);
@ -111,15 +104,32 @@ public interface StrolchRootElement extends StrolchElement, PolicyContainer, Par
* Adds a relation to the given element by using the given parameter ID. Should the {@link StringListParameter} not
* exist, then it will be created
*
* @param param
* the parameter ID on which to set the relations
* @param element
* the element for which to set the relation to
* @param param the parameter ID on which to set the relations
* @param element the element for which to set the relation to
*/
void addRelation(String param, StrolchRootElement element);
/**
* Returns this element if it is not readonly, otherwise returns a clone
*
* @return this element if it is not readonly, otherwise returns a clone
*/
StrolchRootElement ensureModifiable();
/**
* Returns this element if it is readonly, otherwise returns a clone, which is read-only
*
* @return this element if it is readonly, otherwise returns a clone, which is read-only
*/
StrolchRootElement ensureReadOnly();
/**
* Makes this instance read-only, returning this for chaining
*
* @return this
*/
StrolchRootElement readOnly();
/**
* Return a clone of this {@link StrolchElement}
*
@ -138,8 +148,7 @@ public interface StrolchRootElement extends StrolchElement, PolicyContainer, Par
/**
* Visitor pattern accept method. Takes a {@link StrolchRootElementVisitor} to visit this element
*
* @param visitor
* the visitor
* @param visitor the visitor
*
* @return the result of the visitation
*/
@ -251,17 +260,12 @@ public interface StrolchRootElement extends StrolchElement, PolicyContainer, Par
* Set or add a parameter to this element from a {@link JsonObject} to the {@link ParameterBag} with the id
* {StrolchModelConstants#BAG_PARAMETERS}
*
* @param jsonObject
* the object from which to get the value
* @param paramId
* the ID of the parameter on which to set the value, and also the Json reference ID
* @param paramName
* the name of the parameter, if the parameter is to be created
* @param type
* the type of Parameter to create
* @param ignoreOnEmpty
* if true, and the json object is missing the field, then the parameter is not changed, otherwise the parameter
* is cleared if the json field is missing or null
* @param jsonObject the object from which to get the value
* @param paramId the ID of the parameter on which to set the value, and also the Json reference ID
* @param paramName the name of the parameter, if the parameter is to be created
* @param type the type of Parameter to create
* @param ignoreOnEmpty if true, and the json object is missing the field, then the parameter is not changed,
* otherwise the parameter is cleared if the json field is missing or null
*/
default void setOrAddParamFromFlatJson(JsonObject jsonObject, String paramId, String paramName,
StrolchValueType type, boolean ignoreOnEmpty) {
@ -272,23 +276,15 @@ public interface StrolchRootElement extends StrolchElement, PolicyContainer, Par
/**
* Set or add a parameter to this element from a {@link JsonObject}
*
* @param jsonObject
* the object from which to get the value
* @param bagId
* the bag ID on which to set the value
* @param bagName
* the name of the bag, if the bag is to be created
* @param bagType
* the type of the bag, if the bag is to be created
* @param paramId
* the ID of the parameter on which to set the value, and also the Json reference ID
* @param paramName
* the name of the parameter, if the parameter is to be created
* @param type
* the type of Parameter to create
* @param ignoreOnEmpty
* if true, and the json object is missing the field, then the parameter is not changed, otherwise the parameter
* is cleared if the json field is missing or null
* @param jsonObject the object from which to get the value
* @param bagId the bag ID on which to set the value
* @param bagName the name of the bag, if the bag is to be created
* @param bagType the type of the bag, if the bag is to be created
* @param paramId the ID of the parameter on which to set the value, and also the Json reference ID
* @param paramName the name of the parameter, if the parameter is to be created
* @param type the type of Parameter to create
* @param ignoreOnEmpty if true, and the json object is missing the field, then the parameter is not changed,
* otherwise the parameter is cleared if the json field is missing or null
*/
default void setOrAddParamFromFlatJson(JsonObject jsonObject, String bagId, String bagName, String bagType,
String paramId, String paramName, StrolchValueType type, boolean ignoreOnEmpty) {
@ -299,27 +295,17 @@ public interface StrolchRootElement extends StrolchElement, PolicyContainer, Par
/**
* Set or add a parameter to this element from a {@link JsonObject}
*
* @param jsonObject
* the object from which to get the value
* @param bagId
* the bag ID on which to set the value
* @param bagName
* the name of the bag, if the bag is to be created
* @param bagType
* the type of the bag, if the bag is to be created
* @param paramId
* the ID of the parameter on which to set the value, and also the Json reference ID
* @param paramName
* the name of the parameter, if the parameter is to be created
* @param interpretation
* the interpretation
* @param uom
* the uom
* @param type
* the type of Parameter to create
* @param ignoreOnEmpty
* if true, and the json object is missing the field, then the parameter is not changed, otherwise the parameter
* is cleared if the json field is missing or null
* @param jsonObject the object from which to get the value
* @param bagId the bag ID on which to set the value
* @param bagName the name of the bag, if the bag is to be created
* @param bagType the type of the bag, if the bag is to be created
* @param paramId the ID of the parameter on which to set the value, and also the Json reference ID
* @param paramName the name of the parameter, if the parameter is to be created
* @param interpretation the interpretation
* @param uom the uom
* @param type the type of Parameter to create
* @param ignoreOnEmpty if true, and the json object is missing the field, then the parameter is not changed,
* otherwise the parameter is cleared if the json field is missing or null
*/
default void setOrAddParamFromFlatJson(JsonObject jsonObject, String bagId, String bagName, String bagType,
String paramId, String paramName, String interpretation, String uom, StrolchValueType type,
@ -340,23 +326,15 @@ public interface StrolchRootElement extends StrolchElement, PolicyContainer, Par
/**
* Set or add a parameter to this element with the given value
*
* @param bagId
* the bag ID on which to set the value
* @param bagName
* the name of the bag, if the bag is to be created
* @param bagType
* the type of the bag, if the bag is to be created
* @param paramId
* the ID of the parameter on which to set the value, and also the Json reference ID
* @param paramName
* the name of the parameter, if the parameter is to be created
* @param type
* the type of Parameter to create
* @param value
* the value to set
* @param ignoreOnEmpty
* if true, and the value is null, then the parameter is not changed, otherwise the parameter is cleared if the
* value is null
* @param bagId the bag ID on which to set the value
* @param bagName the name of the bag, if the bag is to be created
* @param bagType the type of the bag, if the bag is to be created
* @param paramId the ID of the parameter on which to set the value, and also the Json reference ID
* @param paramName the name of the parameter, if the parameter is to be created
* @param type the type of Parameter to create
* @param value the value to set
* @param ignoreOnEmpty if true, and the value is null, then the parameter is not changed, otherwise the parameter
* is cleared if the value is null
*/
default void setOrAddParam(String bagId, String bagName, String bagType, String paramId, String paramName,
StrolchValueType type, Object value, boolean ignoreOnEmpty) {
@ -367,27 +345,17 @@ public interface StrolchRootElement extends StrolchElement, PolicyContainer, Par
/**
* Set or add a parameter to this element with the given value
*
* @param bagId
* the bag ID on which to set the value
* @param bagName
* the name of the bag, if the bag is to be created
* @param bagType
* the type of the bag, if the bag is to be created
* @param paramId
* the ID of the parameter on which to set the value, and also the Json reference ID
* @param paramName
* the name of the parameter, if the parameter is to be created
* @param interpretation
* the interpretation
* @param uom
* the uom
* @param type
* the type of Parameter to create
* @param value
* the value to set
* @param ignoreOnEmpty
* if true, and the value is null, then the parameter is not changed, otherwise the parameter is cleared if the
* value is null
* @param bagId the bag ID on which to set the value
* @param bagName the name of the bag, if the bag is to be created
* @param bagType the type of the bag, if the bag is to be created
* @param paramId the ID of the parameter on which to set the value, and also the Json reference ID
* @param paramName the name of the parameter, if the parameter is to be created
* @param interpretation the interpretation
* @param uom the uom
* @param type the type of Parameter to create
* @param value the value to set
* @param ignoreOnEmpty if true, and the value is null, then the parameter is not changed, otherwise the parameter
* is cleared if the value is null
*/
default void setOrAddParam(String bagId, String bagName, String bagType, String paramId, String paramName,
String interpretation, String uom, StrolchValueType type, Object value, boolean ignoreOnEmpty) {

View File

@ -15,19 +15,6 @@
*/
package li.strolch.model.activity;
import static java.util.stream.Collectors.toList;
import static li.strolch.model.StrolchModelConstants.BAG_PARAMETERS;
import static li.strolch.model.StrolchModelConstants.BAG_RELATIONS;
import static li.strolch.model.StrolchModelConstants.PolicyConstants.BAG_OBJECTIVES;
import static li.strolch.utils.collections.CollectionsHelper.singletonCollector;
import java.text.MessageFormat;
import java.util.*;
import java.util.Map.Entry;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.Stream;
import li.strolch.exception.StrolchElementNotFoundException;
import li.strolch.exception.StrolchException;
import li.strolch.exception.StrolchModelException;
@ -41,6 +28,19 @@ import li.strolch.model.visitor.StrolchElementVisitor;
import li.strolch.model.xml.StrolchXmlHelper;
import li.strolch.utils.dbc.DBC;
import java.text.MessageFormat;
import java.util.*;
import java.util.Map.Entry;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.Stream;
import static java.util.stream.Collectors.toList;
import static li.strolch.model.StrolchModelConstants.BAG_PARAMETERS;
import static li.strolch.model.StrolchModelConstants.BAG_RELATIONS;
import static li.strolch.model.StrolchModelConstants.PolicyConstants.BAG_OBJECTIVES;
import static li.strolch.utils.collections.CollectionsHelper.singletonCollector;
/**
* Parameterized object grouping a collection of {@link Activity} and {@link Action} objects defining the process to be
* scheduled
@ -68,12 +68,9 @@ public class Activity extends AbstractStrolchRootElement
/**
* Default constructor
*
* @param id
* the id
* @param name
* the name
* @param type
* the type
* @param id the id
* @param name the name
* @param type the type
*/
public Activity(String id, String name, String type, TimeOrdering timeOrdering) {
super(id, name, type);
@ -154,8 +151,7 @@ public class Activity extends AbstractStrolchRootElement
* Returns true if this {@link Activity} contains a child with the given id. The element instance type is ignored,
* i.e. {@link Action} or {@link Activity}
*
* @param id
* the id of the element to check for
* @param id the id of the element to check for
*
* @return true if this {@link Activity} contains a child with the given id. The element instance type is ignored,
* i.e. {@link Action} or {@link Activity}
@ -167,8 +163,7 @@ public class Activity extends AbstractStrolchRootElement
/**
* add an activity element to the {@code LinkedHashMap} of {@code IActivityElements}
*
* @param activityElement
* the element to add
* @param activityElement the element to add
*/
public void addElement(IActivityElement activityElement) {
assertCanAdd(activityElement);
@ -179,10 +174,8 @@ public class Activity extends AbstractStrolchRootElement
/**
* add an activity element to the {@code LinkedHashMap} of {@code IActivityElements} before the given element
*
* @param elementId
* the id of the element before which to add the other element
* @param elementToAdd
* the element to add
* @param elementId the id of the element before which to add the other element
* @param elementToAdd the element to add
*/
public void addElementBefore(String elementId, IActivityElement elementToAdd) {
IActivityElement element = getElement(elementId);
@ -192,10 +185,8 @@ public class Activity extends AbstractStrolchRootElement
/**
* add an activity element to the {@code LinkedHashMap} of {@code IActivityElements} before the given element
*
* @param element
* the element before which to add the other element
* @param elementToAdd
* the element to add
* @param element the element before which to add the other element
* @param elementToAdd the element to add
*/
public void addElementBefore(IActivityElement element, IActivityElement elementToAdd) {
assertCanAdd(elementToAdd);
@ -224,10 +215,8 @@ public class Activity extends AbstractStrolchRootElement
/**
* add an activity element to the {@code LinkedHashMap} of {@code IActivityElements} after the given element
*
* @param elementId
* the id of the element after which to add the other element
* @param elementToAdd
* the element to add
* @param elementId the id of the element after which to add the other element
* @param elementToAdd the element to add
*/
public void addElementAfter(String elementId, IActivityElement elementToAdd) {
IActivityElement element = getElement(elementId);
@ -237,10 +226,8 @@ public class Activity extends AbstractStrolchRootElement
/**
* add an activity element to the {@code LinkedHashMap} of {@code IActivityElements} after the given element
*
* @param element
* the element after which to add the other element
* @param elementToAdd
* the element to add
* @param element the element after which to add the other element
* @param elementToAdd the element to add
*/
public void addElementAfter(IActivityElement element, IActivityElement elementToAdd) {
assertCanAdd(elementToAdd);
@ -283,8 +270,7 @@ public class Activity extends AbstractStrolchRootElement
/**
* Removes the element with the given id and returns it, if it exists
*
* @param id
* the id of the element to remove
* @param id the id of the element to remove
*
* @return the removed element, or null if it does not exist
*/
@ -300,8 +286,7 @@ public class Activity extends AbstractStrolchRootElement
/**
* Returns the {@link Action} with the given ID which is a direct child of this {@link Activity}
*
* @param id
* the id of the {@link Action} to return
* @param id the id of the {@link Action} to return
*
* @return the {@link Action} with the given ID
*/
@ -312,8 +297,7 @@ public class Activity extends AbstractStrolchRootElement
/**
* Returns the {@link Activity} with the given ID which is a direct child of this {@link Activity}
*
* @param id
* the id of the {@link Activity} to return
* @param id the id of the {@link Activity} to return
*
* @return the {@link Activity} with the given ID
*/
@ -324,16 +308,14 @@ public class Activity extends AbstractStrolchRootElement
/**
* get {@code IActivityElement} by id
*
* @param id
* the id of the {@code IActivityElement}
* @param id the id of the {@code IActivityElement}
*
* @return IActivityElement
*/
public <T extends IActivityElement> T getElement(String id) {
if (this.elements == null)
throw new IllegalArgumentException("Element " + id + " does not exist on " + getLocator());
@SuppressWarnings("unchecked")
T t = (T) this.elements.get(id);
@SuppressWarnings("unchecked") T t = (T) this.elements.get(id);
if (t == null)
throw new IllegalArgumentException("Element " + id + " does not exist on " + getLocator());
return t;
@ -513,8 +495,8 @@ public class Activity extends AbstractStrolchRootElement
public <T extends IActivityElement> T findElement(Predicate<IActivityElement> predicate,
Supplier<String> msgSupplier) {
@SuppressWarnings("unchecked")
T t = (T) streamElements().filter(predicate).collect(singletonCollector(msgSupplier));
@SuppressWarnings("unchecked") T t = (T) streamElements().filter(predicate)
.collect(singletonCollector(msgSupplier));
return t;
}
@ -546,8 +528,7 @@ public class Activity extends AbstractStrolchRootElement
/**
* Returns all the actions in the entire hierarchy with the given state
*
* @param state
* the state of the action to return
* @param state the state of the action to return
*
* @return the list of actions with the given state
*/
@ -558,8 +539,7 @@ public class Activity extends AbstractStrolchRootElement
/**
* Returns all the actions in the entire hierarchy with the given type
*
* @param type
* the type of action to return
* @param type the type of action to return
*
* @return the list of actions with the given type
*/
@ -585,8 +565,7 @@ public class Activity extends AbstractStrolchRootElement
throw new StrolchElementNotFoundException(locator + " does not exist!");
}
@SuppressWarnings("unchecked")
T t = (T) element;
@SuppressWarnings("unchecked") T t = (T) element;
return t;
}
@ -766,6 +745,19 @@ public class Activity extends AbstractStrolchRootElement
return this;
}
@Override
public Activity ensureReadOnly() {
if (isReadOnly())
return this;
return getClone(true).readOnly();
}
@Override
public Activity readOnly() {
setReadOnly();
return this;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
@ -903,10 +895,8 @@ public class Activity extends AbstractStrolchRootElement
/**
* Creates a {@link Locator} for activities of the given type and id
*
* @param type
* the type of activity
* @param id
* the id of the activity
* @param type the type of activity
* @param id the id of the activity
*
* @return the locator
*/
@ -917,10 +907,8 @@ public class Activity extends AbstractStrolchRootElement
/**
* Parses the given XML and returns the activity with the given ID
*
* @param xml
* the xml to parse
* @param id
* the id of the activity to return from the parsed elements
* @param xml the xml to parse
* @param id the id of the activity to return from the parsed elements
*
* @return the activity, or null if it does not exist
*/