[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
*
* @param id
* id of this {@link StrolchElement}
* @param name
* name of this {@link StrolchElement}
* @param id id of this {@link StrolchElement}
* @param name name of this {@link StrolchElement}
*/
public AbstractStrolchElement(String id, String name) {
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
* implemented as parents must first add their {@link Locator} information
*
* @param locatorBuilder
* the {@link LocatorBuilder} to which the {@link StrolchElement} must add its locator information
* @param locatorBuilder the {@link LocatorBuilder} to which the {@link StrolchElement} must add its locator
* information
*/
protected abstract void fillLocator(LocatorBuilder locatorBuilder);
/**
* fills the {@link StrolchElement} clone with the id, name and type
*
* @param clone
* the clone to fill
* @param clone the clone to fill
*/
protected void fillClone(AbstractStrolchElement clone) {
clone.id = this.id;
@ -139,5 +136,7 @@ public abstract class AbstractStrolchElement implements StrolchElement {
public abstract int hashCode();
@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.xml.StrolchXmlHelper;
import li.strolch.utils.dbc.DBC;
import li.strolch.utils.iso8601.ISO8601;
import java.text.MessageFormat;
import java.time.*;
@ -331,9 +330,7 @@ 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 getLocator() + ", Version: " + this.version.getVersion();
}
@Override

View File

@ -191,7 +191,9 @@ 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));
}
@ -399,8 +401,7 @@ public class Resource extends AbstractStrolchRootElement implements StrolchRootE
@Override
public String toString() {
return "Resource [id=" + this.id + ", name=" + this.name + ", type=" + this.type + ", version=" + this.version;
return getLocator() + ", Version: " + this.version.getVersion();
}
@Override

View File

@ -16,15 +16,6 @@
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.StrolchPolicyException;
import li.strolch.model.*;
@ -37,6 +28,15 @@ import li.strolch.model.timevalue.IValueChange;
import li.strolch.model.visitor.StrolchElementVisitor;
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
* 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
* the id of the {@link Resource} the {@link Action} acts on
* @param resourceId the id of the {@link Resource} the {@link Action} acts on
*/
public void setResourceId(String resourceId) {
assertNotReadonly();
@ -124,8 +123,7 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
}
/**
* @param state
* the target {@code State} of the a {@code Action}
* @param state the target {@code State} of the a {@code Action}
*/
public void setState(State state) {
assertNotReadonly();
@ -140,8 +138,7 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
}
/**
* @param resourceType
* the resource type
* @param resourceType the resource type
*/
public void setResourceType(String resourceType) {
assertNotReadonly();
@ -151,8 +148,7 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
/**
* Sets the resource type and id from the given {@link Resource}
*
* @param resource
* the resource from which to get the type and id
* @param resource the resource from which to get the type and id
*/
public void setResource(Resource resource) {
assertNotReadonly();
@ -182,8 +178,7 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
*
* @return the {@link Locator} for the {@link Resource} for this action
*
* @throws IllegalStateException
* if the resource is not defined
* @throws IllegalStateException if the resource is not defined
*/
public Locator getResourceLocator() {
if (!isResourceDefined())
@ -201,8 +196,7 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
}
/**
* @param change
* {@code IValueChange} to be applied to the {@code Resource}
* @param change {@code IValueChange} to be applied to the {@code Resource}
*
* @return <tt>true</tt> (as specified by {@link Collection#add})
*/
@ -383,8 +377,7 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
@Override
public String toString() {
return "Action [id=" + this.id + ", name=" + this.name + ", type=" + this.type + ", resourceId="
+ this.resourceId + ", state=" + this.state + "]";
return getLocator() + ", resourceId: " + this.resourceId + ", state=" + this.state;
}
@Override

View File

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