@Override public String toString() { if (cachedToString != null) { return cachedToString; } List<String> significantContent = getSignificantContent(); StringBuilder builder = new StringBuilder(significantContent.size() * 4); for (String segment : significantContent) builder.append(segment); cachedToString = builder.toString(); return cachedToString; }
@Override public String toString() { if (cachedToString != null) { return cachedToString; } List<String> significantContent = getSignificantContent(); StringBuilder builder = new StringBuilder(significantContent.size() * 4); for (String segment : significantContent) builder.append(segment); cachedToString = builder.toString(); return cachedToString; }
/** * Append the contents of a given StringConcatenation to this sequence. Does nothing * if the concatenation is <code>null</code>. * * @param concat * the to-be-appended StringConcatenation. * @since 2.11 */ public void append(StringConcatenation concat) { if (concat != null) appendSegments(segments.size(), concat.getSignificantContent(), concat.lineDelimiter); }
/** * A potentially contained trailing line delimiter is ignored. */ @Override protected List<String> getSignificantContent() { final List<String> result = super.getSignificantContent(); if (((result.size() >= 1) && Objects.equal(this.getLineDelimiter(), IterableExtensions.<String>last(result)))) { int _size = result.size(); int _minus = (_size - 1); return result.subList(0, _minus); } return result; }
/** * Append the contents of a given StringConcatenation to this sequence. Does nothing * if the concatenation is <code>null</code>. The given indentation will be prepended to each line except * the first one. * * @param concat * the to-be-appended StringConcatenation. * @param indentation * the indentation string that should be prepended. May not be <code>null</code>. * @since 2.11 */ public void append(StringConcatenation concat, String indentation) { if (indentation.isEmpty()) { append(concat); } else if (concat != null) appendSegments(indentation, segments.size(), concat.getSignificantContent(), concat.lineDelimiter); }
protected void append(Object object, int index) { if (object == null) return; if (object instanceof String) { append((String) object, index); } else if (object instanceof StringConcatenation) { StringConcatenation other = (StringConcatenation) object; appendSegments(index, other.getSignificantContent(), other.lineDelimiter); } else if (object instanceof StringConcatenationClient) { StringConcatenationClient other = (StringConcatenationClient) object; other.appendTo(new SimpleTarget(this, index)); } else { final String text = getStringRepresentation(object); if (text != null) { append(text, index); } } }
if (object instanceof StringConcatenation) { StringConcatenation other = (StringConcatenation) object; List<String> otherSegments = other.getSignificantContent(); appendSegments(indentation, index, otherSegments, other.lineDelimiter); } else if (object instanceof StringConcatenationClient) {
/** * Add the string representation of the given object to this sequence at the given index. Does nothing if the object * is <code>null</code>. * * @param object * the to-be-appended object. * @param index * the index in the list of segments. */ protected void append(Object object, int index) { if (object == null) return; if (object instanceof StringConcatenation) { StringConcatenation other = (StringConcatenation) object; appendSegments(index, other.getSignificantContent(), other.lineDelimiter); return; } else if (object instanceof StringConcatenationClient) { StringConcatenationClient other = (StringConcatenationClient) object; other.appendTo(new SimpleTarget(this, index)); return; } else { String value = getStringRepresentation(object); List<String> newSegments = splitLinesAndNewLines(value); appendSegments(index, newSegments, lineDelimiter); } }
} else if (object instanceof StringConcatenation) { StringConcatenation other = (StringConcatenation) object; List<String> otherSegments = other.getSignificantContent(); appendSegments(indentation, index, otherSegments, other.lineDelimiter); } else if (object instanceof StringConcatenationClient) {