Source:
<code>private BuildConfig mergeConfig(BuildConfig primary, BuildConfig secondary) { List<BuildStep> steps = primary.getSteps().isEmpty() ? secondary.getSteps() : primary.getSteps(); List<BuildStep> before = primary.getBefore().isEmpty() ? secondary.getBefore() : primary.getBefore(); <START> Optional<BuildConfig.PostBuildSteps> after = primary.getAfter().isPresent() ? primary.getAfter() : secondary.getAfter(); <END> Map<String, String> env = new LinkedHashMap<>(); env.putAll(secondary.getEnv()); env.putAll(primary.getEnv()); List<String> buildDeps = Lists.newArrayList(Iterables.concat(secondary.getBuildDeps(), primary.getBuildDeps())); List<String> webhooks = Lists.newArrayList(Iterables.concat(secondary.getWebhooks(), primary.getWebhooks())); List<String> cache = Lists.newArrayList(Iterables.concat(secondary.getCache(), primary.getCache())); final String user; if (primary.getUser().isPresent()) { user = primary.getUser().get(); } else if (secondary.getUser().isPresent()) { user = secondary.getUser().get(); } else { user = executorConfiguration.getDefaultBuildUser(); } Map<String, StepActivationCriteria> stepActivation = new LinkedHashMap<>(); stepActivation.putAll(secondary.getStepActivation()); stepActivation.putAll(primary.getStepActivation()); Set<Dependency> depends = new HashSet<>(); depends.addAll(primary.getDepends()); depends.addAll(secondary.getDepends()); Set<Dependency> provides = new HashSet<>(); provides.addAll(primary.getDepends()); provides.addAll(secondary.getDepends()); return new BuildConfig(steps, before, after, env, buildDeps, webhooks, cache, Optional.<GitInfo>absent(), Optional.of(user), stepActivation, depends, provides); }</code><technical_language>strategy because: a) allow arbitrarily nested configurations b) of A parent configurations set define core of build</technical_language>

Target:
private BuildConfig mergeConfig(BuildConfig primary, BuildConfig secondary) { List<BuildStep> steps = primary.getSteps().isEmpty() ? secondary.getSteps() : primary.getSteps(); List<BuildStep> before = primary.getBefore().isEmpty() ? secondary.getBefore() : primary.getBefore(); Optional<PostBuildSteps> after = (!primary.getAfter().isPresent()) ? secondary.getAfter() : primary.getAfter(); Map<String, String> env = new LinkedHashMap<>(); env.putAll(secondary.getEnv()); env.putAll(primary.getEnv()); List<String> buildDeps = Lists.newArrayList(Iterables.concat(secondary.getBuildDeps(), primary.getBuildDeps())); List<String> webhooks = Lists.newArrayList(Iterables.concat(secondary.getWebhooks(), primary.getWebhooks())); List<String> cache = Lists.newArrayList(Iterables.concat(secondary.getCache(), primary.getCache())); final String user; if (primary.getUser().isPresent()) { user = primary.getUser().get(); } else if (secondary.getUser().isPresent()) { user = secondary.getUser().get(); } else { user = executorConfiguration.getDefaultBuildUser(); } Map<String, StepActivationCriteria> stepActivation = new LinkedHashMap<>(); stepActivation.putAll(secondary.getStepActivation()); stepActivation.putAll(primary.getStepActivation()); Set<Dependency> depends = new HashSet<>(); depends.addAll(primary.getDepends()); depends.addAll(secondary.getDepends()); Set<Dependency> provides = new HashSet<>(); provides.addAll(primary.getDepends()); provides.addAll(secondary.getDepends()); return new BuildConfig(steps, before, after, env, buildDeps, webhooks, cache, Optional.<GitInfo>absent(), Optional.of(user), stepActivation, depends, provides); }