Class State

  • All Implemented Interfaces:
    Block, Root

    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 by Nyx.state().
    • Constructor Detail

      • State

        @Deprecated
        public State()
        Deprecated.
        Default constructor. DO NOT USE THIS CONSTRUCTOR AS IT EXISTS ONLY FOR INTERNAL USE WHEN UNMARSHALLING
    • Method Detail

      • resume

        public static State resume​(File stateFile,
                                   Configuration configuration)
                            throws DataAccessException,
                                   IllegalPropertyException
        Loads the state attributes from a previously saved state file. Note that not all attributes are loaded from the state file as many of them will still be retrieved live from the configuration.
        Parameters:
        stateFile - the file to load the state from
        configuration - the configuration object to read values from. This object will be set as the getConfiguration() of the newly instantiated object too.
        Returns:
        the new state object deserialized from the given state file
        Throws:
        DataAccessException - in case the state file cannot be read or accessed.
        IllegalPropertyException - in case the state file has incorrect values.
      • 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 after Nyx.infer() has run.
        Specified by:
        getBump in interface Root
        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 be null.
        See Also:
        getBump()
      • getConfiguration

        public Configuration getConfiguration()
        Returns the configuration object. The configuration is a live reference.
        Specified by:
        getConfiguration in interface Root
        Returns:
        the configuration object.
      • 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 interface Root
        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 interface Root
        Returns:
        the current value for this attribute.
      • getTimestamp

        public Long getTimestamp()
        Returns the current timestamp.
        Specified by:
        getTimestamp in interface Root
        Returns:
        the current timestamp.
      • setTimestamp

        public void setTimestamp​(Long timestamp)
        Sets the state timestamp.
        Parameters:
        timestamp - the state timestamp.
      • setVersion

        public void setVersion​(String version)
        Sets the version inferred by Nyx.
        Parameters:
        version - the version inferred by Nyx.
      • touchTimestamp

        public Long touchTimestamp()
        Updates the current timestamp and returns the updated value.
        Returns:
        the updated timestamp.
        See Also:
        getTimestamp()