Skip to content

krvoje/naked-pojo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Naked POJO

A toy Java-to-JavaScript DTO generator.

Use case example:

package org.nakedpojo.model.model;

import org.nakedpojo.annotations.Naked;

@Naked
public class Book {
    @Naked
    public enum Genre {
        SF,
        BELETRISTICS;
    }

    public final String title;
    public final Genre genre;
    public final Author author;
    public final Author[] authors;

    public Book(String title, Genre genre, Author author, Author[] authors) {
        this.title = title;
        this.genre = genre;
        this.author = author;
        this.authors = authors;
    }
}

This should render a JavaSript object with basic knockout.js bindings:

    var Genre = [
        "SF",
        "BELETRISTICS"
    ];

    function Book() {
        self = this;

        self.title=ko.observable(undefined);
        self.genre=ko.observable({});
        self.author=ko.observable({});
        self.authors=ko.observableArray([]);

        self.update = function(dto) {
            self.title(dto.title);
            self.genre(dto.genre);
            self.author(dto.author);
            self.authors(dto.authors);
        }

        self.dto = function() {
            return ko.toJS(self);
        }
    }

About

A toy Java-to-JavaScript DTO generator

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published