/*
 * Copyright 2015-2017 Atomist Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import * as spinnakerPipelineApi from "../SpinnakerPipeline";
import { Build } from "./Build";
import { Commit } from "./Commit";
import { SpinnakerStage } from "./SpinnakerStage";
export { SpinnakerPipeline };

/**
 * Type SpinnakerPipeline
 * Generated class exposing Atomist Cortex.
 * Fluent builder style class for use in testing and query by example.
 */
class SpinnakerPipeline implements spinnakerPipelineApi.SpinnakerPipeline {

    private _application: string;
    private _builds: Build[];
    private _commit: Commit;
    private _eventType: string;
    private _executionId: string;
    private _stageName: string;
    private _stageType: string;
    private _stages: SpinnakerStage[];
    private _taskName: string;
    private _waitingForJudgement: boolean;

    private _nodeName = "SpinnakerPipeline";
    private _nodeTags = [ "SpinnakerPipeline", "-dynamic" ];

    /**
     * Implementation of GraphNode interface method.
     * For infrastructure, not user use
     */
    public nodeName(): string {
        return this._nodeName;
    }

    /**
     * Implementation of GraphNode interface method.
     * For infrastructure, not user use
     */
    public nodeTags(): string[] {
        return this._nodeTags;
    }

    /**
     * application
     *
     * @property {string} application
     */
    get application(): string {
        if (this._application === undefined) {
            throw new Error(`Please use the relevant builder method to set property [application] on stub ` +
                `[SpinnakerPipeline] before accessing it. It's probably called [withApplication]`);
        }
        return this._application;
    }

    /**
     * Fluent builder method to set the application property
     */
    public withApplication(application_: string) {
        this._application = application_;
        return this;
    }

    /**
     * builds - SpinnakerPipeline -> Build
     *
     * @property {Build[]} builds
     */
    get builds(): Build[] {
        if (this._builds === undefined) {
            throw new Error(`Please use the relevant builder method to set property [builds] on stub ` +
                `[SpinnakerPipeline] before accessing it. It's probably called [withBuilds]`);
        }
        return this._builds;
    }

    /**
     * Fluent builder method to add an element to the builds array
     */
    public addBuilds(...builds_: Build[]) {
        if (this._builds === undefined) {
            this._builds = [];
        }
        this._builds = this._builds.concat(builds_);
        return this;
    }

    /**
     * commit - SpinnakerPipeline -> Commit
     *
     * @property {Commit} commit
     */
    get commit(): Commit {
        if (this._commit === undefined) {
            throw new Error(`Please use the relevant builder method to set property [commit] on stub ` +
                `[SpinnakerPipeline] before accessing it. It's probably called [withCommit]`);
        }
        return this._commit;
    }

    /**
     * Fluent builder method to set the commit property
     */
    public withCommit(commit_: Commit) {
        this._commit = commit_;
        return this;
    }

    /**
     * eventType
     *
     * @property {string} eventType
     */
    get eventType(): string {
        if (this._eventType === undefined) {
            throw new Error(`Please use the relevant builder method to set property [eventType] on stub ` +
                `[SpinnakerPipeline] before accessing it. It's probably called [withEventType]`);
        }
        return this._eventType;
    }

    /**
     * Fluent builder method to set the eventType property
     */
    public withEventType(eventType_: string) {
        this._eventType = eventType_;
        return this;
    }

    /**
     * executionId
     *
     * @property {string} executionId
     */
    get executionId(): string {
        if (this._executionId === undefined) {
            throw new Error(`Please use the relevant builder method to set property [executionId] on stub ` +
                `[SpinnakerPipeline] before accessing it. It's probably called [withExecutionId]`);
        }
        return this._executionId;
    }

    /**
     * Fluent builder method to set the executionId property
     */
    public withExecutionId(executionId_: string) {
        this._executionId = executionId_;
        return this;
    }

    /**
     * stageName
     *
     * @property {string} stageName
     */
    get stageName(): string {
        if (this._stageName === undefined) {
            throw new Error(`Please use the relevant builder method to set property [stageName] on stub ` +
                `[SpinnakerPipeline] before accessing it. It's probably called [withStageName]`);
        }
        return this._stageName;
    }

    /**
     * Fluent builder method to set the stageName property
     */
    public withStageName(stageName_: string) {
        this._stageName = stageName_;
        return this;
    }

    /**
     * stageType
     *
     * @property {string} stageType
     */
    get stageType(): string {
        if (this._stageType === undefined) {
            throw new Error(`Please use the relevant builder method to set property [stageType] on stub ` +
                `[SpinnakerPipeline] before accessing it. It's probably called [withStageType]`);
        }
        return this._stageType;
    }

    /**
     * Fluent builder method to set the stageType property
     */
    public withStageType(stageType_: string) {
        this._stageType = stageType_;
        return this;
    }

    /**
     * stages - SpinnakerPipeline -> SpinnakerStage
     *
     * @property {SpinnakerStage[]} stages
     */
    get stages(): SpinnakerStage[] {
        if (this._stages === undefined) {
            throw new Error(`Please use the relevant builder method to set property [stages] on stub ` +
                `[SpinnakerPipeline] before accessing it. It's probably called [withStages]`);
        }
        return this._stages;
    }

    /**
     * Fluent builder method to add an element to the stages array
     */
    public addStages(...stages_: SpinnakerStage[]) {
        if (this._stages === undefined) {
            this._stages = [];
        }
        this._stages = this._stages.concat(stages_);
        return this;
    }

    /**
     * taskName
     *
     * @property {string} taskName
     */
    get taskName(): string {
        if (this._taskName === undefined) {
            throw new Error(`Please use the relevant builder method to set property [taskName] on stub ` +
                `[SpinnakerPipeline] before accessing it. It's probably called [withTaskName]`);
        }
        return this._taskName;
    }

    /**
     * Fluent builder method to set the taskName property
     */
    public withTaskName(taskName_: string) {
        this._taskName = taskName_;
        return this;
    }

    /**
     * waitingForJudgement
     *
     * @property {boolean} waitingForJudgement
     */
    get waitingForJudgement(): boolean {
        if (this._waitingForJudgement === undefined) {
            throw new Error(`Please use the relevant builder method to set property [waitingForJudgement] on stub ` +
                `[SpinnakerPipeline] before accessing it. It's probably called [withWaitingForJudgement]`);
        }
        return this._waitingForJudgement;
    }

    /**
     * Fluent builder method to set the waitingForJudgement property
     */
    public withWaitingForJudgement(waitingForJudgement_: boolean) {
        this._waitingForJudgement = waitingForJudgement_;
        return this;
    }

}
