-
Notifications
You must be signed in to change notification settings - Fork 7
The Builder does not build Lists #13
Comments
Actually, the example you posted works as intended and does not throw any exception, tested with This implicit agreement in this library is that all collection-like properties of a class are always initialized as an empty collection, see for example here. Therefore, I do not see any problem here. Did you maybe use a custom implementation of the AssetAdministrationShellEnvironment interface and unknowingly broke this (not explicitely written) agreement? If not, can you provide a code snippet to reproduce the problem? |
Hi, Currently I am trying to build the Nameplate with litte java code. It is really hard to build up the whole meta model. Do you think it is possible at one day, that the builders e.g. for SubmodelElements like Property have more intelligence? E.g. That I just have to insert some parameters (like IRDI, Value etc.) and the builder will make the whole work to create the meta model ? Currently I have to create up to 2 "Sub" builders only to set the semanticId. So I am a lacy programmer and I am currently creating methods which will help me to reduce work. How hard is it to contribute this to that repo? I have heard from an IDTA actor that the models will be generated in the future. So will it make sense to contribute it to this repo? If this comes it would really help to use the java-model. Br. |
I'm not sure what exactly you are asking for with the request that Contribution to this repository is possible, however there are two major issues
|
Hi. I mean some functions like this:
Or when I am adding a Submodel to the AdminShellEnv it will automatic connected to an AdminShell. Br. |
Also I totally agree that such functionality is quite helpful, I don't think it is feasible to have them as part of the builder classes as this code cannot be auto-generated without additional information beyond the official meta-data model. From my perspective, the way to go is to provide such utility functions e.g. converting Submodel to Reference separate from the model which still allows pretty easy usage like shown in this pseudo-code
A small set of basic such utility functions can be found in the java-serializer project in AasUtils.java. However, this is limited to what was needed to implement serialization. You can find additional utility functions in the context of one of the projects that already use the java-model and java-serializer projects here (disclaimer: I'm one of the developers) Coming back on your initial request to add such functionality in the builder classes, I will bring this up in the aas4j proect meeting once we finished migration and are open for new features. If we find a way to auto-generate something like this I might support this feature but I guess we'll have to keep working with utility functions. |
Closing the ticket as the initial problem has been solved, and future steps towards the suggested functions will be handled in a follow-up ticket in the eclipse repository. |
Hi Team
Can you extend your builders to instantiate Lists.
Example: If you call
environmentBuilder = new DefaultAssetAdministrationShellEnvironment.Builder().submodels(new DefaultSubmodel());
You will receive a null pointer, because the underlying list is null. To get it work you have to call it so:
environmentBuilder = new DefaultAssetAdministrationShellEnvironment.Builder() .submodels(new ArrayList<>()) .submodels(new DefaultSubmodel());
This is not a good behaviour of the builder.
The builder would make more sense when it creates such lists on calling
new DefaultAssetAdministrationShellEnvironment.Builder().submodels(new DefaultSubmodel());
with a code statement like thisThank you
Br.
The text was updated successfully, but these errors were encountered: