sdlang-dev / SDL

SDL (Simple Declarative Language) for java
11 stars 1 forks source link

sdl-annotations #9

Open SingingBush opened 4 years ago

SingingBush commented 4 years ago

Allow a pojo to convert to SDL using annotations:

    @Tag("person")
    public static class Person {

        @Value
        private String username;

        @Attribute
        private String email;

        @Attribute("dob")
        private LocalDate dob;

        public Person(String username, String email, LocalDate dob) {
            this.username = username;
            this.email = email;
            this.dob = dob;
        }

        public String getEmail() {
            return email;
        }

        public LocalDate getDob() {
            return dob;
        }
    }

and then write to sdl with:

final Person p = new Person("testing", "dave@website.test", LocalDate.of(2000, 1, 28));

SDL.toSDL(p, System.out); // similar to using GSON: 'new GSON().toJson(obj, writer);'
SingingBush commented 8 months ago

this is now in develop branch so will be a part of future releases

SingingBush commented 8 months ago

needs some further changes which are being worked on now in the comment-style branch