ai.libs.jaicore.planning.hierarchical.problems.stn.STNPlanningDomain Maven / Gradle / Ivy
package ai.libs.jaicore.planning.hierarchical.problems.stn;
import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import ai.libs.jaicore.logging.ToJSONStringUtil;
import ai.libs.jaicore.planning.classical.problems.strips.Operation;
@SuppressWarnings("serial")
public class STNPlanningDomain implements Serializable {
private final Collection operations;
private final Collection methods;
public STNPlanningDomain(final Collection operations, final Collection methods) {
super();
this.operations = operations;
this.methods = methods;
this.checkValidity();
}
public void checkValidity() {
/* does nothing by default */
}
public Collection getOperations() {
return Collections.unmodifiableCollection(this.operations);
}
public Collection getMethods() {
return Collections.unmodifiableCollection(this.methods);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((this.methods == null) ? 0 : this.methods.hashCode());
result = prime * result + ((this.operations == null) ? 0 : this.operations.hashCode());
return result;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (this.getClass() != obj.getClass()) {
return false;
}
STNPlanningDomain other = (STNPlanningDomain) obj;
if (this.methods == null) {
if (other.methods != null) {
return false;
}
} else if (!this.methods.equals(other.methods)) {
return false;
}
if (this.operations == null) {
if (other.operations != null) {
return false;
}
} else if (!this.operations.equals(other.operations)) {
return false;
}
return true;
}
@Override
public String toString() {
Map fields = new HashMap<>();
fields.put("operations", this.operations);
fields.put("methods", this.methods);
return ToJSONStringUtil.toJSONString(this.getClass().getSimpleName(), fields);
}
}