projects
/
svjatoslav_commons.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixed HTML style.
[svjatoslav_commons.git]
/
src
/
main
/
java
/
eu
/
svjatoslav
/
commons
/
string
/
String2.java
diff --git
a/src/main/java/eu/svjatoslav/commons/string/String2.java
b/src/main/java/eu/svjatoslav/commons/string/String2.java
index
504c41d
..
b6083ed
100755
(executable)
--- a/
src/main/java/eu/svjatoslav/commons/string/String2.java
+++ b/
src/main/java/eu/svjatoslav/commons/string/String2.java
@@
-14,15
+14,16
@@
import java.util.List;
public class String2 {
public class String2 {
- private final List<Character> chars;
+ private final List<Character> chars
= new ArrayList<>()
;
- public String2(final String value) {
- chars = new ArrayList<>(value.length());
- for (final Character c : value.toCharArray())
- chars.add(c);
+ public String2(String value) {
+ addSuffix(value);
}
public String2 addPrefix(final String prefix) {
}
public String2 addPrefix(final String prefix) {
+ if (prefix == null)
+ return this;
+
int i = 0;
for (final char c : prefix.toCharArray())
chars.add(i++, c);
int i = 0;
for (final char c : prefix.toCharArray())
chars.add(i++, c);
@@
-31,12
+32,23
@@
public class String2 {
}
public String2 addSuffix(final String suffix) {
}
public String2 addSuffix(final String suffix) {
+ if (suffix == null)
+ return this;
+
for (final char c : suffix.toCharArray())
chars.add(c);
return this;
}
for (final char c : suffix.toCharArray())
chars.add(c);
return this;
}
+ public String2 addSuffix(String separator, final String suffix) {
+ if (!isEmpty())
+ addSuffix(separator);
+
+ addSuffix(suffix);
+
+ return this;
+ }
/**
* Cut given amount of characters from the left of the string.
*
/**
* Cut given amount of characters from the left of the string.
*
@@
-56,6
+68,9
@@
public class String2 {
}
public String2 trimPrefixIfExists(String prefix){
}
public String2 trimPrefixIfExists(String prefix){
+ if (prefix == null)
+ return this;
+
if (hasPrefix(prefix))
trimPrefix(prefix.length());
if (hasPrefix(prefix))
trimPrefix(prefix.length());