/** * Merge two strings. If the child is null, the parent will be returned. Else the child will be returned. * @param child the child string to merge * @param parent the parent string to merge * @return the merged string */ @SuppressWarnings("RedundantCast") protected String merge(String child, String parent) { return (String) merge((Object) child, (Object) parent); }
/** * Merge two lists. All child element will be in the merged list. All parent elements not in the child list will be * added. Mergeable elements in both lists will be merged according to that element merge rules. New items are added * to the end of the list * @param child the child list to merge * @param parent the parent list to merge * @return the merged list */ protected <T extends Model> LinkedList<T> merge(LinkedList<T> child, LinkedList<T> parent) { return merge(child, parent, true); }
/** * Merge two strings. If the child is null, the parent will be returned. Else the child will be returned. * @param child the child string to merge * @param parent the parent string to merge * @return the merged string */ @SuppressWarnings("RedundantCast") protected String merge(String child, String parent) { return (String) merge((Object) child, (Object) parent); }
/** * Merge two lists. All child element will be in the merged list. All parent elements not in the child list will be * added. Mergeable elements in both lists will be merged according to that element merge rules. New items are added * to the end of the list * @param child the child list to merge * @param parent the parent list to merge * @return the merged list */ protected LinkedList merge(LinkedList child, LinkedList parent) { return merge(child, parent, true); }
/** * Merge two strings. If the child is null, the parent will be returned. Else the child will be returned. * @param child the child string to merge * @param parent the parent string to merge * @return the merged string */ protected String merge(String child, String parent) { return (String) merge((Object) child, (Object) parent); }
/** * Merge two lists. All child element will be in the merged list. All parent elements not in the child list will be * added. Mergeable elements in both lists will be merged according to that element merge rules. New items are added * to the end of the list * @param child the child list to merge * @param parent the parent list to merge * @return the merged list */ protected <T extends Model> LinkedList<T> merge(LinkedList<T> child, LinkedList<T> parent) { return merge(child, parent, true); }
public void testStringMergeNullChild() { AbstractModel obj = new PersistenceContextModel(); String child = null; String parent = "parent"; assertEquals("parent", obj.merge(child, parent)); }
public void testListMergeNulls() { AbstractModel obj = new PersistenceContextModel(); LinkedList<Model> child = null; LinkedList<Model> parent = null; LinkedList<Model> result = obj.merge(child, parent); assertEquals(null, result); }
public void testStringMerge() { AbstractModel obj = new PersistenceContextModel(); String child = "child"; String parent = "parent"; assertEquals("child", obj.merge(child, parent)); }
public void testStringMergeNullParent() { AbstractModel obj = new PersistenceContextModel(); String child = "child"; String parent = null; assertEquals("child", obj.merge(child, parent)); }
public void testStringMergeNulls() { AbstractModel obj = new PersistenceContextModel(); String child = null; String parent = null; assertEquals(null, obj.merge(child, parent)); }
public void testListMergeNullParent() { AbstractModel obj = new PersistenceContextModel(); LinkedList<SecuredModel> child = new LinkedList<>(); child.add(new SecuredModel("1")); LinkedList<SecuredModel> parent = null; LinkedList<SecuredModel> result = obj.merge(child, parent); assertEquals(1, result.size()); assertEquals("1", result.get(0).getAttributes()); }
public void testListMergeNullChild() { LinkedList<SecuredModel> child = null; LinkedList<SecuredModel> parent = new LinkedList<>(); parent.add(new SecuredModel("2")); AbstractModel obj = new PersistenceContextModel(); LinkedList<SecuredModel> result = obj.merge(child, parent); assertEquals(1, result.size()); assertEquals("2", result.get(0).getAttributes()); assertNotSame(parent.get(0), result.get(0)); }
public void testListMergeAddAtEndFalse() { LinkedList<SecuredModel> child = new LinkedList<>(); child.add(new SecuredModel("1")); child.add(new SecuredModel("3")); LinkedList<SecuredModel> parent = new LinkedList<>(); parent.add(new SecuredModel("2")); SecuredModel match = new SecuredModel("3"); match.setMatch("foo"); parent.add(match); AbstractModel obj = new PersistenceContextModel(); LinkedList<SecuredModel> result = obj.merge(child, parent, false); assertEquals(3, result.size()); assertEquals("2", result.get(0).getAttributes()); assertEquals("1", result.get(1).getAttributes()); assertEquals("3", result.get(2).getAttributes()); assertNotSame(parent.get(0), result.get(1)); assertEquals("foo", result.get(2).getMatch()); }
public void testListMergeAddAtEndTrue() { LinkedList<SecuredModel> child = new LinkedList<>(); child.add(new SecuredModel("1")); child.add(new SecuredModel("3")); LinkedList<SecuredModel> parent = new LinkedList<>(); parent.add(new SecuredModel("2")); SecuredModel match = new SecuredModel("3"); match.setMatch("foo"); parent.add(match); AbstractModel obj = new PersistenceContextModel(); LinkedList<SecuredModel> result = obj.merge(child, parent, true); assertEquals(3, result.size()); assertEquals("1", result.get(0).getAttributes()); assertEquals("3", result.get(1).getAttributes()); assertEquals("2", result.get(2).getAttributes()); assertNotSame(parent.get(0), result.get(1)); assertEquals("foo", result.get(1).getMatch()); }