Tabnine Logo
CheckedArrayList.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
org.apache.sis.internal.util.CheckedArrayList
constructor

Best Java code snippets using org.apache.sis.internal.util.CheckedArrayList.<init> (Showing top 20 results out of 315)

origin: org.apache.sis.core/sis-feature

/**
 * Creates a new association of the given role.
 *
 * @param role Information about the association.
 */
public MultiValuedAssociation(final DefaultAssociationRole role) {
  super(role);
  values = new CheckedArrayList<>(AbstractFeature.class);
}
origin: org.apache.sis.core/sis-metadata

/**
 * Returns all identifiers associated to this object, or an empty collection if none.
 * Those identifiers are marshalled in XML as {@code id} or {@code uuid} attributes.
 */
@Override
@SuppressWarnings("ReturnOfCollectionOrArrayField")
public Collection<Identifier> getIdentifiers() {
  if (identifiers == null) {
    identifiers = new CheckedArrayList<>(Identifier.class);
  }
  return identifiers;
}
origin: apache/sis

/**
 * Returns all identifiers associated to this object, or an empty collection if none.
 * Those identifiers are marshalled in XML as {@code id} or {@code uuid} attributes.
 */
@Override
@SuppressWarnings("ReturnOfCollectionOrArrayField")
public Collection<Identifier> getIdentifiers() {
  if (identifiers == null) {
    identifiers = new CheckedArrayList<>(Identifier.class);
  }
  return identifiers;
}
origin: apache/sis

/**
 * Creates a new association of the given role.
 *
 * @param role Information about the association.
 */
public MultiValuedAssociation(final DefaultAssociationRole role) {
  super(role);
  values = new CheckedArrayList<>(AbstractFeature.class);
}
origin: apache/sis

/**
 * Creates a modifiable list for elements of the given type. This method is defined mostly
 * for consistency with {@link #createSet(Class, Collection)}.
 *
 * @param  source  the collection to be copied in the new list. This method uses this information
 *                 only for computing initial capacity; it does not perform the actual copy.
 */
private static <E> List<E> createList(final Class<E> elementType, final Collection<?> source) {
  return new CheckedArrayList<>(elementType, source.size());
}
origin: apache/sis

/**
 * Creates a collection which will initially contain only the given value.
 * At the difference of {@link Collections#singletonList(Object)}, this method returns a modifiable list.
 */
@SuppressWarnings("unchecked")
private static <V> Collection<V> singletonList(final Class<V> valueClass, final int minimumOccurs, final Object value) {
  final CheckedArrayList<V> values = new CheckedArrayList<>(valueClass, Math.max(minimumOccurs, 4));
  values.add((V) value);                              // Type will be checked by CheckedArrayList.
  return values;
}
origin: org.apache.sis.core/sis-feature

/**
 * Creates a collection which will initially contain only the given value.
 * At the difference of {@link Collections#singletonList(Object)}, this method returns a modifiable list.
 */
@SuppressWarnings("unchecked")
private static <V> Collection<V> singletonList(final Class<V> valueClass, final int minimumOccurs, final Object value) {
  final CheckedArrayList<V> values = new CheckedArrayList<>(valueClass, Math.max(minimumOccurs, 4));
  values.add((V) value);                              // Type will be checked by CheckedArrayList.
  return values;
}
origin: org.apache.sis.core/sis-feature

/**
 * Creates a new association of the given role initialized to the given values.
 *
 * @param role   Information about the association.
 * @param values The initial values, or {@code null} for initializing to an empty list.
 */
MultiValuedAssociation(final DefaultAssociationRole role, final Object values) {
  super(role);
  if (values == null) {
    this.values = new CheckedArrayList<>(AbstractFeature.class);
  } else {
    this.values = CheckedArrayList.castOrCopy((CheckedArrayList<?>) values, AbstractFeature.class);
  }
}
origin: apache/sis

