congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
CollectionUtil.iterator
Code IndexAdd Tabnine to your IDE (free)

How to use
iterator
method
in
com.twelvemonkeys.util.CollectionUtil

Best Java code snippets using com.twelvemonkeys.util.CollectionUtil.iterator (Showing top 20 results out of 315)

origin: haraldk/TwelveMonkeys

  protected Iterator<String> keysImpl() {
    @SuppressWarnings("unchecked")
    Enumeration<String> headerNames = request.getHeaderNames();
    return headerNames == null ? null : CollectionUtil.iterator(headerNames);
  }
}
origin: haraldk/TwelveMonkeys

protected List<String> valueImpl(final String pName) {
  @SuppressWarnings("unchecked")
  Enumeration<String> headers = request.getHeaders(pName);
  return headers == null ? null : toList(CollectionUtil.iterator(headers));
}
origin: haraldk/TwelveMonkeys

/**
 * Creates a thin {@link Iterator} wrapper around an array.
 *
 * @param pArray the array to iterate
 * @return a new {@link ListIterator}
 * @throws IllegalArgumentException if {@code pArray} is {@code null},
 *         {@code pStart < 0}, or
 *         {@code pLength > pArray.length - pStart}
 */
public static <E> ListIterator<E> iterator(final E[] pArray) {
  return iterator(pArray, 0, notNull(pArray).length);
}
origin: haraldk/TwelveMonkeys

  protected Iterator<String> keysImpl() {
    @SuppressWarnings("unchecked")
    Enumeration<String> names = request.getParameterNames();
    return names == null ? null : CollectionUtil.iterator(names);
  }
}
origin: haraldk/TwelveMonkeys

@Test(expected = IllegalArgumentException.class)
public void testArrayIteratorRangeBadStart() {
  CollectionUtil.iterator(stringObjects, stringObjects.length + 1, 2);
}
@Test(expected = IllegalArgumentException.class)
origin: haraldk/TwelveMonkeys

@Test(expected = IllegalArgumentException.class)
public void testArrayIteratorNull() {
  CollectionUtil.iterator((Object[]) null);
}
origin: haraldk/TwelveMonkeys

@Test(expected = IllegalArgumentException.class)
public void testEnumIteratorNull() {
  CollectionUtil.iterator((Enumeration<Object>) null);
}

origin: haraldk/TwelveMonkeys

@Test(expected = IllegalArgumentException.class)
public void testArrayIteratorRangeBadLength() {
  CollectionUtil.iterator(stringObjects, 1, stringObjects.length);
}
origin: haraldk/TwelveMonkeys

@Test(expected = IllegalArgumentException.class)
public void testArrayIteratorRangeNull() {
  CollectionUtil.iterator(null, 0, 0);
}
origin: haraldk/TwelveMonkeys

@Test
public void testArrayListIterator() {
  assertCorrectListIterator(CollectionUtil.iterator(new String[] {"foo", "bar", "baz"}), stringObjects);
}
origin: haraldk/TwelveMonkeys

@Test
public void testArrayListIteratorRange() {
  assertCorrectListIterator(CollectionUtil.iterator(new String[] {"foo", "bar", "baz", "boo"}, 1, 2), new String[] {"bar", "baz"});
}
origin: haraldk/TwelveMonkeys

@Test
public void testEmptyIteratorConstructor() throws IOException {
  Reader reader = new CompoundReader(CollectionUtil.iterator(new Reader[0]));
  assertEquals(-1, reader.read());
}
origin: haraldk/TwelveMonkeys

  @Test
  public void testIteratorWithNullConstructor() throws IOException {
    try {
      new CompoundReader(CollectionUtil.iterator(new Reader[] {null}));
      fail("Should not allow null in iterator argument");
    }
    catch (RuntimeException e) {
      assertNotNull(e.getMessage());
    }
  }
}
origin: haraldk/TwelveMonkeys

