[COLLECTIONS-441] Cleanup MultiKeyMap, remove duplicated field map.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1449519 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6dc045c4ed
commit
89d8791f05
|
@ -22,6 +22,9 @@
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<release version="4.0" date="TBA" description="Next release">
|
<release version="4.0" date="TBA" description="Next release">
|
||||||
|
<action issue="COLLECTIONS-441" dev="tn" type="fix" due-to="Thomas Vahrst">
|
||||||
|
MultiKeyMap.clone() now correctly calls super.clone().
|
||||||
|
</action>
|
||||||
<action issue="COLLECTIONS-312" dev="tn" type="fix" due-to="Peter Lawrey, Gary Gregory">
|
<action issue="COLLECTIONS-312" dev="tn" type="fix" due-to="Peter Lawrey, Gary Gregory">
|
||||||
Use of final keyword where applicable, minor performance improvements by properly
|
Use of final keyword where applicable, minor performance improvements by properly
|
||||||
initializing the capacity of newly created collections when known in advance.
|
initializing the capacity of newly created collections when known in advance.
|
||||||
|
|
|
@ -16,6 +16,9 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.commons.collections.map;
|
package org.apache.commons.collections.map;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
import java.io.ObjectOutputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -78,10 +81,6 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
/** Serialisation version */
|
/** Serialisation version */
|
||||||
private static final long serialVersionUID = -1788199231038721040L;
|
private static final long serialVersionUID = -1788199231038721040L;
|
||||||
|
|
||||||
/** The decorated map */
|
|
||||||
//keep this member around for serialization BC with older Collections releases assuming we want to do that
|
|
||||||
protected AbstractHashedMap<MultiKey<? extends K>, V> map;
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Decorates the specified map to add the MultiKeyMap API and fast query.
|
* Decorates the specified map to add the MultiKeyMap API and fast query.
|
||||||
|
@ -819,9 +818,14 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
*
|
*
|
||||||
* @return a shallow clone
|
* @return a shallow clone
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public MultiKeyMap<K, V> clone() {
|
public MultiKeyMap<K, V> clone() {
|
||||||
return new MultiKeyMap<K, V>(decorated().clone());
|
try {
|
||||||
|
return (MultiKeyMap<K, V>) super.clone();
|
||||||
|
} catch (CloneNotSupportedException e) {
|
||||||
|
throw new InternalError();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -867,6 +871,32 @@ public class MultiKeyMap<K, V> extends AbstractMapDecorator<MultiKey<? extends K
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected AbstractHashedMap<MultiKey<? extends K>, V> decorated() {
|
protected AbstractHashedMap<MultiKey<? extends K>, V> decorated() {
|
||||||
return map;
|
return (AbstractHashedMap<MultiKey<? extends K>, V>) super.decorated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* Write the map out using a custom routine.
|
||||||
|
*
|
||||||
|
* @param out the output stream
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
private void writeObject(final ObjectOutputStream out) throws IOException {
|
||||||
|
out.defaultWriteObject();
|
||||||
|
out.writeObject(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read the map in using a custom routine.
|
||||||
|
*
|
||||||
|
* @param in the input stream
|
||||||
|
* @throws IOException
|
||||||
|
* @throws ClassNotFoundException
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||||
|
in.defaultReadObject();
|
||||||
|
map = (Map<MultiKey<? extends K>, V>) in.readObject();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -441,18 +441,18 @@ public class MultiKeyMapTest<K, V> extends AbstractIterableMapTest<MultiKey<? ex
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
@Override
|
@Override
|
||||||
public String getCompatibilityVersion() {
|
public String getCompatibilityVersion() {
|
||||||
return "3.1";
|
return "4.0";
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void testCreate() throws Exception {
|
// public void testCreate() throws Exception {
|
||||||
// resetEmpty();
|
// resetEmpty();
|
||||||
// writeExternalFormToDisk(
|
// writeExternalFormToDisk(
|
||||||
// (java.io.Serializable) map,
|
// (java.io.Serializable) map,
|
||||||
// "D:/dev/collections/data/test/MultiKeyMap.emptyCollection.version3.1.obj");
|
// "src/test/resources/data/test/MultiKeyMap.emptyCollection.version4.0.obj");
|
||||||
// resetFull();
|
// resetFull();
|
||||||
// writeExternalFormToDisk(
|
// writeExternalFormToDisk(
|
||||||
// (java.io.Serializable) map,
|
// (java.io.Serializable) map,
|
||||||
// "D:/dev/collections/data/test/MultiKeyMap.fullCollection.version3.1.obj");
|
// "src/test/resources/data/test/MultiKeyMap.fullCollection.version4.0.obj");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue