in code-generation/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/references/TypeReference.java [38:53]
default Optional<TypeReference> getDiscriminatorType(VariableLiteral variableLiteral) {
// If we found something but there's a "rest" left, we got to use the type we
// found in this level, get that type's definition and continue from there.
if (variableLiteral.getChild().isEmpty()) {
return Optional.of(this);
}
// If we're accessing a child, then the root must be a complex type.
if (!(this instanceof ComplexTypeReference)) {
return Optional.empty();
}
ComplexTypeReference complexTypeReference = (ComplexTypeReference) this;
final ComplexTypeDefinition complexTypeDefinition = complexTypeReference.getTypeDefinition();
VariableLiteral childVariableLiteral = variableLiteral.getChild().get();
return complexTypeDefinition.getTypeReferenceForProperty(childVariableLiteral.getName())
.flatMap(innerTypeReference -> innerTypeReference.getDiscriminatorType(childVariableLiteral));
}