Valhalla breaks minimal-j framework
Bruno Eberhard
bruno.eberhard at pop.ch
Mon Dec 1 19:51:16 UTC 2025
The Keys.of(Class) method goes recursively through all the fields and
sets unique values to the fields. The values are stored in a Map in the
Keys class and identify the fields / properties:
private static final Map<Object, Property> properties = new
IdentityHashMap<>();
Note that if the Address class has its own $ constant then the values
there would be different. So Address.$.zip has a different identity than
Person.$.address.zip.
These are all just tricks to emulate the missing construct
"Person::name" or "Person::address::zip" . I would gladly do it in a
more legal way. Also it gets really messy with enums. And yes I cannot
use int with this. Also not boolean which is the bigger issue. Still
it's really nice to use the $ constant when implementing applications.
Am 01.12.2025 um 20:04 schrieb Ethan McCue:
> Can you elaborate more on how form.line($.address.city); uses the
> identity of city?
>
> How does Backend.find(Person.class, By.field($.address.zip,
> 8000)); figure out that $.address.zip refers to the corresponding field
> in Address?
>
> >
> > public class Person {
> > public static final Person $ = Keys.of(Person.class);
> >
> > @NotEmpty
> > public Integer number;
> >
> > @Size(100)
> > @Searched
> > @NotEmpty
> > public String name;
> >
> > public final Address address = new Address();
> > }
> >
> > With the $ constant there is a reference to the fields of the class.
More information about the valhalla-dev
mailing list