com.regnosys.rosetta.translate.datamodel.json.JsonAttribute Maven / Gradle / Ivy
package com.regnosys.rosetta.translate.datamodel.json;
import java.util.HashSet;
import java.util.Set;
import com.regnosys.rosetta.translate.datamodel.Attribute;
import com.regnosys.rosetta.translate.datamodel.Cardinality;
import com.regnosys.rosetta.translate.datamodel.Entity;
public class JsonAttribute implements Attribute {
private final String name;
private Entity type;
public JsonAttribute(String name, Entity type) {
this.name = name;
this.type = type;
}
@Override
public Cardinality getCardinality() {
if (((JsonEntity) type).getType().equals("multi")) {
return Cardinality.MULTIPLE;
}
return Cardinality.SINGLE;
}
@Override
public Entity getType() {
return type;
}
@Override
public String getName() {
return name;
}
@Override
public String toString() {
return toString(new HashSet<>());
}
@Override
public String toString(Set alreadyWritten) {
return name + getCardinality().toShortString() + "=" + type.toString(alreadyWritten);
}
}