com.datastax.insight.core.conf.Component Maven / Gradle / Ivy
The newest version!
package com.datastax.insight.core.conf;
import com.alibaba.fastjson.annotation.JSONField;
import com.datastax.insight.core.dag.Parameter;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@JsonSerialize(include= JsonSerialize.Inclusion.NON_NULL)
public class Component implements Serializable{
private long id;
private String name;
private String type;
private String shape;
private String description;
private String icon;
private String className;
private String methodName;
private Parameter[] parameters;
private String[] inputTypes;
private String[] outputTypes;
private int orderno;
private boolean isAdvanced;
private String category;
private Boolean multiOutput;
public Component(){}
public Component(String name,String type,String shape){
setName(name);
setType(type);
setShape(shape);
}
private static final long serialVersionUID = 1L;
private List children;
private Component parent;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public List getChildren() {
return children;
}
public void setChildren(List children) {
this.children = children;
}
public void addChild(Component child){
if(this.parent==null){
addChild(this,child);
}else {
Component existed=this.parent.getByName(this.getName());
addChild(existed,child);
}
}
public void addChild(Component parent, Component child){
if(parent.children==null){
parent.setChildren(new ArrayList());
}
if(!parent.hasChild(child)){
parent.getChildren().add(child);
}
child.setParent(parent);
}
public Component getByName(String name){
for(Component c:getChildren()){
if(c.getName().equals(name)){
return c;
}
}
return null;
}
public boolean hasChild(Component child){
if(children==null) return false;
for(Component d : children){
if(d.equals(child)){
return true;
}
}
return false;
}
@Override
public boolean equals(Object obj) {
Component Component=(com.datastax.insight.core.conf.Component) obj;
return Component.getName().equals(this.getName());
}
public void setParent(Component parent) {
this.parent = parent;
}
public String getShape() {
return shape;
}
public void setShape(String shape) {
this.shape = shape;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
public String getClassName() {
return className;
}
public void setClassName(String className) {
this.className = className;
}
public String getMethodName() {
return methodName;
}
public void setMethodName(String methodName) {
this.methodName = methodName;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public Parameter[] getParameters() {
return parameters;
}
public void setParameters(Parameter[] parameters) {
this.parameters = parameters;
}
@JSONField(serialize = false)
public String[] getParamTypes(){
if(parameters!=null && parameters.length>0){
String[] paramTypes=new String[parameters.length];
for(int i=0;i