Beispiel #1
0
 /**
  * Constructs a {@code StringJoiner} with no characters in it using copies
  * of the supplied {@code prefix}, {@code delimiter} and {@code suffix}.
  * If no characters are added to the {@code StringJoiner} and methods
  * accessing the string value of it are invoked, it will return the
  * {@code prefix + suffix} (or properties thereof) in the result, unless
  * {@code setEmptyValue} has first been called.
  *
  * @param  string $delimiter
  *         the sequence of characters to be used between each
  *         element added to the {@code StringJoiner}
  * @param  string $prefix
  *         the sequence of characters to be used at the beginning
  * @param  string $suffix
  *         the sequence of characters to be used at the end
  * @throws NullPointerException if {@code prefix}, {@code delimiter}, or
  *         {@code suffix} is {@code null}
  */
 public function __construct($delimiter, $prefix = null, $suffix = null)
 {
     Objects::requireNonNull($delimiter, "The delimiter must not be null");
     if (null === $prefix xor null === $suffix) {
         Objects::requireNonNull($prefix, "The prefix must not be null");
         Objects::requireNonNull($suffix, "The suffix must not be null");
     }
     $this->prefix = new String($prefix);
     $this->delimiter = new String($delimiter);
     $this->suffix = new String($suffix);
     $this->emptyValue = $this->prefix->concat($this->suffix);
 }
Beispiel #2
0
 public function testConcat()
 {
     $this->assertEquals(self::STRING_VALUE . '0', $this->string->concat(new String('0')));
 }