package org.ntlab.rdlcanvas.models;
import models.terms.Resource;
public class RDLSpecResource extends Resource implements Typable, RDLSpecEvaluatableTerm {
private StructuralType structuralType;
private ValueType valueType;
public RDLSpecResource(String name, int order, StructuralType structuralType, ValueType valueType) {
super(name, order);
if (!(structuralType == StructuralType.structure || structuralType == StructuralType.id || structuralType == StructuralType.primitive || structuralType == StructuralType.map || structuralType == StructuralType.value)) {
throw new IllegalArgumentException(structuralType + " is not expected structural type.");
}
if (structuralType == StructuralType.id || structuralType == StructuralType.primitive || structuralType == StructuralType.value) {
if (!(valueType.equals(RDLSpecLang.typeInt) || valueType.equals(RDLSpecLang.typeDouble) || valueType.equals(RDLSpecLang.typeString) || valueType.equals(RDLSpecLang.typeBoolean))) {
throw new IllegalArgumentException(structuralType + " is not expected valuable Type.");
}
} else {
if (valueType != null) {
throw new IllegalArgumentException("It does not have a type");
}
}
this.structuralType = structuralType;
this.valueType = valueType;
}
public RDLSpecResource(String name, int order, ValueType valueType) {
super(name, order);
structuralType = StructuralType.primitive;
this.valueType = valueType;
}
@Override
public StructuralType getStructuralType() {
return structuralType;
}
@Override
public ValueType getValueType() {
return valueType;
}
@Override
public boolean isDependencyTerm() {
return false;
}
}