@Test
public void testArrayIteratorRange() {
  Iterator<String> iterator = CollectionUtil.iterator(new String[] {"foo", "bar", "baz", "xyzzy"}, 1, 2);
  for (int i = 1; i < 3; i++) {
    assertTrue(iterator.hasNext());
    assertEquals(stringObjects[i], iterator.next());
    try {
      iterator.remove();
      fail("Array has no remove method, iterator.remove() must throw exception");
    }
    catch (UnsupportedOperationException expected) {
    }
  }
  assertFalse(iterator.hasNext());
  try {
    iterator.next();
    fail("Iterator has more elements than array range");
  }
  catch (NoSuchElementException expected) {
  }
}
origin: haraldk/TwelveMonkeys

@Test
public void testEnumIterator() {
  @SuppressWarnings("unchecked")
  Iterator<String> iterator = CollectionUtil.iterator((Enumeration) new StringTokenizer("foo, bar, baz", ", "));
  int count = 0;
  for (Object stringObject : stringObjects) {
    assertTrue(iterator.hasNext());
    assertEquals(stringObject, iterator.next());
    
    try {
      iterator.remove();
      fail("Enumeration has no remove method, iterator.remove() must throw exception");
    }
    catch (UnsupportedOperationException expected) {
    }
    count++;
  }
  assertEquals(3, count);
  assertFalse(iterator.hasNext());
  
  try {
    iterator.next();
    fail("Iterator has more elements than enumeration");
  }
  catch (NoSuchElementException expected) {
  }
}
origin: haraldk/TwelveMonkeys

@Test
public void testArrayIterator() {
  Iterator<String> iterator = CollectionUtil.iterator(new String[] {"foo", "bar", "baz"});
  int count = 0;
  for (Object stringObject : stringObjects) {
    assertTrue(iterator.hasNext());
    assertEquals(stringObject, iterator.next());
    try {
      iterator.remove();
      fail("Array have fixed length, iterator.remove() must throw exception");
    }
    catch (UnsupportedOperationException expected) {
    }
    count++;
  }
  assertEquals(3, count);
  assertFalse(iterator.hasNext());
  try {
    iterator.next();
    fail("Iterator has more elements than array");
  }
  catch (NoSuchElementException expected) {
  }
}
origin: com.twelvemonkeys.common/common-lang

/**
 * Creates a thin {@link Iterator} wrapper around an array.
 *
 * @param pArray the array to iterate
 * @return a new {@link ListIterator}
 * @throws IllegalArgumentException if {@code pArray} is {@code null},
 *         {@code pStart < 0}, or
 *         {@code pLength > pArray.length - pStart}
 */
public static <E> ListIterator<E> iterator(final E[] pArray) {
  return iterator(pArray, 0, notNull(pArray).length);
}
origin: com.twelvemonkeys.common/common-lang

@Test(expected = IllegalArgumentException.class)
public void testArrayIteratorRangeBadLength() {
  CollectionUtil.iterator(stringObjects, 1, stringObjects.length);
}
origin: com.github.lafa.twelvemonkeyspurejava.common/common-io

@Test
public void testEmptyIteratorConstructor() throws IOException {
  Reader reader = new CompoundReader(CollectionUtil.iterator(new Reader[0]));
  assertEquals(-1, reader.read());
}
origin: com.github.lafa.twelvemonkeyspurejava.common/common-io

  @Test
  public void testIteratorWithNullConstructor() throws IOException {
    try {
      new CompoundReader(CollectionUtil.iterator(new Reader[] {null}));
      fail("Should not allow null in iterator argument");
    }
    catch (RuntimeException e) {
      assertNotNull(e.getMessage());
    }
  }
}
com.twelvemonkeys.utilCollectionUtiliterator

Javadoc

Creates a thin Iterator wrapper around an array.

Popular methods of CollectionUtil

  • subArray
    Creates an array containing a subset of the original array. If the pLength parameter is negative, it
  • mergeArrays
    Merges two arrays into a new array. Elements from array1 and array2 will be copied into a new array,
  • addAll
    Adds all elements of the iterator to the collection.
  • generify
  • generify2
  • invert
    Creates an inverted mapping of the key/value pairs in the given map. Optionally, a duplicate handler
  • reverseOrder
  • test

Popular in Java

  • Reading from database using SQL prepared statement
  • getSharedPreferences (Context)
  • compareTo (BigDecimal)
  • putExtra (Intent)
  • String (java.lang)
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • Collectors (java.util.stream)
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Github Copilot alternatives
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