All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.regnosys.rosetta.translate.datamodel.SchemaSerialise Maven / Gradle / Ivy
package com.regnosys.rosetta.translate.datamodel;
import java.util.function.BiConsumer;
import com.regnosys.rosetta.translate.CustomSerialise;
import com.regnosys.rosetta.translate.datamodel.json.JsonAttribute;
import com.regnosys.rosetta.translate.datamodel.json.JsonEntity;
public class SchemaSerialise extends CustomSerialise{
public SchemaSerialise() {
serialiseMethods.put(AttributeImpl.class, (BiConsumer) this::serialiseAtt);
serialiseMethods.put(JsonAttribute.class, (BiConsumer) this::serialiseAtt);
serialiseMethods.put(Schema.class, (BiConsumer) this::serialiseSchema);
serialiseMethods.put(EntityImpl.class, (BiConsumer) this::serialiseEntity);
serialiseMethods.put(JsonEntity.class, (BiConsumer) this::serialiseEntity);
serialiseMethods.put(SimpleType.class, (BiConsumer) this::serialiseSimpleType);
}
private void serialiseSchema(Schema schema, SerialiseContext context) {
writeCollection("attributes:", schema.getAttributes(), context);
writeCollection("entities:", schema.getGlobalTypes(), context);
}
private void serialiseAtt(Attribute att, SerialiseContext context) {
print("name:", att.getName(), context);
print("cardinality:", att.getCardinality().toString(), context);
print("type:", "", context);
writeObjOrRef(att.getType(), context);
}
private void serialiseEntity(Entity ent, SerialiseContext context) {
print("namespace:", ent.getName().getNamespace(), context);
print("name:", ent.getName().getName(), context);
print("hasData:", ent.hasData(), context);
print("extends:", "", context);
writeObjOrRef(ent.getExtendedEntity(), context);
writeCollection("attributes:", ent.getAttributes(), context);
print("extending:", "[", context);
for (Entity ext : ent.getKnownExtendingEntities()) {
writeObjOrRef(ext, context);
}
print("]", context);
print("child:", ent.hasChild(), context);
}
private void serialiseSimpleType(SimpleType type, SerialiseContext context) {
print("namespace:", type.getName().getNamespace(), context);
print("name:", type.getName().getName(), context);
print("type:", type.getType().toString(), context);
print("extending:", "[", context);
for (Entity ext : type.getKnownExtendingEntities()) {
writeObjOrRef(ext, context);
}
print("]", context);
}
}