public interface DomainFirst { interface Factory { Data newData(); Pojo newPojo(); } interface Data extends Factory { // read-only int getId(); String getName(); } interface Pojo extends Data { // read-write Pojo setId(int id); Pojo setName(String name); } } public interface DomainSecond { interface Factory { Data newData(); Pojo newPojo(); } interface Data extends Factory { // read-only int getId(); String getName(); DomainFirst.Data getDomainFirst(); } interface Pojo extends Data { // read-write Pojo setId(int id); Pojo setName(String name); DomainFirst.Pojo setDomainFirst(); } } public static void main(String[] args) { DomainSecond.Pojo pojo2 = ...; DomainSecond.Data data2 = pojo2.setId(2).setName("pojo2").newData(); // DomainFirst.Data data = pojo2.setDomainFirst().setId(1).setName("pojo1").newData(); DomainFirst.Pojo pojo = data.newPojo(); }
Saturday, June 06, 2015
Frozen POJO Concept
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment