Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to map fields to a set #369

Open
ArkasDev opened this issue Apr 7, 2021 · 0 comments
Open

How to map fields to a set #369

ArkasDev opened this issue Apr 7, 2021 · 0 comments

Comments

@ArkasDev
Copy link

ArkasDev commented Apr 7, 2021

I want to use the Orika mapper to map attributes of a class into a set. Previously I implemented it with a list, however I want to get rid of the indices in the Orika factories, because the order of the elements is not important.

For the list implementation, the declarative mapping configuration in the Orika factories worked quite well. When I changed everything to Set, Orika's field mapping no longer works. Does anyone know why? Do I have a wrong declaration of the field mapping?

Set<AssetAdministrationShell> administrationShells = new HashSet<>(environment.getAssetAdministrationShells());
Set<InternalElement> shellInternalElements = mapper.mapAsSet(administrationShells, InternalElement.class);

List factory mapper

factory.classMap(AssetAdministrationShell.class, InternalElement.class)
                .mapNulls(true)
                .mapNullsInReverse(true)
                .fieldMap("derivedFrom", "attribute[0]")
                .converter(DerivedFromToAttributeConverter.class.getName()).add()
                .fieldMap("identification", "attribute[1]")
                .converter(IdentificationToAttributeConverter.class.getName()).add()

Set factory mapper that does not work yet

factory.classMap(AssetAdministrationShell.class, InternalElement.class)
                .mapNulls(true)
                .mapNullsInReverse(true)
                .fieldMap("derivedFrom", "attribute{}")
                .converter(DerivedFromToAttributeConverter.class.getName()).add()
                .fieldMap("identification", "attribute{}")
                .converter(IdentificationToAttributeConverter.class.getName()).add()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant