You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@juneau.apache.org by "James Bognar (JIRA)" <ji...@apache.org> on 2017/09/02 17:24:00 UTC
[jira] [Resolved] (JUNEAU-65) utility for merging two like POJOs
[ https://issues.apache.org/jira/browse/JUNEAU-65?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
James Bognar resolved JUNEAU-65.
--------------------------------
Resolution: Fixed
Assignee: James Bognar
Fix Version/s: 6.3.2
> 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
> Assignee: James Bognar
> Fix For: 6.3.2
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> 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)