Skip to content
Permalink
Browse files

Improved: Remove unneeded generics in ‘MapContextTest’

(OFBIZ-10933)

This is done to remove a warning in OpenJDK 8 which doesn't seem to
handle ‘@safevarargs’ annotation properly when using generics.  This
warning was not present with OpenJDK 11.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1858483 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mthl committed May 1, 2019
1 parent 2d01c1e commit ad645133b26a55c8e0311d1d1e8d1b7c05a259a5
@@ -41,19 +41,19 @@
*
* @see ControllerConfig
*/
static class PNode<K, V> {
static class PNode {
/** The properties of the node. */
public Map<K, V> props;
public Map<String, String> props;
/** The included identifier of nodes. */
private List<PNode<K, V>> includes;
private List<PNode> includes;

/**
* Constructs a node without properties.
*
* @param includes the included nodes
*/
@SafeVarargs
public PNode(PNode<K, V>... includes) {
public PNode(PNode... includes) {
this(Collections.emptyMap(), includes);
}

@@ -64,7 +64,7 @@ public PNode(PNode<K, V>... includes) {
* @param includes the included nodes
*/
@SafeVarargs
public PNode(Map<K, V> props, PNode<K, V>... includes) {
public PNode(Map<String, String> props, PNode... includes) {
this.props = props;
this.includes = Arrays.asList(includes);
}
@@ -74,8 +74,8 @@ public PNode(Map<K, V> props, PNode<K, V>... includes) {
*
* @return a map context containing the properties of the tree.
*/
public MapContext<K, V> allProps() {
MapContext<K, V> res = new MapContext<>();
public MapContext<String, String> allProps() {
MapContext<String, String> res = new MapContext<>();
includes.forEach(inc -> res.push(inc.allProps()));
res.push(props);
return res;
@@ -90,10 +90,10 @@ public void ControllerConfigLikeContext() {
UtilMisc.toMap(LinkedHashMap::new, "aa", "1", "ab", "1");
Map<String, String> propsB =
UtilMisc.toMap(LinkedHashMap::new, "ba", "3", "bb", "8", "bc", "1", "bd", "14");
PNode<String, String> pn = new PNode<>(propsA,
new PNode<>(propsB, new PNode<>(), new PNode<>()),
new PNode<>(new PNode<>()),
new PNode<>());
PNode pn = new PNode(propsA,
new PNode(propsB, new PNode(), new PNode()),
new PNode(new PNode()),
new PNode());

MapContext<String, String> mc = pn.allProps();
assertThat("insertion order of LinkedHashMap is preserved by the 'values' method",

0 comments on commit ad64513

Please sign in to comment.
You can’t perform that action at this time.