package models.dataConstraintModel; import java.util.ArrayList; import java.util.List; import models.algebra.Expression; import models.algebra.Type; import models.algebra.Symbol; import models.algebra.Term; public class ResourcePath extends Symbol { protected ResourceHierarchy resourceHierarchy = null; protected List<Expression> pathParams = null; protected Expression initialValue; protected String initText; public ResourcePath(String path, ResourceHierarchy resourceHierarchy) { super(path, 2); this.resourceHierarchy = resourceHierarchy; this.pathParams = new ArrayList<>(); } public ResourcePath(String path, ResourceHierarchy resourceHierarchy, List<Expression> pathParams) { super(path, 2); this.resourceHierarchy = resourceHierarchy; this.pathParams = pathParams; } // public ResourcePath getParent() { // return resourceHierarchy.getParent(); // } // // public void setParent(ResourcePath parent) { // this.resourceHierarchy.setParent(parent); // } public String getResourceName() { return resourceHierarchy.getResourceName(); } public int getNumberOfParameters() { return resourceHierarchy.getNumParameters(); } public models.algebra.Type getResourceStateType() { return resourceHierarchy.getResourceStateType(); } public void setResourceStateType(models.algebra.Type resourceStateType) { this.resourceHierarchy.setResourceStateType(resourceStateType); if (initialValue != null) { if (initialValue instanceof Term) { ((Term) initialValue).setType(resourceStateType); } } } public List<Expression> getPathParams() { return pathParams; } public void setPathParams(List<Expression> pathParams) { this.pathParams = pathParams; } public void addPathParam(Expression pathParam) { pathParams.add(pathParam); } public Expression getInitialValue() { return initialValue; } public void setInitialValue(Expression initialValue) { this.initialValue = initialValue; } public String getInitText() { return initText; } public void setInitText(String initText) { this.initText = initText; } public boolean equals(Object another) { if (!(another instanceof ResourcePath)) return false; return resourceHierarchy.getResourceName().equals(((ResourcePath) another).resourceHierarchy.getResourceName()); } public int hashCode() { return resourceHierarchy.getResourceName().hashCode(); } }