Tabnine Logo
CheckedArrayList.add
Code IndexAdd Tabnine to your IDE (free)

How to use
add
method
in
org.apache.sis.internal.util.CheckedArrayList

Best Java code snippets using org.apache.sis.internal.util.CheckedArrayList.add (Showing top 14 results out of 315)

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

/**
 * Sets the attribute value.
 *
 * @param  value  the new value, or {@code null} for removing all values from this attribute.
 */
@Override
public void setValue(final V value) {
  values.clear();
  if (value != null) {
    values.add(value);
  }
}
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: 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: apache/sis

/**
 * Sets the attribute value.
 *
 * @param  value  the new value, or {@code null} for removing all values from this attribute.
 */
@Override
public void setValue(final V value) {
  values.clear();
  if (value != null) {
    values.add(value);
  }
}
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: 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: 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: apache/sis

/**
 * Sets the feature.
 *
 * @param  value  the new value, or {@code null} for removing all values from this association.
 */
@Override
public void setValue(final AbstractFeature value) {
  values.clear();
  if (value != null) {
    ensureValid(role.getValueType(), value.getType());
    values.add(value);
  }
}
origin: org.apache.sis.core/sis-feature

/**
 * Sets the feature.
 *
 * @param  value  the new value, or {@code null} for removing all values from this association.
 */
@Override
public void setValue(final AbstractFeature value) {
  values.clear();
  if (value != null) {
    ensureValid(role.getValueType(), value.getType());
    values.add(value);
  }
}
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: org.apache.sis.core/sis-feature

/**
 * Sets the feature values. All previous values are replaced by the given collection.
 *
 * @param  newValues  the new values.
 */
@Override
public void setValues(final Collection<? extends AbstractFeature> newValues) {
  if (newValues != values) {
    ArgumentChecks.ensureNonNull("values", newValues);  // The parameter name in public API is "values".
    final DefaultFeatureType base = role.getValueType();
    values.clear();
    for (final AbstractFeature value : newValues) {
      ensureValid(base, value.getType());
      values.add(value);
    }
  }
}
origin: apache/sis

/**
 * Sets the feature values. All previous values are replaced by the given collection.
 *
 * @param  newValues  the new values.
 */
@Override
public void setValues(final Collection<? extends AbstractFeature> newValues) {
  if (newValues != values) {
    ArgumentChecks.ensureNonNull("values", newValues);  // The parameter name in public API is "values".
    final DefaultFeatureType base = role.getValueType();
    values.clear();
    for (final AbstractFeature value : newValues) {
      ensureValid(base, value.getType());
      values.add(value);
    }
  }
}
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.
}
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>"));
  }
}
org.apache.sis.internal.utilCheckedArrayListadd

Javadoc

Inserts the specified element at the specified position in this list.

Popular methods of CheckedArrayList

  • <init>
    Constructs a list of the specified type and initial capacity.
  • addAll
    Appends all of the elements in the specified collection to the end of this list, in the order that t
  • 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

  • Updating database using SQL prepared statement
  • addToBackStack (FragmentTransaction)
  • onCreateOptionsMenu (Activity)
  • requestLocationUpdates (LocationManager)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • JTextField (javax.swing)
  • Top 12 Jupyter Notebook extensions
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