juneau-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steve Blackmon (JIRA)" <j...@apache.org>
Subject [jira] [Created] (JUNEAU-65) utility for merging two like POJOs
Date Thu, 24 Aug 2017 16:13:00 GMT
Steve Blackmon created JUNEAU-65:
------------------------------------

             Summary: utility for merging two like POJOs
                 Key: JUNEAU-65
                 URL: https://issues.apache.org/jira/browse/JUNEAU-65
             Project: Juneau
          Issue Type: New Feature
            Reporter: Steve Blackmon


I think it would be useful to have a juneau utility to merge two pojos of the same class,
with a primary and a fallback.

typesafe config has something like this: delta.withFallback(base) gives you a view where anything
not defined in delta is pulled from base

the interface would look something like:
PojoMerge<T> {
  public T merge(T delta, T base);
}

the test case would be something like:
class Bean { 
  String foo;
  String bar;
}

Bean blank = new Bean()
Bean foo = new Bean(); foo.setFoo("foo")
Bean bar = new Bean(); bar.setBar("bar")
Bean foobar = new Bean(); foobar.setFoo("foo"), foobar.setBar("bar")

assert( merge( blank, foo).equals(foo) )
assert( merge( foo, blank).equals(foo) )
assert( merge( foo, bar).equals(foobar) )
assert( merge( bar, foo).equals(foobar) )
assert( merge( blank, blank).equals(blank) )
assert( merge( foo, foo ).equals(foo) )
assert( merge( foo, foobar ).equals(foobar) )
assert( merge( foobar, bar ).equals(foobar) )




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message