The IMendixObject (the variables that you actively use in microflows and Java) don't posses the information that you are looking for. These only have the information that makes up the entity, everything that the entity owns. Adding information about additional entities and associations would only consume a lot of memory.
It seems that you are looking for Meta information, the descriptive information about your domain model and entities. This does provide access to all associations regardless if the entity is parent or child of the association. See the Mendix api documentation about the IMetaObject: https://apidocs.mendix.com/7/runtime/com/mendix/systemwideinterfaces/core/meta/IMetaObject.html
This is the same information as the Model Reflection module uses, I would recommend to take a look in that module to see how the module uses that API.
Using a function like: Core.getMetaObject( "module.entity" ).getMetaAssociationsChild() you get the IMetaAssociation information about all the associations of which you are the child. Based on the AssociationType (ref/refset) and ownership you can determine the cardinality.
When using the IMeta information pay extra attention to the result combined with inheritance, the API behaves exactly as designed (last time I checked in 7.15), but there are some complexities with some of the APIs. For example getting the 'Declared' Members will only give the current entities members, but not what is inherited. There is another API for that.
I'd suggest read the API docs and play a bit with the API functions you should be able to understand what I mean in a few minutes.
You can try something like this:
for (IMendixObject mxObj : Core.getAllMendixObjects()) {
for (MendixObjectReference objRef : mxObj.getReferences(this.getContext())) {
Core.getLogger("Example").info("Entity: " + mxObj.getType() + " has the following reference: " + objRef.getName());
}
for (MendixObjectReferenceSet objRefSet : mxObj.getReferenceSets(this.getContext())) {
Core.getLogger("Example").info("Entity: " + mxObj.getType() + " has the following reference set: " + objRefSet.getName());
}
}
Sample output:
If you just want a single specific entity, you can do something like:
String fullyQualifiedName = "Module.Entity";
IMendixObject mxObj = Core.instantiate(this.getContext(), fullyQualifiedName);
Hello Steven,
If you're using the pre-compiled wrapper methods it will implicitly return a collection or a single object in java.
i.e. subordinate.getSubordinate_Manager will always bring back a single object or a null.
If you're using the IMendixObject's getValue() method it's a bit more complicated.
What is your use-case?