svn commit: r1836631 - in /ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections: MapContext.java MapStack.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1836631 - in /ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections: MapContext.java MapStack.java

Taher Alkhateeb
Author: taher
Date: Wed Jul 25 13:21:32 2018
New Revision: 1836631

URL: http://svn.apache.org/viewvc?rev=1836631&view=rev
Log:
Improved: Reafctor MapContext by removing unused code
(OFBIZ-10485)

- Remove unused functions that are only supposed to be used internally.
- Remove redundant warning and @override annotations

Thanks: Mathieu Lirzin for the patch, and careful analysis of code.
Thanks: Pradhan Sharma for reviewing the work

Modified:
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/MapContext.java
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/MapStack.java

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/MapContext.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/MapContext.java?rev=1836631&r1=1836630&r2=1836631&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/MapContext.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/MapContext.java Wed Jul 25 13:21:32 2018
@@ -46,40 +46,12 @@ public class MapContext<K, V> implements
         return new MapContext<>();
     }
 
-    public static <K, V> MapContext<K, V> createMapContext() {
-        MapContext<K, V> newValue = MapContext.getMapContext();
-        // initialize with a single entry
-        newValue.push();
-        return newValue;
-    }
-
-    public static <K, V> MapContext<K, V> createMapContext(Map<K, V> baseMap) {
-        MapContext<K, V> newValue = MapContext.getMapContext();
-        if (baseMap instanceof MapContext) {
-            newValue.stackList.addAll(((MapContext<K, V>) baseMap).stackList);
-        } else {
-            newValue.stackList.add(0, baseMap);
-        }
-        return newValue;
-    }
-
-    /** Does a shallow copy of the internal stack of the passed MapContext; enables simultaneous stacks that share common parent Maps */
-    public static <K, V> MapContext<K, V> createMapContext(MapContext<K, V> source) {
-        MapContext<K, V> newValue = MapContext.getMapContext();
-        newValue.stackList.addAll(source.stackList);
-        return newValue;
-    }
-
     protected MapContext() {
         super();
     }
 
     protected List<Map<K, V>> stackList = new LinkedList<>();
 
-    public void reset() {
-        stackList = new LinkedList<>();
-    }
-
     /** Puts a new Map on the top of the stack */
     public void push() {
         Map<K, V> newMap = new HashMap<>();
@@ -111,29 +83,6 @@ public class MapContext<K, V> implements
         return null;
     }
 
-    /**
-     * Creates a MapContext object that has the same Map objects on its stack;
-     * meant to be used to enable a
-     * situation where a parent and child context are operating simultaneously
-     * using two different MapContext objects, but sharing the Maps in common
-     */
-    public MapContext<K, V> standAloneStack() {
-        MapContext<K, V> standAlone = MapContext.createMapContext(this);
-        return standAlone;
-    }
-
-    /**
-     * Creates a MapContext object that has the same Map objects on its stack,
-     * but with a new Map pushed on the top; meant to be used to enable a
-     * situation where a parent and child context are operating simultaneously
-     * using two different MapContext objects, but sharing the Maps in common
-     */
-    public MapContext<K, V> standAloneChildStack() {
-        MapContext<K, V> standAloneChild = MapContext.createMapContext(this);
-        standAloneChild.push();
-        return standAloneChild;
-    }
-
     /* (non-Javadoc)
      * @see java.util.Map#size()
      */

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/MapStack.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/MapStack.java?rev=1836631&r1=1836630&r2=1836631&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/MapStack.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/MapStack.java Wed Jul 25 13:21:32 2018
@@ -38,7 +38,6 @@ public class MapStack<K> extends MapCont
         return newValue;
     }
 
-    @SuppressWarnings("unchecked")
     public static <K> MapStack<K> create(Map<K, Object> baseMap) {
         MapStack<K> newValue = new MapStack<>();
         if (baseMap instanceof MapStack) {
@@ -66,7 +65,6 @@ public class MapStack<K> extends MapCont
      * situation where a parent and child context are operating simultaneously
      * using two different MapStack objects, but sharing the Maps in common
      */
-    @Override
     public MapStack<K> standAloneStack() {
         MapStack<K> standAlone = MapStack.create(this);
         return standAlone;
@@ -78,7 +76,6 @@ public class MapStack<K> extends MapCont
      * situation where a parent and child context are operating simultaneously
      * using two different MapStack objects, but sharing the Maps in common
      */
-    @Override
     public MapStack<K> standAloneChildStack() {
         MapStack<K> standAloneChild = MapStack.create(this);
         standAloneChild.push();