Class ChangeLogParameters
- java.lang.Object
-
- liquibase.changelog.ChangeLogParameters
-
public class ChangeLogParameters extends Object
Holds the parameters configured for aDatabaseChangeLog
.In general, the end behavior of defined parameters is "the first set value wins". For example, if you set a parameter "x" to "1" and then set it to "2", the value will remain "1". This immutable property behavior allows users to easily set default values, knowing that any "upstream" overrides will take priority.
In determining which property value is actually "first set", context, label, and dbms filtering is taken into account.
Properties can be defined as "global" or "local". Global properties span all change logs. A global setting configured in an included changelog is still available to all changesets Local properties are only available in the change log that they are defined in -- not even in changelogs "included" by the file that defines the property.
-
-
Constructor Summary
Constructors Constructor Description ChangeLogParameters()
CallsChangeLogParameters(Database)
with a null database.ChangeLogParameters(Database database)
Creates a new ChangeLogParameters instance, populated with a set of "database.*" global parameters based on the passed database configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
expandExpressions(String string, DatabaseChangeLog changeLog)
Expand any expressions in the given string, taking into account parameters local to the given changelog file as well as contexts, labels, and database configured in this instance.Contexts
getContexts()
Gets the contexts to filter calls togetValue(String, DatabaseChangeLog)
etc.String
getDatabase()
Sets the database to filter calls togetValue(String, DatabaseChangeLog)
etc.LabelExpression
getLabels()
Gets the labels to filter calls togetValue(String, DatabaseChangeLog)
etc.Object
getValue(String key, DatabaseChangeLog changeLog)
Get the value of the given parameter, taking into account parameters local to the given changelog file and values configured ingetContexts()
andgetLabels()
and the database.boolean
hasValue(String key, DatabaseChangeLog changeLog)
Return whether the given parameters is defined, taking into account parameters local to the given changelog file as well as contexts, labels, and database configured on this instancevoid
set(String parameter, Object value)
Sets a global changelog parameter with no context/label/database filters on it.void
set(String key, Object value, String contexts, String labels, String databases, boolean globalParam, DatabaseChangeLog changeLog)
Convenience version ofset(String, Object, ContextExpression, Labels, String, boolean, DatabaseChangeLog)
.void
set(String key, Object value, ContextExpression contexts, Labels labels, String... databases)
Sets a global changelog parameter.void
set(String key, Object value, ContextExpression contexts, Labels labels, String databases, boolean globalParam, DatabaseChangeLog changeLog)
Calls eitherset(String, Object, ContextExpression, Labels, String...)
orsetLocal(String, Object, DatabaseChangeLog, ContextExpression, Labels, String...)
depending on the value of globalParam.void
setContexts(Contexts contexts)
Sets the contexts to filter calls togetValue(String, DatabaseChangeLog)
etc.void
setDatabase(String filterDatabase)
Sets the database to filter calls togetValue(String, DatabaseChangeLog)
etc.void
setLabels(LabelExpression labels)
Sets the labels to filter calls togetValue(String, DatabaseChangeLog)
etc.void
setLocal(String parameter, Object value, DatabaseChangeLog changeLog)
Sets a local changelog parameter with no context/label/database filters on it.void
setLocal(String key, Object value, DatabaseChangeLog changeLog, ContextExpression contexts, Labels labels, String... databases)
Sets a changelog parameter local to the given changeLog file.
-
-
-
Constructor Detail
-
ChangeLogParameters
public ChangeLogParameters()
CallsChangeLogParameters(Database)
with a null database.
-
ChangeLogParameters
public ChangeLogParameters(Database database)
Creates a new ChangeLogParameters instance, populated with a set of "database.*" global parameters based on the passed database configuration. If the database is null, no global parameters are added.The passed database is used as a default value for
getDatabase()
-
-
Method Detail
-
set
public void set(String parameter, Object value)
Sets a global changelog parameter with no context/label/database filters on it. Convenience version ofset(String, Object, ContextExpression, Labels, String...)
.
-
setLocal
public void setLocal(String parameter, Object value, DatabaseChangeLog changeLog)
Sets a local changelog parameter with no context/label/database filters on it. Convenience version ofsetLocal(String, Object, DatabaseChangeLog, ContextExpression, Labels, String...)
.
-
set
public void set(String key, Object value, ContextExpression contexts, Labels labels, String databases, boolean globalParam, DatabaseChangeLog changeLog)
Calls eitherset(String, Object, ContextExpression, Labels, String...)
orsetLocal(String, Object, DatabaseChangeLog, ContextExpression, Labels, String...)
depending on the value of globalParam.
-
set
public void set(String key, Object value, String contexts, String labels, String databases, boolean globalParam, DatabaseChangeLog changeLog)
Convenience version ofset(String, Object, ContextExpression, Labels, String, boolean, DatabaseChangeLog)
.
-
set
public void set(String key, Object value, ContextExpression contexts, Labels labels, String... databases)
Sets a global changelog parameter. Just because you call this with a particular key, does not mean it will override the existing value. See the class description for more details on how values act as if they are immutable.
-
setLocal
public void setLocal(String key, Object value, DatabaseChangeLog changeLog, ContextExpression contexts, Labels labels, String... databases)
Sets a changelog parameter local to the given changeLog file. Just because you call this with a particular key, does not mean it will override the existing value. See the class description for more details on how values act as if they are immutable.- Parameters:
changeLog
- required for local parameters, ignored for global parameters
-
getValue
public Object getValue(String key, DatabaseChangeLog changeLog)
Get the value of the given parameter, taking into account parameters local to the given changelog file and values configured ingetContexts()
andgetLabels()
and the database.
-
hasValue
public boolean hasValue(String key, DatabaseChangeLog changeLog)
Return whether the given parameters is defined, taking into account parameters local to the given changelog file as well as contexts, labels, and database configured on this instance
-
expandExpressions
public String expandExpressions(String string, DatabaseChangeLog changeLog) throws UnknownChangeLogParameterException
Expand any expressions in the given string, taking into account parameters local to the given changelog file as well as contexts, labels, and database configured in this instance.
-
getContexts
public Contexts getContexts()
Gets the contexts to filter calls togetValue(String, DatabaseChangeLog)
etc. with.
-
setContexts
public void setContexts(Contexts contexts)
Sets the contexts to filter calls togetValue(String, DatabaseChangeLog)
etc. with.
-
getLabels
public LabelExpression getLabels()
Gets the labels to filter calls togetValue(String, DatabaseChangeLog)
etc. with.
-
setLabels
public void setLabels(LabelExpression labels)
Sets the labels to filter calls togetValue(String, DatabaseChangeLog)
etc. with.
-
getDatabase
public String getDatabase()
Sets the database to filter calls togetValue(String, DatabaseChangeLog)
etc. with.
-
setDatabase
public void setDatabase(String filterDatabase)
Sets the database to filter calls togetValue(String, DatabaseChangeLog)
etc. with.
-
-