[Minor] Changed the toString()-methods to include the Locator

This commit is contained in:
Robert von Burg 2024-02-05 14:01:13 +01:00
parent 63670a77b6
commit 56098c96fa
Signed by: eitch
GPG Key ID: 75DB9C85C74331F7
5 changed files with 33 additions and 48 deletions

View File

@ -42,10 +42,8 @@ public abstract class AbstractStrolchElement implements StrolchElement {
/** /**
* Default constructor * Default constructor
* *
* @param id * @param id id of this {@link StrolchElement}
* id of this {@link StrolchElement} * @param name name of this {@link StrolchElement}
* @param name
* name of this {@link StrolchElement}
*/ */
public AbstractStrolchElement(String id, String name) { public AbstractStrolchElement(String id, String name) {
setId(id); setId(id);
@ -98,16 +96,15 @@ public abstract class AbstractStrolchElement implements StrolchElement {
* Used to build a {@link Locator} for this {@link StrolchElement}. It must be implemented by the concrete * Used to build a {@link Locator} for this {@link StrolchElement}. It must be implemented by the concrete
* implemented as parents must first add their {@link Locator} information * implemented as parents must first add their {@link Locator} information
* *
* @param locatorBuilder * @param locatorBuilder the {@link LocatorBuilder} to which the {@link StrolchElement} must add its locator
* the {@link LocatorBuilder} to which the {@link StrolchElement} must add its locator information * information
*/ */
protected abstract void fillLocator(LocatorBuilder locatorBuilder); protected abstract void fillLocator(LocatorBuilder locatorBuilder);
/** /**
* fills the {@link StrolchElement} clone with the id, name and type * fills the {@link StrolchElement} clone with the id, name and type
* *
* @param clone * @param clone the clone to fill
* the clone to fill
*/ */
protected void fillClone(AbstractStrolchElement clone) { protected void fillClone(AbstractStrolchElement clone) {
clone.id = this.id; clone.id = this.id;
@ -139,5 +136,7 @@ public abstract class AbstractStrolchElement implements StrolchElement {
public abstract int hashCode(); public abstract int hashCode();
@Override @Override
public abstract String toString(); public String toString() {
return getLocator().toString();
}
} }

View File

@ -22,7 +22,6 @@ import li.strolch.model.policy.PolicyDefs;
import li.strolch.model.visitor.StrolchElementVisitor; import li.strolch.model.visitor.StrolchElementVisitor;
import li.strolch.model.xml.StrolchXmlHelper; import li.strolch.model.xml.StrolchXmlHelper;
import li.strolch.utils.dbc.DBC; import li.strolch.utils.dbc.DBC;
import li.strolch.utils.iso8601.ISO8601;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.time.*; import java.time.*;
@ -331,9 +330,7 @@ public class Order extends AbstractStrolchRootElement implements StrolchRootElem
@Override @Override
public String toString() { public String toString() {
return getLocator() + ", Version: " + this.version.getVersion();
return "Order [id=" + this.id + ", name=" + this.name + ", type=" + this.type + ", state=" + this.state +
", date=" + ISO8601.toString(this.date) + ", version=" + this.version + "]";
} }
@Override @Override

View File

@ -191,7 +191,9 @@ public class Resource extends AbstractStrolchRootElement implements StrolchRootE
if (this.timedStateMap == null || this.timedStateMap.isEmpty()) if (this.timedStateMap == null || this.timedStateMap.isEmpty())
return Stream.empty(); return Stream.empty();
return this.timedStateMap.values().stream() return this.timedStateMap
.values()
.stream()
.filter(s -> s.getInterpretation().equals(interpretation) && s.getUom().equals(uom)); .filter(s -> s.getInterpretation().equals(interpretation) && s.getUom().equals(uom));
} }
@ -399,8 +401,7 @@ public class Resource extends AbstractStrolchRootElement implements StrolchRootE
@Override @Override
public String toString() { public String toString() {
return getLocator() + ", Version: " + this.version.getVersion();
return "Resource [id=" + this.id + ", name=" + this.name + ", type=" + this.type + ", version=" + this.version;
} }
@Override @Override

View File

@ -16,15 +16,6 @@
package li.strolch.model.activity; package li.strolch.model.activity;
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.helper.StringHelper.isNotEmpty;
import static li.strolch.utils.helper.StringHelper.trimOrEmpty;
import java.text.MessageFormat;
import java.util.*;
import li.strolch.exception.StrolchModelException; import li.strolch.exception.StrolchModelException;
import li.strolch.exception.StrolchPolicyException; import li.strolch.exception.StrolchPolicyException;
import li.strolch.model.*; import li.strolch.model.*;
@ -37,6 +28,15 @@ import li.strolch.model.timevalue.IValueChange;
import li.strolch.model.visitor.StrolchElementVisitor; import li.strolch.model.visitor.StrolchElementVisitor;
import li.strolch.utils.dbc.DBC; import li.strolch.utils.dbc.DBC;
import java.text.MessageFormat;
import java.util.*;
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.helper.StringHelper.isNotEmpty;
import static li.strolch.utils.helper.StringHelper.trimOrEmpty;
/** /**
* An {@link Action} represents a single step within an {@link Activity}, that is, one that is not further decomposed * An {@link Action} represents a single step within an {@link Activity}, that is, one that is not further decomposed
* within the {@link Activity}. A {@link Activity} applies {@link IValueChange} objects at the start and end time of the * within the {@link Activity}. A {@link Activity} applies {@link IValueChange} objects at the start and end time of the
@ -107,8 +107,7 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
} }
/** /**
* @param resourceId * @param resourceId the id of the {@link Resource} the {@link Action} acts on
* the id of the {@link Resource} the {@link Action} acts on
*/ */
public void setResourceId(String resourceId) { public void setResourceId(String resourceId) {
assertNotReadonly(); assertNotReadonly();
@ -124,8 +123,7 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
} }
/** /**
* @param state * @param state the target {@code State} of the a {@code Action}
* the target {@code State} of the a {@code Action}
*/ */
public void setState(State state) { public void setState(State state) {
assertNotReadonly(); assertNotReadonly();
@ -140,8 +138,7 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
} }
/** /**
* @param resourceType * @param resourceType the resource type
* the resource type
*/ */
public void setResourceType(String resourceType) { public void setResourceType(String resourceType) {
assertNotReadonly(); assertNotReadonly();
@ -151,8 +148,7 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
/** /**
* Sets the resource type and id from the given {@link Resource} * Sets the resource type and id from the given {@link Resource}
* *
* @param resource * @param resource the resource from which to get the type and id
* the resource from which to get the type and id
*/ */
public void setResource(Resource resource) { public void setResource(Resource resource) {
assertNotReadonly(); assertNotReadonly();
@ -182,8 +178,7 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
* *
* @return the {@link Locator} for the {@link Resource} for this action * @return the {@link Locator} for the {@link Resource} for this action
* *
* @throws IllegalStateException * @throws IllegalStateException if the resource is not defined
* if the resource is not defined
*/ */
public Locator getResourceLocator() { public Locator getResourceLocator() {
if (!isResourceDefined()) if (!isResourceDefined())
@ -201,8 +196,7 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
} }
/** /**
* @param change * @param change {@code IValueChange} to be applied to the {@code Resource}
* {@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})
*/ */
@ -383,8 +377,7 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
@Override @Override
public String toString() { public String toString() {
return "Action [id=" + this.id + ", name=" + this.name + ", type=" + this.type + ", resourceId=" return getLocator() + ", resourceId: " + this.resourceId + ", state=" + this.state;
+ this.resourceId + ", state=" + this.state + "]";
} }
@Override @Override

View File

@ -495,7 +495,8 @@ public class Activity extends AbstractStrolchRootElement
public <T extends IActivityElement> T findElement(Predicate<IActivityElement> predicate, public <T extends IActivityElement> T findElement(Predicate<IActivityElement> predicate,
Supplier<String> msgSupplier) { Supplier<String> msgSupplier) {
@SuppressWarnings("unchecked") T t = (T) streamElements().filter(predicate) @SuppressWarnings("unchecked") T t = (T) streamElements()
.filter(predicate)
.collect(singletonCollector(msgSupplier)); .collect(singletonCollector(msgSupplier));
return t; return t;
} }
@ -778,12 +779,7 @@ public class Activity extends AbstractStrolchRootElement
@Override @Override
public String toString() { public String toString() {
final StringBuilder builder = new StringBuilder(); final StringBuilder builder = new StringBuilder();
builder.append("Activity [id="); builder.append(getLocator());
builder.append(this.id);
builder.append(", name=");
builder.append(this.name);
builder.append(", type=");
builder.append(this.type);
builder.append(", state="); builder.append(", state=");
builder.append(getState()); builder.append(getState());
builder.append(", start="); builder.append(", start=");
@ -792,9 +788,8 @@ public class Activity extends AbstractStrolchRootElement
builder.append(getEnd()); builder.append(getEnd());
if (isRootElement()) { if (isRootElement()) {
builder.append(", version="); builder.append(", version=");
builder.append(this.version); builder.append(this.version.getVersion());
} }
builder.append("]");
return builder.toString(); return builder.toString();
} }