Skip to content

Commit 7177162

Browse files
committed
new utility method for merging resolvingcontexes
1 parent f7ca044 commit 7177162

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/java/org/tensorics/core/tree/domain/Contexts.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,19 @@ public static EditableResolvingContext newResolvingContext() {
5656
return new ResolvingContextImpl();
5757
}
5858

59+
/**
60+
* Merges the contexts of the iterable in the order they appear. Being a context a map-like object the order of
61+
* insertion matters.
62+
*
63+
* @param contexts the given contexts to merge
64+
* @return the context with all the values of the given contexts
65+
*/
66+
public static EditableResolvingContext mergeContextsOrdered(Iterable<ResolvingContext> contexts) {
67+
EditableResolvingContext newCtx = newResolvingContext();
68+
contexts.forEach(newCtx::putAllNew);
69+
return newCtx;
70+
}
71+
5972
/**
6073
* creates a new rebuilding-context which allows the rebuilding of model nodes
6174
*

0 commit comments

Comments
 (0)