package com.hubspot.blazar.base;

import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;

@JsonIgnoreProperties(ignoreUnknown = true)
public class BuildConfig {
  private List<String> cmds;
  private final Optional<Map<String, String>> env;
  private final Optional<List<String>> buildDependencies;
  private final Optional<List<String>> buildDependents;
  private final Optional<Boolean> autoDeployQa;

  @JsonCreator
  public BuildConfig(@JsonProperty("cmds") Optional<List<String>> cmds,
                     @JsonProperty("env") Optional<Map<String, String>> env,
                     @JsonProperty("buildDependencies") Optional<List<String>> buildDependencies,
                     @JsonProperty("buildDependents") Optional<List<String>> buildDependents,
                     @JsonProperty("autoDeployQa") Optional<Boolean> autoDeployQa) {
    this.env = env;
    if (cmds.isPresent()) {
      this.cmds = cmds.get();
    } else{
      this.cmds = ImmutableList.of("runbuildpack");
    }
    this.buildDependencies = buildDependencies;
    this.buildDependents = buildDependents;
    this.autoDeployQa = autoDeployQa;
  }

  public List<String> getCmds() {
    return cmds;
  }

  public Optional<Map<String, String>> getEnv() {
    return env;
  }

  public Optional<List<String>> getBuildDependencies() {
    return buildDependencies;
  }

  public Optional<List<String>> getBuildDependents() {
    return buildDependents;
  }

  public Optional<Boolean> getAutoDeployQa() {
    return autoDeployQa;
  }

}

@@ -44,20 +44,27 @@
 va.util.
-List
+Collections
 ;%0Aimport
@@ -78,67 +78,119 @@
 til.
+Hash
 Map;%0A
-%0A
 import 
-com.fasterxml.jackson.annotation.JsonCreato
+java.util.List;%0Aimport java.util.Map;%0A%0Aimport javax.print.attribute.standard.MediaSize.Othe
 r;%0A
+%0A
 impo
@@ -229,32 +229,23 @@
 ion.Json
-IgnoreProperties
+Creator
 ;%0Aimport
@@ -292,16 +292,55 @@
 operty;%0A
+import com.google.common.base.Objects;%0A
 import c
@@ -424,52 +424,8 @@
 t;%0A%0A
-@JsonIgnoreProperties(ignoreUnknown = true)%0A
 publ
@@ -447,16 +447,17 @@
 onfig %7B%0A
+%0A
   privat
@@ -458,16 +458,22 @@
 private 
+final 
 List%3CStr
@@ -499,25 +499,16 @@
 e final 
-Optional%3C
 Map%3CStri
@@ -514,25 +514,24 @@
 ing, String%3E
-%3E
  env;%0A  priv
@@ -536,33 +536,24 @@
 ivate final 
-Optional%3C
 List%3CString%3E
@@ -544,33 +544,32 @@
 nal List%3CString%3E
-%3E
  buildDependenci
@@ -588,25 +588,16 @@
 e final 
-Optional%3C
 List%3CStr
@@ -592,33 +592,32 @@
 nal List%3CString%3E
-%3E
  buildDependents
@@ -638,38 +638,29 @@
 nal 
-Optional%3CBoolean%3E autoDeployQa
+List%3CString%3E webHooks
 ;%0A%0A 
@@ -712,33 +712,24 @@
 rty(%22cmds%22) 
-Optional%3C
 List%3CString%3E
@@ -728,17 +728,16 @@
 %3CString%3E
-%3E
  cmds,%0A 
@@ -777,25 +777,16 @@
 (%22env%22) 
-Optional%3C
 Map%3CStri
@@ -796,17 +796,16 @@
  String%3E
-%3E
  env,%0A  
@@ -854,33 +854,24 @@
 endencies%22) 
-Optional%3C
 List%3CString%3E
@@ -862,33 +862,32 @@
 s%22) List%3CString%3E
-%3E
  buildDependenci
@@ -944,25 +944,16 @@
 dents%22) 
-Optional%3C
 List%3CStr
@@ -956,17 +956,16 @@
 %3CString%3E
-%3E
  buildDe
@@ -1014,164 +1014,87 @@
 ty(%22
-autoDeployQa%22) Optional%3CBoolean%3E autoDeployQa) %7B%0A    this.env = env;%0A    if (cmds.isPresent()) %7B%0A      this.cmds = cmds.get();%0A    %7D else%7B%0A      this.
+webHooks%22) List%3CString%3E webHooks) %7B%0A%0A    this.cmds = Objects.firstNonNull(
 cmds
- =
+,
  Imm
@@ -1126,144 +1126,377 @@
 ck%22)
+)
 ;%0A    
-%7D%0A    this.buildDependencies = buildDependencies;%0A    this.buildDependents = buildDependents;%0A    this.autoDeployQa = autoDeployQa
+this.env = Objects.firstNonNull(env, Collections.%3CString,String%3EemptyMap());%0A    this.buildDependencies = Objects.firstNonNull(buildDependencies, Collections.%3CString%3EemptyList());%0A    this.buildDependents = Objects.firstNonNull(buildDependents, Collections.%3CString%3EemptyList());%0A    this.webHooks = Objects.firstNonNull(webHooks, Collections.%3CString%3EemptyList())
 ;%0A  
@@ -1563,25 +1563,16 @@
  public 
-Optional%3C
 Map%3CStri
@@ -1578,25 +1578,24 @@
 ing, String%3E
-%3E
  getEnv() %7B%0A
@@ -1620,33 +1620,24 @@
 %7D%0A%0A  public 
-Optional%3C
 List%3CString%3E
@@ -1628,33 +1628,32 @@
 lic List%3CString%3E
-%3E
  getBuildDepende
@@ -1706,25 +1706,16 @@
  public 
-Optional%3C
 List%3CStr
@@ -1718,17 +1718,16 @@
 %3CString%3E
-%3E
  getBuil
@@ -1788,41 +1788,32 @@
 lic 
-Optional%3CBoolean%3E getAutoDeployQa
+List%3CString%3E getWebHooks
 () %7B
@@ -1828,25 +1828,20 @@
 urn 
-autoDeployQa
+webHooks
 ;%0A  %7D%0A
-%0A
 %7D%0A

add webhooks feild, dont use optionals as much