Search in sources :

Example 11 with StringJoiner

use of java.util.StringJoiner in project jdk8u_jdk by JetBrains.

the class MergeTest method testEmptyThis.

public void testEmptyThis() {
    StringJoiner sj = new StringJoiner(",", "{", "}");
    StringJoiner other = new StringJoiner(":", "[", "]");
    Stream.of("d", "e", "f").forEachOrdered(other::add);
    sj.merge(other);
    assertEquals(sj.toString(), "{d:e:f}");
    sj = new StringJoiner(",", "{", "}").setEmptyValue("EMPTY");
    assertEquals(sj.toString(), "EMPTY");
    sj.merge(other);
    assertEquals(sj.toString(), "{d:e:f}");
}
Also used : StringJoiner(java.util.StringJoiner)

Example 12 with StringJoiner

use of java.util.StringJoiner in project jdk8u_jdk by JetBrains.

the class MergeTest method testDelimiter.

public void testDelimiter() {
    StringJoiner sj = new StringJoiner(",", "{", "}");
    StringJoiner other = new StringJoiner(":", "[", "]");
    Stream.of("a", "b", "c").forEachOrdered(sj::add);
    Stream.of("d", "e", "f").forEachOrdered(other::add);
    sj.merge(other);
    assertEquals(sj.toString(), "{a,b,c,d:e:f}");
}
Also used : StringJoiner(java.util.StringJoiner)

Example 13 with StringJoiner

use of java.util.StringJoiner in project jdk8u_jdk by JetBrains.

the class MergeTest method testEmptyBoth.

public void testEmptyBoth() {
    StringJoiner sj = new StringJoiner(",", "{", "}");
    StringJoiner other = new StringJoiner(":", "[", "]");
    sj.merge(other);
    assertEquals(sj.toString(), "{}");
    other.setEmptyValue("NOTHING");
    sj.merge(other);
    assertEquals(sj.toString(), "{}");
    sj = new StringJoiner(",", "{", "}").setEmptyValue("EMPTY");
    assertEquals(sj.toString(), "EMPTY");
    sj.merge(other);
    assertEquals(sj.toString(), "EMPTY");
}
Also used : StringJoiner(java.util.StringJoiner)

Example 14 with StringJoiner

use of java.util.StringJoiner in project jdk8u_jdk by JetBrains.

the class MergeTest method testMergeSelf.

public void testMergeSelf() {
    final StringJoiner sj = new StringJoiner(",", "[", "]").add("a").add("b");
    assertEquals(sj.merge(sj).toString(), "[a,b,a,b]");
    assertEquals(sj.merge(sj).toString(), "[a,b,a,b,a,b,a,b]");
    final StringJoiner sj2 = new StringJoiner(",").add("c").add("d");
    assertEquals(sj2.merge(sj2).toString(), "c,d,c,d");
}
Also used : StringJoiner(java.util.StringJoiner)

Example 15 with StringJoiner

use of java.util.StringJoiner in project jdk8u_jdk by JetBrains.

the class StringJoinerTest method addAlladdAll.

// The following tests do two successive adds of different types
public void addAlladdAll() {
    StringJoiner sj = new StringJoiner(DASH, "{", "}");
    ArrayList<String> firstOne = new ArrayList<>();
    firstOne.add(ONE);
    firstOne.add(TWO);
    firstOne.add(THREE);
    firstOne.stream().forEachOrdered(sj::add);
    ArrayList<String> nextOne = new ArrayList<>();
    nextOne.add(FOUR);
    nextOne.add(FIVE);
    nextOne.stream().forEachOrdered(sj::add);
    String expected = "{" + ONE + DASH + TWO + DASH + THREE + DASH + FOUR + DASH + FIVE + "}";
    assertEquals(sj.toString(), expected);
}
Also used : ArrayList(java.util.ArrayList) StringJoiner(java.util.StringJoiner)

Aggregations

StringJoiner (java.util.StringJoiner)94 ArrayList (java.util.ArrayList)20 List (java.util.List)10 HashSet (java.util.HashSet)6 Map (java.util.Map)6 IOException (java.io.IOException)4 HashMap (java.util.HashMap)4 Collectors (java.util.stream.Collectors)4 ClassName (com.squareup.javapoet.ClassName)3 FieldSpec (com.squareup.javapoet.FieldSpec)3 ParameterizedTypeName (com.squareup.javapoet.ParameterizedTypeName)3 TypeName (com.squareup.javapoet.TypeName)3 TypeSpec (com.squareup.javapoet.TypeSpec)3 Expression (com.sri.ai.expresso.api.Expression)3 Attribute (io.requery.meta.Attribute)3 Scanner (java.util.Scanner)3 RaptorColumnHandle (com.facebook.presto.raptor.RaptorColumnHandle)2 Range (com.facebook.presto.spi.predicate.Range)2 MaterializedResult (com.facebook.presto.testing.MaterializedResult)2 MaterializedRow (com.facebook.presto.testing.MaterializedRow)2