use of org.finos.legend.pure.m3.serialization.grammar.m3parser.antlr.M3Parser.MultiplicityArgumentContext in project legend-pure by finos.
the class AntlrContextToM3CoreInstance method buildMultiplicity.
private Multiplicity buildMultiplicity(MultiplicityArgumentContext ctx) {
if (ctx.identifier() == null) {
if ((ctx.fromMultiplicity() == null || "1".equals(ctx.fromMultiplicity().getText())) && "1".equals(ctx.toMultiplicity().getText())) {
if (this.pureOne == null) {
this.pureOne = (Multiplicity) this.processorSupport.package_getByUserPath(M3Paths.PureOne);
}
return this.pureOne;
} else if ((ctx.fromMultiplicity() == null || "0".equals(ctx.fromMultiplicity().getText())) && "*".equals(ctx.toMultiplicity().getText())) {
if (this.zeroMany == null) {
this.zeroMany = (Multiplicity) this.processorSupport.package_getByUserPath(M3Paths.ZeroMany);
}
return this.zeroMany;
} else if ((ctx.fromMultiplicity() == null || "0".equals(ctx.fromMultiplicity().getText())) && "0".equals(ctx.toMultiplicity().getText())) {
if (this.pureZero == null) {
this.pureZero = (Multiplicity) this.processorSupport.package_getByUserPath(M3Paths.PureZero);
}
return this.pureZero;
} else if (ctx.fromMultiplicity() != null && "0".equals(ctx.fromMultiplicity().getText()) && "1".equals(ctx.toMultiplicity().getText())) {
if (this.zeroOne == null) {
this.zeroOne = (Multiplicity) this.processorSupport.package_getByUserPath(M3Paths.ZeroOne);
}
return this.zeroOne;
} else if (ctx.fromMultiplicity() != null && "1".equals(ctx.fromMultiplicity().getText()) && "*".equals(ctx.toMultiplicity().getText())) {
if (this.oneMany == null) {
this.oneMany = (Multiplicity) this.processorSupport.package_getByUserPath(M3Paths.OneMany);
}
return this.oneMany;
} else {
String f = ctx.fromMultiplicity() == null ? "*".equals(ctx.toMultiplicity().getText()) ? "0" : ctx.toMultiplicity().getText() : ctx.fromMultiplicity().getText();
MultiplicityInstance instance = MultiplicityInstance.createPersistent(this.repository, this.sourceInformation.getPureSourceInformation(ctx.toMultiplicity().getStart()));
MultiplicityValueInstance lower = MultiplicityValueInstance.createPersistent(this.repository);
lower._value(Long.parseLong(f));
MultiplicityValueInstance upper = MultiplicityValueInstance.createPersistent(this.repository);
if (!"*".equals(ctx.toMultiplicity().getText())) {
upper._value(Long.parseLong(ctx.toMultiplicity().getText()));
}
instance._lowerBound(lower);
instance._upperBound(upper);
return instance;
}
} else {
Token src = ctx.toMultiplicity() == null ? ctx.identifier().getStart() : ctx.toMultiplicity().getStart();
MultiplicityInstance instance = MultiplicityInstance.createPersistent(this.repository, this.sourceInformation.getPureSourceInformation(src));
instance._multiplicityParameter(ctx.identifier().getText());
return instance;
}
}
Aggregations