You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2012/10/05 07:23:30 UTC
svn commit: r1394363 - in /sis/trunk/sis-utility/src:
main/java/org/apache/sis/util/collection/
main/java/org/apache/sis/util/logging/
test/java/org/apache/sis/util/collection/
Author: desruisseaux
Date: Fri Oct 5 05:23:30 2012
New Revision: 1394363
URL: http://svn.apache.org/viewvc?rev=1394363&view=rev
Log:
Removed the newInstance() convenience methods. With type inference provided by JDK7, they are not needed anymore.
Modified:
sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/WeakHashSet.java
sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java
sis/trunk/sis-utility/src/main/java/org/apache/sis/util/logging/LoggerFactory.java
sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/WeakHashSetTest.java
sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/WeakValueHashMapTest.java
Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/WeakHashSet.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/WeakHashSet.java?rev=1394363&r1=1394362&r2=1394363&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/WeakHashSet.java (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/WeakHashSet.java Fri Oct 5 05:23:30 2012
@@ -56,7 +56,7 @@ import org.apache.sis.internal.util.Obje
* a convenient way to use {@code WeakHashSet} as an internal pool of immutable objects:
*
* {@preformat java
- * private final WeakHashSet<Foo> pool = WeakHashSet.newInstance(Foo.class);
+ * private final WeakHashSet<Foo> pool = new WeakHashSet<Foo>(Foo.class);
*
* public Foo create(String definition) {
* Foo created = new Foo(definition);
@@ -133,20 +133,9 @@ public class WeakHashSet<E> extends Abst
/**
* Creates a {@code WeakHashSet} for elements of the specified type.
*
- * @param <E> The type of elements in the set.
- * @param type The type of elements in the set.
- * @return An initially empty set for elements of the given type.
- */
- public static <E> WeakHashSet<E> newInstance(final Class<E> type) {
- return new WeakHashSet<E>(type);
- }
-
- /**
- * Creates a {@code WeakHashSet} for elements of the specified type.
- *
* @param type The type of the element to be included in this set.
*/
- protected WeakHashSet(final Class<E> type) {
+ public WeakHashSet(final Class<E> type) {
elementType = type;
mayContainArrays = type.isArray() || type.equals(Object.class);
lastTimeNormalCapacity = System.nanoTime();
Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java?rev=1394363&r1=1394362&r2=1394363&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java Fri Oct 5 05:23:30 2012
@@ -204,23 +204,11 @@ public class WeakValueHashMap<K,V> exten
private transient long lastTimeNormalCapacity;
/**
- * Creates a {@code WeakValueHashMap} for keys of the specified type.
- *
- * @param <K> The type of keys in the map.
- * @param <V> The type of values in the map.
- * @param keyType The type of keys in the map.
- * @return An initially empty map for keys of the given type.
- */
- public static <K,V> WeakValueHashMap<K,V> newInstance(final Class<K> keyType) {
- return new WeakValueHashMap<K,V>(keyType);
- }
-
- /**
* Creates a new {@code WeakValueHashMap}.
*
* @param keyType The type of keys in the map.
*/
- protected WeakValueHashMap(final Class<K> keyType) {
+ public WeakValueHashMap(final Class<K> keyType) {
this.keyType = keyType;
mayContainArrays = keyType.isArray() || keyType.equals(Object.class);
lastTimeNormalCapacity = System.nanoTime();
Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/logging/LoggerFactory.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/logging/LoggerFactory.java?rev=1394363&r1=1394362&r2=1394363&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/logging/LoggerFactory.java (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/logging/LoggerFactory.java Fri Oct 5 05:23:30 2012
@@ -59,7 +59,7 @@ public abstract class LoggerFactory<L> {
*/
protected LoggerFactory(final Class<L> loggerClass) {
this.loggerClass = loggerClass;
- loggers = WeakValueHashMap.newInstance(String.class);
+ loggers = new WeakValueHashMap<String,Logger>(String.class);
}
/**
Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/WeakHashSetTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/WeakHashSetTest.java?rev=1394363&r1=1394362&r2=1394363&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/WeakHashSetTest.java (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/WeakHashSetTest.java Fri Oct 5 05:23:30 2012
@@ -54,7 +54,7 @@ public final strictfp class WeakHashSetT
public void testStrongReferences() {
final Random random = new Random();
for (int pass=0; pass<NUM_RETRY; pass++) {
- final WeakHashSet<Integer> weakSet = WeakHashSet.newInstance(Integer.class);
+ final WeakHashSet<Integer> weakSet = new WeakHashSet<Integer>(Integer.class);
final HashSet<Integer> strongSet = new HashSet<Integer>();
for (int i=0; i<SAMPLE_SIZE; i++) {
final Integer value = random.nextInt(SAMPLE_SIZE);
@@ -97,7 +97,7 @@ public final strictfp class WeakHashSetT
public void testWeakReferences() throws InterruptedException {
final Random random = new Random();
for (int pass=0; pass<NUM_RETRY; pass++) {
- final WeakHashSet<Integer> weakSet = WeakHashSet.newInstance(Integer.class);
+ final WeakHashSet<Integer> weakSet = new WeakHashSet<Integer>(Integer.class);
final HashSet<Integer> strongSet = new HashSet<Integer>();
for (int i=0; i<SAMPLE_SIZE; i++) {
final Integer value = new Integer(random.nextInt(SAMPLE_SIZE)); // Really need new instances
@@ -176,7 +176,7 @@ public final strictfp class WeakHashSetT
@Test
@DependsOnMethod("testStrongReferences")
public void testWithArrayElements() {
- final WeakHashSet<int[]> weakSet = WeakHashSet.newInstance(int[].class);
+ final WeakHashSet<int[]> weakSet = new WeakHashSet<int[]>(int[].class);
final int[] array = new int[] {2, 5, 3};
assertTrue (weakSet.add(array));
assertFalse(weakSet.add(array));
Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/WeakValueHashMapTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/WeakValueHashMapTest.java?rev=1394363&r1=1394362&r2=1394363&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/WeakValueHashMapTest.java (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/WeakValueHashMapTest.java Fri Oct 5 05:23:30 2012
@@ -54,7 +54,7 @@ public final strictfp class WeakValueHas
public void testStrongReferences() {
final Random random = new Random();
for (int pass=0; pass<NUM_RETRY; pass++) {
- final WeakValueHashMap<Integer,Integer> weakMap = WeakValueHashMap.newInstance(Integer.class);
+ final WeakValueHashMap<Integer,Integer> weakMap = new WeakValueHashMap<Integer,Integer>(Integer.class);
final HashMap<Integer,Integer> strongMap = new HashMap<Integer,Integer>();
for (int i=0; i<SAMPLE_SIZE; i++) {
final Integer key = random.nextInt(SAMPLE_SIZE);
@@ -86,7 +86,7 @@ public final strictfp class WeakValueHas
public void testWeakReferences() throws InterruptedException {
final Random random = new Random();
for (int pass=0; pass<NUM_RETRY; pass++) {
- final WeakValueHashMap<Integer,Integer> weakMap = WeakValueHashMap.newInstance(Integer.class);
+ final WeakValueHashMap<Integer,Integer> weakMap = new WeakValueHashMap<Integer,Integer>(Integer.class);
final HashMap<Integer,Integer> strongMap = new HashMap<Integer,Integer>();
for (int i=0; i<SAMPLE_SIZE; i++) {
// We really want new instances here.
@@ -159,7 +159,7 @@ public final strictfp class WeakValueHas
@Test
@DependsOnMethod("testStrongReferences")
public void testWithArrayKeys() {
- final WeakValueHashMap<int[],Integer> weakMap = WeakValueHashMap.newInstance(int[].class);
+ final WeakValueHashMap<int[],Integer> weakMap = new WeakValueHashMap<int[],Integer>(int[].class);
final int[] k1 = new int[] {2, 5, 3};
final int[] k2 = new int[] {2, 5, 4};
final Integer v1 = 1;