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 2014/05/07 14:49:03 UTC
svn commit: r1592997 - in /sis/branches/JDK8/core:
sis-feature/src/main/java/org/apache/sis/feature/
sis-feature/src/test/java/org/apache/sis/feature/
sis-feature/src/test/java/org/apache/sis/test/suite/
sis-utility/src/main/java/org/apache/sis/interna...
Author: desruisseaux
Date: Wed May 7 12:49:03 2014
New Revision: 1592997
URL: http://svn.apache.org/r1592997
Log:
Renamed SingletonValue as PropertySingleton (previous name was confusing, because we make a distinction between property and value),
and provide an initial draft of PropertyList.
Added:
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/PropertyList.java (with props)
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/PropertySingleton.java
- copied, changed from r1592952, sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/SingletonValue.java
sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/PropertySingletonTest.java
- copied, changed from r1592952, sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/SingletonValueTest.java
Removed:
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/SingletonValue.java
sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/SingletonValueTest.java
Modified:
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeature.java
sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultFeatureTest.java
sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedArrayList.java
Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeature.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeature.java?rev=1592997&r1=1592996&r2=1592997&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeature.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeature.java [UTF-8] Wed May 7 12:49:03 2014
@@ -60,7 +60,7 @@ public class DefaultFeature implements S
* Each value can be one of the following types (from most generic to most specific):
*
* <ul>
- * <li>A {@link MultiValues}, which is a list of {@code Attribute}.</li>
+ * <li>A {@link PropertyList}, which is a list of {@code Attribute}.</li>
* <li>An {@code Attribute} in the common case of [0…1] cardinality.</li>
* <li>An object in the common case of [0…1] cardinality when only the value
* (not the {@code Attribute} object) is requested.</li>
@@ -110,22 +110,27 @@ public class DefaultFeature implements S
throw new IllegalArgumentException(propertyNotFound(name));
}
/*
- * If the majority of cases, the feature allows at most one attribute for the given name.
+ * In the majority of cases, the feature allows at most one attribute for the given name.
* In order to save a little bit of space (because SIS applications may have a very large
* amount of features), we will not store the list in this DefaultFeature. Instead, we use
* a temporary object which will read and write the Attribute instance directly in the map.
*/
- if (at.getMaximumOccurs() <= 1) {
- return new SingletonValue(at, properties, name);
+ final int maximumOccurs = at.getMaximumOccurs();
+ if (maximumOccurs <= 1) {
+ return new PropertySingleton(at, properties, name);
}
/*
- * If the property allow more than one feature, then we need a real List implementation.
+ * If the property allows more than one feature, then we need a real List implementation.
+ * This case is less frequent, so we test it last.
*/
- final Object element = properties.get(name);
+ Object element = properties.get(name);
if (element == null) {
- // TODO: create MultiValues list here.
+ element = new PropertyList(at, maximumOccurs);
+ if (properties.put(name, element) != null) {
+ throw new ConcurrentModificationException(name);
+ }
}
- throw new UnsupportedOperationException();
+ return (PropertyList) element;
}
/**
@@ -133,13 +138,14 @@ public class DefaultFeature implements S
* This convenience method combines a call to {@link #properties(String)} followed by calls to
* {@link DefaultAttribute#getValue()} for each attribute, but may potentially be more efficient.
*
- * <p>Special cases:</p>
+ * <p>The type of the returned object depends on the {@linkplain DefaultAttributeType#getMaximumOccurs()
+ * maximum number of occurrences} of the named attribute:</p>
+ *
* <ul>
- * <li>If the {@linkplain DefaultAttributeType#getCardinality() attribute cardinality} allows
- * more than one occurrence, then this method will always return a {@link List}.
+ * <li>If the attribute is allowed to occur at most once (which is the usual case of <cite>simple
+ * features</cite>), then this method returns either the singleton value or {@code null}.</li>
+ * <li>Otherwise this method will always return a {@link List}.
* That list may be empty but never {@code null}.</li>
- * <li>Otherwise (if the attribute cardinality allows at most one occurrence),
- * this method returns either the singleton value or {@code null}.</li>
* </ul>
*
* @param name The attribute name.
@@ -160,15 +166,22 @@ public class DefaultFeature implements S
if (at == null) {
throw new IllegalArgumentException(propertyNotFound(name));
}
- if (at.getMaximumOccurs() <= 1) {
+ final int maximumOccurs = at.getMaximumOccurs();
+ if (maximumOccurs <= 1) {
return at.getDefaultValue();
}
- // TODO
+ final PropertyList list = new PropertyList(at, maximumOccurs);
+ if (properties.put(name, list) != null) {
+ throw new ConcurrentModificationException(name);
+ }
+ return list;
}
- // TODO: test MultiValues list here.
if (element instanceof DefaultAttribute<?>) {
return ((DefaultAttribute<?>) element).getValue();
}
+ if (element instanceof PropertyList) {
+ // TODO
+ }
return element;
}
@@ -202,15 +215,15 @@ public class DefaultFeature implements S
final DefaultAttribute<?> attribute = new DefaultAttribute<>(at);
setAttributeValue(attribute, value);
if (properties.put(name, attribute) != null) {
- throw new ConcurrentModificationException();
+ throw new ConcurrentModificationException(name);
}
} else {
- // TODO: check for MultiValues list here.
+ // TODO: check for PropertyList list here.
if (element instanceof DefaultAttribute<?>) {
setAttributeValue((DefaultAttribute<?>) element, value);
} else {
if (properties.put(name, value) != element) {
- throw new ConcurrentModificationException();
+ throw new ConcurrentModificationException(name);
}
}
}
@@ -239,8 +252,8 @@ public class DefaultFeature implements S
}
/**
- * Ensures that all current property values comply with the constraints defined by the feature type.
- * This method will implicitly invokes {@link DefaultAttribute#validate()} for all attribute values.
+ * Ensures that all current properties comply with the constraints defined by the feature type.
+ * This method will implicitly invokes {@link DefaultAttribute#validate()} for all attributes.
*
* @throws RuntimeException If the current attribute value violates a constraint.
* <span style="color:firebrick">This exception will be changed to {@code IllegalAttributeException}
@@ -272,7 +285,7 @@ public class DefaultFeature implements S
if (obj == this) {
return true;
}
- if (super.equals(obj)) {
+ if (obj != null && obj.getClass() == getClass()) {
final DefaultFeature that = (DefaultFeature) obj;
return type.equals(that.type) &&
properties.equals(that.properties);
@@ -294,7 +307,7 @@ public class DefaultFeature implements S
for (final Map.Entry<String,Object> entry : properties.entrySet()) {
final DefaultAttributeType<?> at;
Object element = entry.getValue();
- // TODO: check for MultiValues list here.
+ // TODO: check for PropertyList list here.
if (element instanceof DefaultAttribute<?>) {
at = ((DefaultAttribute<?>) element).getType();
element = ((DefaultAttribute<?>) element).getValue();
Added: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/PropertyList.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/PropertyList.java?rev=1592997&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/PropertyList.java (added)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/PropertyList.java [UTF-8] Wed May 7 12:49:03 2014
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.feature;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Collection;
+import org.apache.sis.util.resources.Errors;
+import org.apache.sis.internal.util.CheckedArrayList;
+
+import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
+import static org.apache.sis.util.ArgumentChecks.ensureNonNullElement;
+
+
+/**
+ * A list which may contains more than 1 attribute. This class perform some minimal validation checks
+ * before to delegate the work to the standard JDK implementation.
+ *
+ * <p><b>Limitation:</b> the validation performed by this class is not exhaustive.
+ * Furthermore this class has many holes (e.g. when using sublists or list iterator).
+ * The intend is only to catch some of the most common errors.</p>
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.5
+ * @version 0.5
+ * @module
+ */
+final class PropertyList extends ArrayList<DefaultAttribute<?>> {
+ /**
+ * For cross-version compatibility.
+ */
+ private static final long serialVersionUID = -5952391259488363686L;
+
+ /**
+ * The type of all property elements in this list.
+ */
+ private final AbstractIdentifiedType type;
+
+ /**
+ * The maximum number of occurrences allowed by this list.
+ *
+ * <div class="note"><b>Note:</b> we do not check the minimum number of occurrences because it is common
+ * to have less elements than allowed when feature construction is under progress. Furthermore, we want
+ * {@code PropertyList} list behavior to be consistent with {@link PropertySingleton} behavior regarding
+ * cardinality.</div>
+ */
+ private final int maximumOccurs;
+
+ /**
+ * Creates a new list of attributes of the given type.
+ */
+ PropertyList(final AbstractIdentifiedType type, final int maximumOccurs) {
+ this.type = type;
+ this.maximumOccurs = maximumOccurs;
+ }
+
+ /**
+ * Verify if this list can accept the given element.
+ * The caller shall ensure that the element is non-null before to invoke this method.
+ */
+ private void ensureCanAdd(final DefaultAttribute<?> element) {
+ if (size() >= maximumOccurs && maximumOccurs != Integer.MAX_VALUE) {
+ throw new IllegalStateException(Errors.format(Errors.Keys.TooManyOccurrences_2, size(), type.getName()));
+ }
+ Validator.ensureValidType(type, element);
+ }
+
+ /**
+ * Ensures that all elements of the given collection can be added to this list.
+ *
+ * @param collection the collection to check, or {@code null}.
+ * @return The a wrapper over the elements to add.
+ */
+ @SuppressWarnings({"unchecked","rawtypes"})
+ private List<DefaultAttribute<?>> ensureCanAdd(final Collection<? extends DefaultAttribute<?>> collection) {
+ final Object[] array = collection.toArray();
+ /*
+ * The first condition below is equivalent to 'if (size() + array.length > maximumOccurs)',
+ * but rearranged in a way to avoid integer overflow.
+ */
+ if (size() > maximumOccurs - array.length && maximumOccurs != Integer.MAX_VALUE) {
+ throw new IllegalStateException(Errors.format(Errors.Keys.TooManyOccurrences_2, size(), type.getName()));
+ }
+ for (int i=0; i<array.length; i++) {
+ final DefaultAttribute<?> element = (DefaultAttribute<?>) array[i];
+ ensureNonNullElement("collection", i, element);
+ Validator.ensureValidType(type, element);
+ }
+ /*
+ * Cast to List<DefaultAttribute<?>> is safe since we checked the type of all elements in the above loop.
+ */
+ return new CheckedArrayList.Mediator(array);
+ }
+
+ /**
+ * If the users request an increase in list capacity, limit that increase
+ * to the maximum number o occurrences allowed for the attribute.
+ */
+ @Override
+ public void ensureCapacity(final int minCapacity) {
+ super.ensureCapacity(Math.min(minCapacity, maximumOccurs));
+ }
+
+ /**
+ * Validates the given element before to store it in this list.
+ */
+ @Override
+ public DefaultAttribute<?> set(final int index, final DefaultAttribute<?> element) {
+ ensureNonNull("element", element);
+ Validator.ensureValidType(type, element);
+ return super.set(index, element);
+ }
+
+ /**
+ * Validates the given element before to add it in this list.
+ */
+ @Override
+ public boolean add(final DefaultAttribute<?> element) {
+ ensureNonNull("element", element);
+ ensureCanAdd(element);
+ return super.add(element);
+ }
+
+ /**
+ * Validates the given element before to add it in this list.
+ */
+ @Override
+ public void add(final int index, final DefaultAttribute<?> element) {
+ ensureNonNull("element", element);
+ ensureCanAdd(element);
+ super.add(index, element);
+ }
+
+ /**
+ * Appends all of the elements in the specified collection to the end of this list,
+ * in the order that they are returned by the specified Collection's Iterator.
+ */
+ @Override
+ public boolean addAll(final Collection<? extends DefaultAttribute<?>> collection) {
+ return super.addAll(ensureCanAdd(collection));
+ }
+
+ /**
+ * Inserts all of the elements in the specified collection into this list,
+ * starting at the specified position.
+ */
+ @Override
+ public boolean addAll(final int index, final Collection<? extends DefaultAttribute<?>> collection) {
+ return super.addAll(index, ensureCanAdd(collection));
+ }
+}
Propchange: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/PropertyList.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/PropertyList.java
------------------------------------------------------------------------------
svn:mime-type = text/plain;charset=UTF-8
Copied: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/PropertySingleton.java (from r1592952, sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/SingletonValue.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/PropertySingleton.java?p2=sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/PropertySingleton.java&p1=sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/SingletonValue.java&r1=1592952&r2=1592997&rev=1592997&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/SingletonValue.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/PropertySingleton.java [UTF-8] Wed May 7 12:49:03 2014
@@ -43,7 +43,7 @@ import static org.apache.sis.util.Argume
* @version 0.5
* @module
*/
-final class SingletonValue extends AbstractList<DefaultAttribute<?>> {
+final class PropertySingleton extends AbstractList<DefaultAttribute<?>> {
/**
* An empty list of attributes.
*/
@@ -68,7 +68,7 @@ final class SingletonValue extends Abstr
/**
* Creates a new list for the attribute associated to the given key in the given map.
*/
- SingletonValue(final AbstractIdentifiedType type, final Map<String, Object> properties, final String key) {
+ PropertySingleton(final AbstractIdentifiedType type, final Map<String, Object> properties, final String key) {
this.type = type;
this.properties = properties;
this.key = key;
@@ -126,7 +126,7 @@ final class SingletonValue extends Abstr
return (DefaultAttribute<?>) previous;
}
if (properties.remove(key) != element) {
- throw new ConcurrentModificationException();
+ throw new ConcurrentModificationException(key);
}
}
throw new IndexOutOfBoundsException(Errors.format(Errors.Keys.IndexOutOfBounds_1, index));
@@ -162,7 +162,7 @@ final class SingletonValue extends Abstr
* Removes the attribute associated to the key.
*
* This method does not checks if the removal is allowed by the
- * {@linkplain DefaultAttributeType#getCardinality() cardinality}.
+ * {@linkplain DefaultAttributeType#getMinimumOccurs() cardinality}.
* Such check can be performed by {@link DefaultFeature#validate()}.
*/
@Override
@@ -186,7 +186,7 @@ final class SingletonValue extends Abstr
*/
final boolean clear(final int c) {
if (c != modCount) {
- throw new ConcurrentModificationException();
+ throw new ConcurrentModificationException(key);
}
return properties.remove(key) != null;
}
@@ -195,7 +195,7 @@ final class SingletonValue extends Abstr
* Removes the attribute associated to the key.
*
* This method does not checks if the removal is allowed by the
- * {@linkplain DefaultAttributeType#getCardinality() cardinality}.
+ * {@linkplain DefaultAttributeType#getMinimumOccurs() cardinality}.
* Such check can be performed by {@link DefaultFeature#validate()}.
*/
@Override
@@ -222,7 +222,7 @@ final class SingletonValue extends Abstr
}
/**
- * Implementation of the iterator returned by {@link SingletonValue#iterator()}.
+ * Implementation of the iterator returned by {@link PropertySingleton#iterator()}.
*/
private final class Iter implements Iterator<DefaultAttribute<?>> {
/**
@@ -231,7 +231,7 @@ final class SingletonValue extends Abstr
private DefaultAttribute<?> element;
/**
- * Initial {@link SingletonValue#modCount} value, for checks against concurrent modifications.
+ * Initial {@link PropertySingleton#modCount} value, for checks against concurrent modifications.
*/
private final int c;
Modified: sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultFeatureTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultFeatureTest.java?rev=1592997&r1=1592996&r2=1592997&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultFeatureTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultFeatureTest.java [UTF-8] Wed May 7 12:49:03 2014
@@ -34,7 +34,7 @@ import static org.junit.Assert.*;
@DependsOn({
DefaultFeatureTypeTest.class,
DefaultAttributeTest.class,
- SingletonValueTest.class
+ PropertySingletonTest.class
})
public final strictfp class DefaultFeatureTest extends TestCase {
/**
Copied: sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/PropertySingletonTest.java (from r1592952, sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/SingletonValueTest.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/PropertySingletonTest.java?p2=sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/PropertySingletonTest.java&p1=sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/SingletonValueTest.java&r1=1592952&r2=1592997&rev=1592997&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/SingletonValueTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/PropertySingletonTest.java [UTF-8] Wed May 7 12:49:03 2014
@@ -31,7 +31,7 @@ import static org.apache.sis.test.TestUt
/**
- * Tests {@link SingletonValue}.
+ * Tests {@link PropertySingleton}.
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.5
@@ -39,7 +39,7 @@ import static org.apache.sis.test.TestUt
* @module
*/
@DependsOn(DefaultAttributeTest.class)
-public final strictfp class SingletonValueTest extends TestCase {
+public final strictfp class PropertySingletonTest extends TestCase {
/**
* The key used for storing value in this test class.
*/
@@ -48,7 +48,7 @@ public final strictfp class SingletonVal
/**
* The instance to test.
*/
- private final SingletonValue singleton;
+ private final PropertySingleton singleton;
/**
* The type of the attribute value in the {@link #singleton} list.
@@ -68,12 +68,12 @@ public final strictfp class SingletonVal
/**
* Creates a new test case.
*/
- public SingletonValueTest() {
+ public PropertySingletonTest() {
otherValues = singletonMap("other key", "other value");
properties = new HashMap<>(otherValues);
attributeType = new DefaultAttributeType<>(singletonMap(DefaultAttributeType.NAME_KEY, KEY),
Integer.class, 0, 1, null);
- singleton = new SingletonValue(attributeType, properties, KEY);
+ singleton = new PropertySingleton(attributeType, properties, KEY);
}
/**
@@ -161,7 +161,7 @@ public final strictfp class SingletonVal
/**
* Tests the attempt to add an attribute of the wrong type.
- * {@link SingletonValue} shall not allow this operation.
+ * {@link PropertySingleton} shall not allow this operation.
*/
@Test
@DependsOnMethod("testSingleton")
Modified: sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java?rev=1592997&r1=1592996&r2=1592997&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java [UTF-8] Wed May 7 12:49:03 2014
@@ -33,7 +33,7 @@ import org.junit.BeforeClass;
org.apache.sis.feature.DefaultAttributeTypeTest.class,
org.apache.sis.feature.DefaultFeatureTypeTest.class,
org.apache.sis.feature.DefaultAttributeTest.class,
- org.apache.sis.feature.SingletonValueTest.class,
+ org.apache.sis.feature.PropertySingletonTest.class,
org.apache.sis.feature.DefaultFeatureTest.class
})
public final strictfp class FeatureTestSuite extends TestSuite {
Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedArrayList.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedArrayList.java?rev=1592997&r1=1592996&r2=1592997&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedArrayList.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedArrayList.java [UTF-8] Wed May 7 12:49:03 2014
@@ -194,15 +194,17 @@ public final class CheckedArrayList<E> e
}
/**
- * A wrapper around the given array for use by {@link #addAll(Collection)} only. This wrapper violates
- * some {@link List} method contracts, so it must really be used only as a temporary object for passing
- * the array to {@code AbstractList.addAll(…)} implementation. In particular {@link #toArray()} returns
- * directly the internal array, because this is the method to be invoked by {@code addAll(…)} (this is
- * actually the only important method for this wrapper).
+ * A wrapper around the given array for use by {@link CheckedArrayList#addAll(Collection)} only, or by other
+ * implementations using the same strategy. This wrapper violates some {@link List} method contracts, so it
+ * shall really be used only as a temporary object for passing array to {@code ArrayList.addAll(…)} methods.
+ * In particular {@link #toArray()} returns directly the internal array, because this is the method to be
+ * invoked by {@code ArrayList.addAll(…)} (this is actually the only important method in this wrapper).
+ *
+ * @param <E> The type or list elements.
*/
- private static final class Mediator<E> extends AbstractList<E> {
+ public static final class Mediator<E> extends AbstractList<E> {
private final E[] array;
- Mediator(final E[] array) {this.array = array;}
+ public Mediator(final E[] array) {this.array = array;}
@Override public int size() {return array.length;}
@Override public E get(int index) {return array[index];}
@Override public E[] toArray() {return array;} // See class javadoc.