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 git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1836631 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -46,40 +46,12 @@ public class MapContext<K, V> implements Map<K, V>, LocalizedMap<V> {
|
||||
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 Map<K, V>, LocalizedMap<V> {
|
||||
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()
|
||||
*/
|
||||
|
||||
@@ -38,7 +38,6 @@ public class MapStack<K> extends MapContext<K, Object> {
|
||||
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 MapContext<K, Object> {
|
||||
* 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 MapContext<K, Object> {
|
||||
* 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();
|
||||
|
||||
Reference in New Issue
Block a user