use of org.eclipse.collections.impl.string.immutable.CharAdapter in project eclipse-collections by eclipse.
the class StringsTest method asChars.
@Test
public void asChars() {
CharAdapter adapter = Strings.asChars("The quick brown fox jumps over the lazy dog.");
Assert.assertTrue(adapter.contains('T'));
}
use of org.eclipse.collections.impl.string.immutable.CharAdapter in project eclipse-collections by eclipse.
the class StringsTest method toChars.
@Test
public void toChars() {
CharAdapter adapter = Strings.toChars('H', 'e', 'l', 'l', 'o');
Assert.assertEquals(2, adapter.count(c -> c == 'l'));
}
use of org.eclipse.collections.impl.string.immutable.CharAdapter in project eclipse-collections by eclipse.
the class StringIterateTest method asCharAdapter.
@Test
public void asCharAdapter() {
CharAdapter answer = StringIterate.asCharAdapter("HelloHellow").collectChar(Character::toUpperCase).select(c -> c != 'W').distinct().toReversed().reject(CharAdapter.adapt("LE")::contains).newWith('!');
Assert.assertEquals("OH!", answer.toString());
Assert.assertEquals("OH!", answer.toStringBuilder().toString());
Assert.assertEquals("OH!", answer.makeString(""));
CharList charList = StringIterate.asCharAdapter("HelloHellow").asLazy().collectChar(Character::toUpperCase).select(c -> c != 'W').toList().distinct().toReversed().reject(CharAdapter.adapt("LE")::contains).with('!');
Assert.assertEquals("OH!", CharAdapter.from(charList).toString());
Assert.assertEquals("OH!", CharAdapter.from(CharAdapter.from(charList)).toString());
String helloUppercase2 = StringIterate.asCharAdapter("Hello").asLazy().collectChar(Character::toUpperCase).makeString("");
Assert.assertEquals("HELLO", helloUppercase2);
CharArrayList arraylist = new CharArrayList();
StringIterate.asCharAdapter("Hello".toUpperCase()).chars().sorted().forEach(e -> arraylist.add((char) e));
Assert.assertEquals(StringIterate.asCharAdapter("EHLLO"), arraylist);
ImmutableCharList arrayList2 = StringIterate.asCharAdapter("Hello".toUpperCase()).toSortedList().toImmutable();
Assert.assertEquals(StringIterate.asCharAdapter("EHLLO"), arrayList2);
Assert.assertEquals(StringIterate.asCharAdapter("HELLO"), CharAdapter.adapt("hello").collectChar(Character::toUpperCase));
}
Aggregations