agrestio / agrest

Server-side Java REST Framework for easy access to data graphs from various backends
https://agrest.io
Apache License 2.0
80 stars 34 forks source link

Improve support for Java records as Agrest entities #614

Closed andrus closed 1 year ago

andrus commented 1 year ago

Currently to turn a Java 17 "record" into an Agrest entity, we need to create old style getters. E.g.:

public record MyRecord(String p1, String p2) {

    @AgAttribute
    public String getP1() {
        return p1;
    }

    @AgAttribute
    public String getP2() {
        return p2;
    }
}

This works, but I wish it would look a bit more native like this:

public record MyRecord(@AgAttribute String p1, @AgAttribute String p2) {}

This is achievable without an explicit Java 17 dependency. This issue depends on redefining "properties" per #618