Package com.mooltiverse.oss.nyx.state
Class State
- java.lang.Object
-
- com.mooltiverse.oss.nyx.state.State
-
public class State extends Object implements Root
The State class holds a number of attributes resulting from the execution of one or more command and so represents the current status of a release process at a certain point in time. Each command updates the state object with new or modified attributes so the same state instance is shared among all commands. There must be only one instance of this class for every execution and it's retrieved byNyx.state()
.
-
-
Constructor Summary
Constructors Constructor Description State(Configuration configuration)
Standard constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getBump()
Returns the version identifier bumped on the previous release to produce the new release, if any.Configuration
getConfiguration()
Returns the configuration object.File
getDirectory()
Returns the directory used as the working directory as it's defined by the configuration.Map<String,String>
getInternals()
Returns the live map of internal attributes.ReleaseScope
getReleaseScope()
Returns the object modelling the attributes defining the scope of the release.Scheme
getScheme()
Returns the versioning scheme used as it's defined by the configuration.Long
getTimestamp()
Returns the current timestamp.String
getVersion()
Returns the version inferred by Nyx, if any.Version
getVersionInternal()
Gets the version attribute.void
setBump(String bump)
Sets the version identifier bumped on the previous release to produce the new release, if any.void
setVersionInternal(Version version)
Sets the version attribute.Long
touchTimestamp()
Updates the current timestamp and returns the updated value.
-
-
-
Constructor Detail
-
State
public State(Configuration configuration)
Standard constructor.- Parameters:
configuration
- the configuration object held by this state- Throws:
NullPointerException
- if the given argument isnull
-
-
Method Detail
-
getBump
public String getBump() throws DataAccessException, IllegalPropertyException
Returns the version identifier bumped on the previous release to produce the new release, if any. This value is only available afterNyx.infer()
has run.- Specified by:
getBump
in interfaceRoot
- Returns:
- the version identifier bumped on the previous release to produce the new release, if any.
It may be
null
if no identifier has been bumped (i.e. because no significant changes have been detected in the release scope or because inference was inhibited by values overridden by user). - Throws:
DataAccessException
- in case the attribute cannot be read or accessed.IllegalPropertyException
- in case the attribute has been defined but has incorrect values or it can't be resolved.- See Also:
Root.getReleaseScope()
,ReleaseScope.getSignificant()
-
setBump
public void setBump(String bump)
Sets the version identifier bumped on the previous release to produce the new release, if any.- Parameters:
bump
- the version identifier bumped on the previous release to produce the new release, if any. It may benull
.- See Also:
getBump()
-
getConfiguration
public Configuration getConfiguration()
Returns the configuration object. The configuration is a live reference.- Specified by:
getConfiguration
in interfaceRoot
- Returns:
- the configuration object.
-
getDirectory
public File getDirectory() throws DataAccessException, IllegalPropertyException
Returns the directory used as the working directory as it's defined by the configuration.- Specified by:
getDirectory
in interfaceRoot
- Returns:
- the current value for this attribute.
- Throws:
DataAccessException
- in case the attribute cannot be read or accessed.IllegalPropertyException
- in case the attribute has been defined but has incorrect values or it can't be resolved.- See Also:
Configuration.getDirectory()
-
getInternals
public Map<String,String> getInternals()
Returns the live map of internal attributes. Internal attributes are not documented so they must not be used by users as the implementation may change them at any time. Commands and other implementation objects are free to store and remove their own attributes here (i.e. for caching or store their internal state). When handling these attributes, entities must make sure the names (keys) do not overlap, unless for shared attributes. This object takes no control over the values stored in this map. Sensitive informations must not be stored here as they would be exposed when marshalling the attributes to files.- Specified by:
getInternals
in interfaceRoot
- Returns:
- the live map of internal attributes. The returned map is never
null
-
getReleaseScope
public ReleaseScope getReleaseScope()
Returns the object modelling the attributes defining the scope of the release.- Specified by:
getReleaseScope
in interfaceRoot
- Returns:
- the current value for this attribute.
-
getScheme
public Scheme getScheme() throws DataAccessException, IllegalPropertyException
Returns the versioning scheme used as it's defined by the configuration.- Specified by:
getScheme
in interfaceRoot
- Returns:
- the current value for this attribute.
- Throws:
DataAccessException
- in case the attribute cannot be read or accessed.IllegalPropertyException
- in case the attribute has been defined but has incorrect values or it can't be resolved.
-
getTimestamp
public Long getTimestamp()
Returns the current timestamp.- Specified by:
getTimestamp
in interfaceRoot
- Returns:
- the current timestamp.
-
getVersion
public String getVersion() throws DataAccessException, IllegalPropertyException
Returns the version inferred by Nyx, if any. If the version was overridden by configuration this will be the same asConfiguration.getVersion()
. This value is only available afterNyx.infer()
has run. This method returns the same asgetVersionInternal()
but with the prefix, if configured.- Specified by:
getVersion
in interfaceRoot
- Returns:
- the current version inferred by Nyx. This is
null
untilNyx.infer()
has run. - Throws:
DataAccessException
- in case the attribute cannot be read or accessed.IllegalPropertyException
- in case the attribute has been defined but has incorrect values or it can't be resolved.- See Also:
Configuration.getVersion()
,Nyx.infer()
,Infer
-
getVersionInternal
public Version getVersionInternal() throws DataAccessException, IllegalPropertyException
Gets the version attribute. This method returns the internal representation of theVersion
, which does not include the prefix. If you need the prefix as well usegetVersion()
instead.- Returns:
- the version attribute to set for this state.
- Throws:
DataAccessException
- in case the attribute cannot be read or accessed.IllegalPropertyException
- in case the attribute has been defined but has incorrect values or it can't be resolved.- See Also:
setVersionInternal(Version)
,getVersion()
,Version.getScheme()
,Configuration.getScheme()
-
setVersionInternal
public void setVersionInternal(Version version) throws DataAccessException, IllegalPropertyException
Sets the version attribute. This is the internal representation and does not contemplate the configured prefix, if any.- Parameters:
version
- the version attribute to set for this state.- Throws:
DataAccessException
- in case the attribute cannot be read or accessed.IllegalPropertyException
- in case the attribute has been defined but has incorrect values or it can't be resolved.- See Also:
getVersionInternal()
,Version.getScheme()
,Configuration.getScheme()
-
touchTimestamp
public Long touchTimestamp()
Updates the current timestamp and returns the updated value.- Returns:
- the updated timestamp.
- See Also:
getTimestamp()
-
-