// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.api.application.v4.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.yahoo.vespa.hosted.controller.api.identifiers.GitBranch;
import com.yahoo.vespa.hosted.controller.api.identifiers.GitCommit;
import com.yahoo.vespa.hosted.controller.api.identifiers.GitRepository;

import java.util.Objects;

/**
 * Additional options to be sent along the application package and the application test package
 * when submitting an application to the controller
 *
 * @author freva
 */
@JsonIgnoreProperties(ignoreUnknown = true)
public class SubmitOptions {

    public GitRepository gitRepository;
    public GitBranch gitBranch;
    public GitCommit gitCommit;

    public static SubmitOptions from(String repository, String branch, String commit) {
        SubmitOptions options = new SubmitOptions();
        options.gitRepository = new GitRepository(repository);
        options.gitBranch = new GitBranch(branch);
        options.gitCommit = new GitCommit(commit);
        return options;
    }

    @Override
    public String toString() {
        return "SubmitOptions{" +
                "gitRepository=" + gitRepository +
                ", gitBranch=" + gitBranch +
                ", gitCommit=" + gitCommit +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        SubmitOptions that = (SubmitOptions) o;
        return Objects.equals(gitRepository, that.gitRepository) &&
                Objects.equals(gitBranch, that.gitBranch) &&
                Objects.equals(gitCommit, that.gitCommit);
    }

    @Override
    public int hashCode() {
        return Objects.hash(gitRepository, gitBranch, gitCommit);
    }
}

@@ -754,20 +754,17 @@
 ository 
-gitR
+r
 epositor
@@ -787,20 +787,17 @@
 tBranch 
-gitB
+b
 ranch;%0A 
@@ -816,20 +816,17 @@
 tCommit 
-gitC
+c
 ommit;%0A%0A
@@ -982,20 +982,17 @@
 options.
-gitR
+r
 epositor
@@ -1042,20 +1042,17 @@
 options.
-gitB
+b
 ranch = 
@@ -1090,20 +1090,17 @@
 options.
-gitC
+c
 ommit = 
@@ -1249,20 +1249,17 @@
        %22
-gitR
+r
 epositor
@@ -1264,20 +1264,17 @@
 ory=%22 + 
-gitR
+r
 epositor
@@ -1296,20 +1296,17 @@
      %22, 
-gitB
+b
 ranch=%22 
@@ -1307,20 +1307,17 @@
 nch=%22 + 
-gitB
+b
 ranch +%0A
@@ -1335,20 +1335,17 @@
      %22, 
-gitC
+c
 ommit=%22 
@@ -1346,20 +1346,17 @@
 mit=%22 + 
-gitC
+c
 ommit +%0A
@@ -1616,20 +1616,17 @@
 .equals(
-gitR
+r
 epositor
@@ -1633,20 +1633,17 @@
 y, that.
-gitR
+r
 epositor
@@ -1679,20 +1679,17 @@
 .equals(
-gitB
+b
 ranch, t
@@ -1692,20 +1692,17 @@
 h, that.
-gitB
+b
 ranch) &
@@ -1734,20 +1734,17 @@
 .equals(
-gitC
+c
 ommit, t
@@ -1747,20 +1747,17 @@
 t, that.
-gitC
+c
 ommit);%0A
@@ -1837,12 +1837,9 @@
 ash(
-gitR
+r
 epos
@@ -1849,23 +1849,17 @@
 ry, 
-gitB
+b
 ranch, 
-gitC
+c
 ommi

Update SubmitOptions to match SourceRevision