/**
 * Creates a new association of the given role initialized to the given values.
 *
 * @param role   Information about the association.
 * @param values The initial values, or {@code null} for initializing to an empty list.
 */
MultiValuedAssociation(final DefaultAssociationRole role, final Object values) {
  super(role);
  if (values == null) {
    this.values = new CheckedArrayList<>(AbstractFeature.class);
  } else {
    this.values = CheckedArrayList.castOrCopy((CheckedArrayList<?>) values, AbstractFeature.class);
  }
}
origin: org.apache.sis.core/sis-metadata

/**
 * Creates a list with the content of the {@code source} collection,
 * or returns {@code null} if the source is {@code null} or empty.
 * This is a convenience method for copying fields in subclass copy constructors.
 *
 * @param  <E>          the type represented by the {@code Class} argument.
 * @param  source       the source collection, or {@code null}.
 * @param  elementType  the base type of elements to put in the list.
 * @return a list containing the {@code source} elements,
 *         or {@code null} if the source was null or empty.
 */
protected final <E> List<E> copyList(final Collection<? extends E> source, final Class<E> elementType) {
  if (isNullOrEmpty(source)) {
    return null;
  }
  final List<E> target = new CheckedArrayList<>(elementType, source.size());
  target.addAll(source);
  return target;
}
origin: apache/sis

/**
 * Creates a new attribute of the given type initialized to the
 * {@linkplain DefaultAttributeType#getDefaultValue() default value}.
 *
 * @param  type  information about the attribute (base Java class, domain of values, <i>etc.</i>).
 */
public MultiValuedAttribute(final DefaultAttributeType<V> type) {
  super(type);
  values = new CheckedArrayList<>(type.getValueClass());
  final V value = type.getDefaultValue();
  if (value != null) {
    values.add(value);
  }
}
origin: apache/sis

/**
 * Creates a new attribute of the given type initialized to the given values.
 * Note that a {@code null} value may not be the same as the default value.
 *
 * @param  type    information about the attribute (base Java class, domain of values, <i>etc.</i>).
 * @param  values  the initial values, or {@code null} for initializing to an empty list.
 */
@SuppressWarnings("unchecked")
MultiValuedAttribute(final DefaultAttributeType<V> type, final Object values) {
  super(type);
  final Class<V> valueClass = type.getValueClass();
  if (values == null) {
    this.values = new CheckedArrayList<>(valueClass);
  } else {
    final Class<?> actual = ((CheckedContainer<?>) values).getElementType();
    if (actual == valueClass) {
      this.values = (CheckedArrayList<V>) values;
    } else {
      throw new ClassCastException(Errors.format(Errors.Keys.IllegalArgumentClass_3, "values", valueClass, actual));
    }
  }
}
origin: org.apache.sis.core/sis-feature

/**
 * Creates a new attribute of the given type initialized to the
 * {@linkplain DefaultAttributeType#getDefaultValue() default value}.
 *
 * @param  type  information about the attribute (base Java class, domain of values, <i>etc.</i>).
 */
public MultiValuedAttribute(final DefaultAttributeType<V> type) {
  super(type);
  values = new CheckedArrayList<>(type.getValueClass());
  final V value = type.getDefaultValue();
  if (value != null) {
    values.add(value);
  }
}
origin: org.apache.sis.core/sis-feature

/**
 * Creates a new attribute of the given type initialized to the given values.
 * Note that a {@code null} value may not be the same as the default value.
 *
 * @param  type    information about the attribute (base Java class, domain of values, <i>etc.</i>).
 * @param  values  the initial values, or {@code null} for initializing to an empty list.
 */
