Primitive Arrays in DataObjects

What’s the best way to store primitive arrays in DataObjects? I’m asking specifically about booleans, integers, and doubles. Order matters, btw.

Thanks!

Pre-3.2, I’d suggest using a StringFieldMetadata and JSON serializing the array/list/set or turning it into a CSV. Obviously you don’t get a lot of meaningful filter support from the various String filters regarding does my array contain any or all of 1, 42, and 500 for example.

Starting in LEAF 3.2, you can define custom FieldMetadata, so you could somewhat easily make a SetOfIntegersFieldMetadata or a ListOfBooleansFieldMetadata. (I’d suggest collections over arrays as the value class as collections are generally easier to work with, and you can easily make them immutable.) And with custom FieldMetadata you can create custom filters that can do meaningful searches even for collection-like fields. I will mention the only limitation is if using SQL, custom FM will have to ultimately be stored in a String-like column, as our hooks for custom FM in SQL are based around the columns we use for our built-in fields. That said for Mongo, you could easily store a ListOfIntegersFieldMetadata literally as a Mongo array of numbers, and you could make a corresponding custom filter for contains or equals operations. And of course Mongo’s array does maintain order.

See more RE: custom FieldMetadata https://docs.leidos-leaf.com/stable/3.2/4.0-leaf-components/4.1-leaf-framework-services/advanced-java-development/metadata/custom-field-metadata/

Excellent! Thanks!