package com.atlassian.bitbucket.mesh.app;

import org.springframework.boot.context.properties.NestedConfigurationProperty;

import javax.annotation.Nonnull;

public class BuildProperties {

    /**
     * The commit used to create the build.
     */
    @NestedConfigurationProperty
    private final BuildCommit commit = new BuildCommit();

    /**
     * The timestamp when the build was run.
     */
    private String timestamp;
    /**
     * The format the timestamp was created in, which will be used to parse it as a {@code Date}.
     */
    private String timestampFormat;
    /**
     * The software version.
     */
    private String version;

    @Nonnull
    public BuildCommit getCommit() {
        return commit;
    }

    @Nonnull
    public String getTimestamp() {
        return timestamp;
    }

    @Nonnull
    public String getTimestampFormat() {
        return timestampFormat;
    }

    @Nonnull
    public String getVersion() {
        return version;
    }

    public void setTimestamp(String timestamp) {
        this.timestamp = timestamp;
    }

    public void setTimestampFormat(String timestampFormat) {
        this.timestampFormat = timestampFormat;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public static class BuildCommit {

        /**
         * The commit hash, which is its unique identifier in the underlying SCM.
         */
        private String hash;
        /**
         * The timestamp at which the commit was created, as a UNIX timestamp (seconds since the epoch).
         */
        private String timestamp;

        public String getHash() {
            return hash;
        }

        public String getTimestamp() {
            return timestamp;
        }

        public void setHash(String hash) {
            this.hash = hash;
        }

        public void setTimestamp(String timestamp) {
            this.timestamp = timestamp;
        }
    }
}