org.jamesii.ml3.parser.nodes.AgentDeclarationNode Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ml3 Show documentation
Show all versions of ml3 Show documentation
The Modeling Language for Linked Lives, a domain specific modeling language for agent-based
computational demography.
/*
* Copyright 2017 University of Rostock
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jamesii.ml3.parser.nodes;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import org.jamesii.ml3.parser.AbstractParseTreeNode;
public class AgentDeclarationNode extends AbstractParseTreeNode {
public String agentType;
private List attributes;
public boolean isSinglton;
public AgentDeclarationNode(ModelNode modelNode, String agentType, boolean isSinglton) {
super(modelNode);
this.agentType = agentType;
this.attributes = new ArrayList<>();
this.isSinglton = isSinglton;
}
@Override
public String toString() {
// "agentDec{" + agentIdentifier + ":" + attributeDeclarations +
// "}";
String ret = String.join(", ",
attributes.stream().map(e -> e.toString()).collect(Collectors.toList()));
ret = agentType + "(" + ret + ");\n";
if (isSinglton){
return "singlton "+ret;
}else {
return ret;
}
}
/**
* @return the attributes
*/
public List getAttributes() {
return attributes;
}
/**
* @param attributes the attributes to set
*/
public void setAttributes(List attributes) {
this.attributes = attributes;
}
public void addAttribute(AttributeDeclarationNode attribute) {
attributes.add(attribute);
}
}