Package liquibase.util
Class StringClauses
- java.lang.Object
-
- liquibase.util.StringClauses
-
public class StringClauses extends Object
Defines a list of clauses that can be manipulated and rearranged based on keys associated with each. OntoString()
, the clauses will be joined by the separator passed at construction time and prepended/postpended by the start/end strings set at construction time.
Note: all keys and values passed in are trimmed.
NOTE: All keys are managed in a case INSENSITIVE manner
NOTE: Null or empty clauses and subclauses are skipped intoString()
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
StringClauses.ClauseIterator
static class
StringClauses.Comment
static class
StringClauses.Delimiter
static interface
StringClauses.LiteralClause
static class
StringClauses.Whitespace
-
Constructor Summary
Constructors Constructor Description StringClauses()
Creates a new StringClause with no start or end strings and a space separator.StringClauses(String separator)
Creates a new StringClause with no start or end strings and the given separator.StringClauses(String start, String separator, String end)
Creates a new StringClause with the given start, end and separator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringClauses
append(Enum name, String clause)
Convenience method forappend(String, String)
when using enums.StringClauses
append(Enum name, StringClauses subclauses)
Convenience method forappend(String, StringClauses)
when using enums.StringClauses
append(String clause)
Adds a new clause at the end of the list.StringClauses
append(String key, String clause)
Adds a new clause at the end of the list with the given key.StringClauses
append(String key, StringClauses subclauses)
Adds a new sub-clause at the end of the list with the given key.StringClauses
append(StringClauses.LiteralClause literal)
boolean
contains(String key)
boolean
equals(Object o)
String
get(Enum exitingKey)
Convenience method forget(String)
when using enums.String
get(String exitingKey)
Retrieves the given key.StringClauses.ClauseIterator
getClauseIterator()
StringClauses
getSubclause(Enum exitingKey)
Convenience method forgetSubclause(String)
when using enumsStringClauses
getSubclause(String exitingKey)
Retrieves the given key.int
hashCode()
StringClauses
insertAfter(Enum existingKey, String newValue)
Convenience method forinsertAfter(String, String)
when using enumsStringClauses
insertAfter(String existingKey, String newValue)
Convenience method forinsertAfter(String, String, String)
using the newValue as the newKey.StringClauses
insertAfter(String existingKey, String newKey, String newValue)
Inserts a new clause after the given key.StringClauses
insertAfter(String existingKey, String newKey, StringClauses newValue)
Inserts a new sub-clause after the given key.StringClauses
insertBefore(Enum existingKey, Enum newKey, String newValue)
Convenience method forinsertBefore(String, String)
when using enums.StringClauses
insertBefore(Enum existingKey, String newValue)
Convenience method forinsertBefore(String, String)
when using enums.StringClauses
insertBefore(String existingKey, String newValue)
Convenience method forinsertBefore(String, String, String)
where the new clause key is equal to the newValue.StringClauses
insertBefore(String existingKey, String newKey, String newValue)
Inserts a new clause before the given key.StringClauses
insertBefore(String existingKey, String newKey, StringClauses newValue)
Inserts a new sub-clause before the given key.boolean
isEmpty()
StringClauses
prepend(Enum key, String clause)
Convenience method forprepend(String, String)
when using enumsStringClauses
prepend(Enum key, StringClauses clause)
Convenience method forprepend(String, liquibase.util.StringClauses)
when using enumsStringClauses
prepend(String clause)
Convenience method forprepend(String, String)
that uses the clause as the key.StringClauses
prepend(String key, String clause)
Adds a clause with the given key to the beginning of the list.StringClauses
prepend(String key, StringClauses clause)
Adds a sub-clause with the given key to the beginning of the list.StringClauses
prepend(StringClauses.LiteralClause literal)
StringClauses
remove(Enum key)
Convenience method forremove(String)
when using enums.StringClauses
remove(String key)
Removes the clause with the given key.StringClauses
replace(Enum key, String newValue)
Convenience method forreplace(String, String)
when using enums.StringClauses
replace(Enum key, StringClauses newValue)
Convenience method forreplace(String, liquibase.util.StringClauses)
when using enums.StringClauses
replace(String key, String newValue)
Replaces the given key with a new string.StringClauses
replace(String key, StringClauses newValue)
Replaces the given key with a new sub-clause.Object[]
toArray(boolean stringify)
String
toString()
-
-
-
Constructor Detail
-
StringClauses
public StringClauses()
Creates a new StringClause with no start or end strings and a space separator.
-
StringClauses
public StringClauses(String separator)
Creates a new StringClause with no start or end strings and the given separator.
-
-
Method Detail
-
append
public StringClauses append(String key, String clause)
Adds a new clause at the end of the list with the given key.
-
append
public StringClauses append(String key, StringClauses subclauses)
Adds a new sub-clause at the end of the list with the given key.
-
append
public StringClauses append(String clause)
Adds a new clause at the end of the list. The key is equal to the passed clause. There is no corresponding append with just a StringClauses because the subclause may not be fully created when appended and so the key may be an unexpected value.
-
append
public StringClauses append(Enum name, StringClauses subclauses)
Convenience method forappend(String, StringClauses)
when using enums.
-
append
public StringClauses append(Enum name, String clause)
Convenience method forappend(String, String)
when using enums.
-
append
public StringClauses append(StringClauses.LiteralClause literal)
-
prepend
public StringClauses prepend(StringClauses.LiteralClause literal)
-
prepend
public StringClauses prepend(String key, String clause)
Adds a clause with the given key to the beginning of the list.
-
prepend
public StringClauses prepend(String key, StringClauses clause)
Adds a sub-clause with the given key to the beginning of the list.
-
prepend
public StringClauses prepend(String clause)
Convenience method forprepend(String, String)
that uses the clause as the key.
-
prepend
public StringClauses prepend(Enum key, String clause)
Convenience method forprepend(String, String)
when using enums
-
prepend
public StringClauses prepend(Enum key, StringClauses clause)
Convenience method forprepend(String, liquibase.util.StringClauses)
when using enums
-
remove
public StringClauses remove(String key)
Removes the clause with the given key. Removes case insensitively. If key doesn't exist, operation is a no-op.
-
remove
public StringClauses remove(Enum key)
Convenience method forremove(String)
when using enums.
-
replace
public StringClauses replace(String key, String newValue) throws IllegalArgumentException
Replaces the given key with a new string. If the existing key does not exist, throws IllegalArgumentException- Throws:
IllegalArgumentException
-
contains
public boolean contains(String key)
-
replace
public StringClauses replace(String key, StringClauses newValue)
Replaces the given key with a new sub-clause. If the existing key does not exist, throws IllegalArgumentException
-
replace
public StringClauses replace(Enum key, StringClauses newValue)
Convenience method forreplace(String, liquibase.util.StringClauses)
when using enums.
-
replace
public StringClauses replace(Enum key, String newValue)
Convenience method forreplace(String, String)
when using enums.
-
insertBefore
public StringClauses insertBefore(String existingKey, String newKey, String newValue) throws IllegalArgumentException
Inserts a new clause before the given key. Throws IllegalArgumentException if the existingKey does not exist.- Throws:
IllegalArgumentException
-
insertBefore
public StringClauses insertBefore(String existingKey, String newKey, StringClauses newValue)
Inserts a new sub-clause before the given key. Throws IllegalArgumentException if the existingKey does not exist.
-
insertBefore
public StringClauses insertBefore(String existingKey, String newValue)
Convenience method forinsertBefore(String, String, String)
where the new clause key is equal to the newValue.
-
insertBefore
public StringClauses insertBefore(Enum existingKey, String newValue)
Convenience method forinsertBefore(String, String)
when using enums.
-
insertBefore
public StringClauses insertBefore(Enum existingKey, Enum newKey, String newValue)
Convenience method forinsertBefore(String, String)
when using enums.
-
insertAfter
public StringClauses insertAfter(String existingKey, String newKey, String newValue)
Inserts a new clause after the given key. Throws IllegalArgumentException if the existingKey does not exist.
-
insertAfter
public StringClauses insertAfter(String existingKey, String newKey, StringClauses newValue)
Inserts a new sub-clause after the given key. Throws IllegalArgumentException if the existingKey does not exist.
-
insertAfter
public StringClauses insertAfter(Enum existingKey, String newValue)
Convenience method forinsertAfter(String, String)
when using enums
-
insertAfter
public StringClauses insertAfter(String existingKey, String newValue)
Convenience method forinsertAfter(String, String, String)
using the newValue as the newKey.
-
get
public String get(String exitingKey)
Retrieves the given key. Returns null if not set. If clause at key is a StringClause, return the string version of it. Will traverse sub-clauses to find the key.
-
get
public String get(Enum exitingKey)
Convenience method forget(String)
when using enums.
-
getSubclause
public StringClauses getSubclause(String exitingKey)
Retrieves the given key. Returns null if not set. If clause at key is a String, return a new StringClause version of it. Will traverse sub-clauses to find the key.
-
getSubclause
public StringClauses getSubclause(Enum exitingKey)
Convenience method forgetSubclause(String)
when using enums
-
getClauseIterator
public StringClauses.ClauseIterator getClauseIterator()
-
toArray
public Object[] toArray(boolean stringify)
-
isEmpty
public boolean isEmpty()
-
-