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 classStringClauses.ClauseIteratorstatic classStringClauses.Commentstatic classStringClauses.Delimiterstatic interfaceStringClauses.LiteralClausestatic classStringClauses.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 StringClausesappend(Enum name, String clause)Convenience method forappend(String, String)when using enums.StringClausesappend(Enum name, StringClauses subclauses)Convenience method forappend(String, StringClauses)when using enums.StringClausesappend(String clause)Adds a new clause at the end of the list.StringClausesappend(String key, String clause)Adds a new clause at the end of the list with the given key.StringClausesappend(String key, StringClauses subclauses)Adds a new sub-clause at the end of the list with the given key.StringClausesappend(StringClauses.LiteralClause literal)booleancontains(String key)booleanequals(Object o)Stringget(Enum exitingKey)Convenience method forget(String)when using enums.Stringget(String exitingKey)Retrieves the given key.StringClauses.ClauseIteratorgetClauseIterator()StringClausesgetSubclause(Enum exitingKey)Convenience method forgetSubclause(String)when using enumsStringClausesgetSubclause(String exitingKey)Retrieves the given key.inthashCode()StringClausesinsertAfter(Enum existingKey, String newValue)Convenience method forinsertAfter(String, String)when using enumsStringClausesinsertAfter(String existingKey, String newValue)Convenience method forinsertAfter(String, String, String)using the newValue as the newKey.StringClausesinsertAfter(String existingKey, String newKey, String newValue)Inserts a new clause after the given key.StringClausesinsertAfter(String existingKey, String newKey, StringClauses newValue)Inserts a new sub-clause after the given key.StringClausesinsertBefore(Enum existingKey, Enum newKey, String newValue)Convenience method forinsertBefore(String, String)when using enums.StringClausesinsertBefore(Enum existingKey, String newValue)Convenience method forinsertBefore(String, String)when using enums.StringClausesinsertBefore(String existingKey, String newValue)Convenience method forinsertBefore(String, String, String)where the new clause key is equal to the newValue.StringClausesinsertBefore(String existingKey, String newKey, String newValue)Inserts a new clause before the given key.StringClausesinsertBefore(String existingKey, String newKey, StringClauses newValue)Inserts a new sub-clause before the given key.booleanisEmpty()StringClausesprepend(Enum key, String clause)Convenience method forprepend(String, String)when using enumsStringClausesprepend(Enum key, StringClauses clause)Convenience method forprepend(String, liquibase.util.StringClauses)when using enumsStringClausesprepend(String clause)Convenience method forprepend(String, String)that uses the clause as the key.StringClausesprepend(String key, String clause)Adds a clause with the given key to the beginning of the list.StringClausesprepend(String key, StringClauses clause)Adds a sub-clause with the given key to the beginning of the list.StringClausesprepend(StringClauses.LiteralClause literal)StringClausesremove(Enum key)Convenience method forremove(String)when using enums.StringClausesremove(String key)Removes the clause with the given key.StringClausesreplace(Enum key, String newValue)Convenience method forreplace(String, String)when using enums.StringClausesreplace(Enum key, StringClauses newValue)Convenience method forreplace(String, liquibase.util.StringClauses)when using enums.StringClausesreplace(String key, String newValue)Replaces the given key with a new string.StringClausesreplace(String key, StringClauses newValue)Replaces the given key with a new sub-clause.Object[]toArray(boolean stringify)StringtoString()
-
-
-
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()
-
-