[New] Added IActivityElement.isAction() and .isActivity() methods

This commit is contained in:
Robert von Burg 2018-12-04 08:58:16 +01:00
parent 102fe87b63
commit 534b555af4
3 changed files with 55 additions and 24 deletions

View File

@ -71,6 +71,16 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
this.changes = new ArrayList<>(); this.changes = new ArrayList<>();
} }
@Override
public boolean isAction() {
return true;
}
@Override
public boolean isActivity() {
return false;
}
/** /**
* @return the id of the {@link Resource} the {@link Action} acts on * @return the id of the {@link Resource} the {@link Action} acts on
*/ */
@ -88,7 +98,7 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
} }
/** /**
* @return the current <code>State</code> of the a<code>Action</code> * @return the current {@code State} of the a {@code Action}
*/ */
@Override @Override
public State getState() { public State getState() {
@ -97,7 +107,7 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
/** /**
* @param state * @param state
* the target <code>State</code> of the a<code>Action</code> * the target {@code State} of the a {@code Action}
*/ */
public void setState(State state) { public void setState(State state) {
assertNotReadonly(); assertNotReadonly();
@ -105,7 +115,7 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
} }
/** /**
* @return the type of the <code>Resource</code> this <code>Action</code> acts on * @return the type of the {@code Resource} this {@code Action} acts on
*/ */
public String getResourceType() { public String getResourceType() {
return this.resourceType; return this.resourceType;
@ -131,7 +141,7 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
/** /**
* @param change * @param change
* <code>IValueChange</code> to be applied to the <code>Resource</code> * {@code IValueChange} to be applied to the {@code Resource}
* *
* @return <tt>true</tt> (as specified by {@link Collection#add}) * @return <tt>true</tt> (as specified by {@link Collection#add})
*/ */
@ -142,7 +152,7 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
} }
/** /**
* @return the list of <code>IValueChange</code> attached to the <code>Action</code> start * @return the list of {@code IValueChange} attached to the {@code Action} start
*/ */
public List<IValueChange<? extends IValue<?>>> getChanges() { public List<IValueChange<? extends IValue<?>>> getChanges() {
if (this.changes == null) if (this.changes == null)
@ -274,7 +284,7 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
@Override @Override
public Long getStart() { public Long getStart() {
Long start = Long.MAX_VALUE; long start = Long.MAX_VALUE;
if (this.changes == null) if (this.changes == null)
return start; return start;
for (IValueChange<?> change : this.changes) { for (IValueChange<?> change : this.changes) {
@ -285,7 +295,7 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
@Override @Override
public Long getEnd() { public Long getEnd() {
Long end = 0L; long end = 0L;
if (this.changes == null) if (this.changes == null)
return end; return end;
for (IValueChange<?> change : this.changes) { for (IValueChange<?> change : this.changes) {

View File

@ -115,6 +115,16 @@ public class Activity extends AbstractStrolchRootElement
} }
} }
@Override
public boolean isAction() {
return false;
}
@Override
public boolean isActivity() {
return true;
}
/** /**
* Returns true if this {@link Activity} contains any children i.e. any of {@link Action} or {@link Activity} * Returns true if this {@link Activity} contains any children i.e. any of {@link Action} or {@link Activity}
* *
@ -139,7 +149,7 @@ public class Activity extends AbstractStrolchRootElement
} }
/** /**
* add an activity element to the <code>LinkedHashMap</code> of <code>IActivityElements</code> * add an activity element to the {@code LinkedHashMap} of {@code IActivityElements}
* *
* @param activityElement * @param activityElement
* the element to add * the element to add
@ -185,10 +195,10 @@ public class Activity extends AbstractStrolchRootElement
} }
/** /**
* get <code>IActivityElement</code> by id * get {@code IActivityElement} by id
* *
* @param id * @param id
* the id of the <code>IActivityElement</code> * the id of the {@code IActivityElement}
* *
* @return IActivityElement * @return IActivityElement
*/ */
@ -291,7 +301,7 @@ public class Activity extends AbstractStrolchRootElement
} }
/** /**
* @return get the <code>LinkedHashMap</code> of <code>IActivityElements</code> * @return get the {@code LinkedHashMap} of {@code IActivityElements}
*/ */
public Map<String, IActivityElement> getElements() { public Map<String, IActivityElement> getElements() {
if (this.elements == null) if (this.elements == null)
@ -385,7 +395,7 @@ public class Activity extends AbstractStrolchRootElement
@Override @Override
public Long getStart() { public Long getStart() {
Long start = Long.MAX_VALUE; long start = Long.MAX_VALUE;
if (this.elements == null) if (this.elements == null)
return start; return start;
Iterator<Entry<String, IActivityElement>> elementIterator = elementIterator(); Iterator<Entry<String, IActivityElement>> elementIterator = elementIterator();
@ -398,7 +408,7 @@ public class Activity extends AbstractStrolchRootElement
@Override @Override
public Long getEnd() { public Long getEnd() {
Long end = 0L; long end = 0L;
if (this.elements == null) if (this.elements == null)
return end; return end;
Iterator<Entry<String, IActivityElement>> elementIterator = elementIterator(); Iterator<Entry<String, IActivityElement>> elementIterator = elementIterator();

View File

@ -32,24 +32,35 @@ public interface IActivityElement extends StrolchElement {
/** /**
* @return the start time of this element * @return the start time of this element
*/ */
public Long getStart(); Long getStart();
/** /**
* @return the end time of this element * @return the end time of this element
*/ */
public Long getEnd(); Long getEnd();
/** /**
* @return the {@link State} of this element * @return the {@link State} of this element
*/ */
public State getState(); State getState();
/**
* @return true if this element is an {@link Action}
*/
boolean isAction();
/**
* @return true if this element is an {@link Activity}
*/
boolean isActivity();
/** /**
* Set the parent * Set the parent
* *
* @param activity * @param activity
* the activity to set as parent
*/ */
public void setParent(Activity activity); void setParent(Activity activity);
/** /**
* <p> * <p>
@ -63,7 +74,7 @@ public interface IActivityElement extends StrolchElement {
* *
* @see GroupedParameterizedElement#getParameter(String, String) * @see GroupedParameterizedElement#getParameter(String, String)
*/ */
public <U, T extends Parameter<U>> T findParameter(String bagKey, String paramKey); <U, T extends Parameter<U>> T findParameter(String bagKey, String paramKey);
/** /**
* <p> * <p>
@ -72,22 +83,22 @@ public interface IActivityElement extends StrolchElement {
* </p> * </p>
* *
* <p> * <p>
* If the parameter does not exist and <code>assertExists</code> is true, then an * If the parameter does not exist and {@code assertExists} is true, then an
* </p> * </p>
* *
* @see GroupedParameterizedElement#getParameter(String, String, boolean) * @see GroupedParameterizedElement#getParameter(String, String, boolean)
*/ */
public <U, T extends Parameter<U>> T findParameter(String bagKey, String paramKey, boolean assertExists) <U, T extends Parameter<U>> T findParameter(String bagKey, String paramKey, boolean assertExists)
throws StrolchModelException; throws StrolchModelException;
@Override @Override
public Activity getParent(); Activity getParent();
@Override @Override
public Activity getRootElement(); Activity getRootElement();
@Override @Override
public IActivityElement getClone(); IActivityElement getClone();
/** /**
* Implements the visitor pattern. Concrete implementation will call the proper method on the visitor * Implements the visitor pattern. Concrete implementation will call the proper method on the visitor
@ -97,5 +108,5 @@ public interface IActivityElement extends StrolchElement {
* *
* @return the result of the visitor being accepted * @return the result of the visitor being accepted
*/ */
public <T> T accept(StrolchElementVisitor<T> visitor); <T> T accept(StrolchElementVisitor<T> visitor);
} }