Skip to content

Commit

Permalink
Improved: Remove unneeded generics in ‘MapContextTest’
Browse files Browse the repository at this point in the history
(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 ad64513
Showing 1 changed file with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ public class MapContextTest {
*
* @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);
}

Expand All @@ -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);
}
Expand All @@ -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;
Expand All @@ -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",
Expand Down

0 comments on commit ad64513

Please sign in to comment.