@SuppressWarnings("unchecked")
MultiValuedAttribute(final DefaultAttributeType<V> type, final Object values) {
  super(type);
  final Class<V> valueClass = type.getValueClass();
  if (values == null) {
    this.values = new CheckedArrayList<>(valueClass);
  } else {
    final Class<?> actual = ((CheckedContainer<?>) values).getElementType();
    if (actual == valueClass) {
      this.values = (CheckedArrayList<V>) values;
    } else {
      throw new ClassCastException(Errors.format(Errors.Keys.IllegalArgumentClass_3, "values", valueClass, actual));
    }
  }
}
origin: apache/sis

/**
 * Ensures that we can not element of the wrong type.
 */
@Test
public void testAddWrongType() {
  final CheckedArrayList<String> list = new CheckedArrayList<>(String.class);
  final String message = testAddWrongType(list);
  assertTrue("element", message.contains("element"));
  assertTrue("Integer", message.contains("Integer"));
  assertTrue("String",  message.contains("String"));
}
origin: apache/sis

/**
 * Ensures that we can not add null elements.
 */
@Test
public void testAddAllNull() {
  final CheckedArrayList<String> list = new CheckedArrayList<>(String.class);
  final Collection<String> toAdd = Arrays.asList("One", null, "Three");
  try {
    list.addAll(toAdd);
  } catch (NullArgumentException e) {
    final String message = e.getMessage();
    assertTrue(message.contains("CheckedArrayList<String>"));
  }
}
origin: apache/sis

/**
 * Ensures that we can not add null elements.
 */
@Test
public void testAddNull() {
  final CheckedArrayList<String> list = new CheckedArrayList<>(String.class);
  try {
    list.add(null);
  } catch (NullArgumentException e) {
    final String message = e.getMessage();
    assertTrue(message.contains("CheckedArrayList<String>"));
  }
}
origin: apache/sis

/**
 * Tests {@link CheckedArrayList#addAll(Collection)}.
 */
@Test
public void testAddAll() {
  final CheckedArrayList<String> list = new CheckedArrayList<>(String.class);
  assertTrue(list.add("One"));
  assertTrue(list.addAll(Arrays.asList("Two", "Three")));
  assertEquals(Arrays.asList("One", "Two", "Three"), list);
}
origin: apache/sis

/**
 * Tests {@link CheckedArrayList#add(Object)}.
 */
@Test
public void testAdd() {
  final CheckedArrayList<String> list = new CheckedArrayList<>(String.class);
  assertTrue(list.add("One"));
  assertTrue(list.add("Two"));
  assertTrue(list.add("Three"));
  assertEquals(Arrays.asList("One", "Two", "Three"), list);
}
origin: apache/sis

/**
 * Ensures that we can not element of the wrong type in a sublist.
 */
@Test
@DependsOnMethod("testAddWrongType")
public void testAddWrongTypeToSublist() {
  final CheckedArrayList<String> list = new CheckedArrayList<>(String.class);
  assertTrue(list.add("One"));
  assertTrue(list.add("Two"));
  assertTrue(list.add("Three"));
  testAddWrongType(list.subList(1, 3));
  // Exception message is JDK-dependent, so we can not test it.
}
org.apache.sis.internal.utilCheckedArrayList<init>

Javadoc

Constructs a list of the specified type.

Popular methods of CheckedArrayList

  • addAll
    Appends all of the elements in the specified collection to the end of this list, in the order that t
  • add
    Appends the specified element to the end of this list.
  • castOrCopy
    Returns the given collection as a CheckedArrayList instance of the given element type.
  • get
  • clear
  • clone
  • ensureValid
    Ensures that the given element is non-null and assignable to the type specified at construction time
  • ensureValidCollection
    Ensures that all elements of the given collection can be added to this list.
  • equals
  • getElementType
    Returns the element type given at construction time.
  • hashCode
  • illegalElement
    Invoked when an illegal element has been given to the add(E) method. The element may be illegal eith
  • hashCode,
  • illegalElement,
  • size,
  • subList

Popular in Java

  • Reactive rest calls using spring rest template
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getContentResolver (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • String (java.lang)
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • Reference (javax.naming)
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now