You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
with the variants factories (Weather.sunny, Weather.rainy…) expected raw types (int, double, String, etc.) for the attributes.
I’d like to have the factories support Entity and/or ValueObject types, and the generated modddel behave as an Entity itself.
Rational
My use-case is as follow:
I’m modelling data layers for a map
there are multiple, specific layer types: raster, vector, geojson…
each with different attributes and behaviors
but with some shared attributes as well
"leaf" attributes are implemented as value objects: URI, VectorTilesStyle, GeoJSON, Percentage… each with its specific validation logic
for there are multiple layer types, and each type supports only so much of the possible "leaf" attributes, there’s need to be layer types variants: MapLayer ought to be the union of MapLayer.raster, MapLayer.vector, MapLayer.geojson… with some shared attributes (int position in the layer selector, URI uri to fetch the layer tiles from a remote source…), and some specific attributes depending on the variant (e.g., MapLayer.geojson requires GeoJSON geojsonText, whereas other variants don’t)
It could look like this (not using shared props, but could dry things up nicely):
I think you're confusing MultiValueObject with union of ValueObjects. A MultiValueObject is simply a ValueObject that can have multiple member parameters (See this page of the docs).
You can create a union of any modddel kind, you just need to follow the same steps as for creating a modddel, then add multiple factory constructors. The Weather example you mentioned was for creating a union of MultiValueObjects, but you can do the same for all other modddel kinds (SingleValueObject, SimpleEntity...)
In your use-case, you want to create a union of SimpleEntity :
Hi! Thank you for creating this great library.
I wonder whether it’s possible, or could be made possible, creating a union of Entity modddels.
Currently the documentation only covers creating a union of ValueObject modddels:
with the variants factories (
Weather.sunny
,Weather.rainy
…) expected raw types (int
,double
,String
, etc.) for the attributes.I’d like to have the factories support Entity and/or ValueObject types, and the generated modddel behave as an Entity itself.
Rational
My use-case is as follow:
URI
,VectorTilesStyle
,GeoJSON
,Percentage
… each with its specific validation logicMapLayer
ought to be the union ofMapLayer.raster
,MapLayer.vector
,MapLayer.geojson
… with some shared attributes (int position
in the layer selector,URI uri
to fetch the layer tiles from a remote source…), and some specific attributes depending on the variant (e.g.,MapLayer.geojson
requiresGeoJSON geojsonText
, whereas other variants don’t)It could look like this (not using shared props, but could dry things up nicely):
The text was updated successfully, but these errors were encountered: