# Java Bindings: Use of custom "Set" class (da.set.types) vs Java Set?

**URL:** <https://forum.canton.network/t/java-bindings-use-of-custom-set-class-da-set-types-vs-java-set/4843>\
**Category:** App Development\
**Created:** [July 5, 2022, 4:15pm UTC](https://forum.canton.network/t/java-bindings-use-of-custom-set-class-da-set-types-vs-java-set/4843 "2022-07-05T16:15:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![StephenOTT](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/stephenott/32/3953_2.png) [@StephenOTT](https://forum.canton.network/u/StephenOTT)\
**Post date:** [July 5, 2022, 4:15pm UTC](https://forum.canton.network/t/java-bindings-use-of-custom-set-class-da-set-types-vs-java-set/4843/1 "2022-07-05T16:15:06Z")

</div>

What is the reason for have a types such as Set vs using the languages built in format?

---

<div class="post-metadata">

**Author:** ![Stephen](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/stephen/32/102_2.png) [@Stephen](https://forum.canton.network/u/Stephen)\
**Post date:** [July 5, 2022, 4:36pm UTC](https://forum.canton.network/t/java-bindings-use-of-custom-set-class-da-set-types-vs-java-set/4843/2 "2022-07-05T16:36:09Z")

</div>

This is done so that the relationship between Daml[-LF] and the codegen output is less “magical”. That is, type definitions in Daml are always reflected in a generated record or variant class generated in exactly the same shape as any other record or variant class.

Only LF _primitives_ may receive special treatment, and this treatment needs to be carefully considered. Without expanding too much detail, I can safely say, for example, that we would _not_ choose `java.util.Set` as the expansion if set was an LF primitive.

We considered for Scala codegen, and rejected, the idea of “detecting” or special-casing codegen choices for Daml type definitions; this decision carries over to Java codegen.

---

<div class="post-metadata">

**Author:** ![StephenOTT](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/stephenott/32/3953_2.png) [@StephenOTT](https://forum.canton.network/u/StephenOTT)\
**Post date:** [July 5, 2022, 5:25pm UTC](https://forum.canton.network/t/java-bindings-use-of-custom-set-class-da-set-types-vs-java-set/4843/3 "2022-07-05T17:25:32Z")

</div>

Thanks for the details! Very clear.

Why this question came up was when working with these special types, there is serialization factors: such as how to serialize a Daml “Set”, which really means conversion of Daml Set into java set.

Would be very helpful to provide adapter utils to convert from the special Daml types into the lang types. Example Daml Set is a Set\<Map\<K, Unit\>\> which turns into more de/serialization complexities for each application impl.
