/*
 * Copyright 2014-present Facebook, 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.
 */

package com.facebook.buck.android;

import com.facebook.buck.io.ProjectFilesystem;
import com.facebook.buck.model.BuildTarget;
import com.facebook.buck.rules.BuildRule;
import com.facebook.buck.rules.BuildRuleParams;
import com.facebook.buck.rules.SourcePath;
import com.facebook.buck.rules.SourcePathRuleFinder;
import com.facebook.buck.rules.TestBuildRuleParams;
import com.facebook.buck.testutil.FakeProjectFilesystem;
import com.google.common.collect.ImmutableSortedMap;
import com.google.common.collect.ImmutableSortedSet;
import java.nio.file.Path;

public class AndroidResourceRuleBuilder {

  private AndroidResourceRuleBuilder() {
    // Utility class
  }

  public static Builder newBuilder() {
    return new Builder();
  }

  public static class Builder {

    private SourcePathRuleFinder ruleFinder;
    private ProjectFilesystem projectFilesystem = new FakeProjectFilesystem();
    private BuildRuleParams buildRuleParams;
    private ImmutableSortedSet<BuildRule> deps = ImmutableSortedSet.of();
    private SourcePath res;
    private ImmutableSortedMap<Path, SourcePath> resSrcs = ImmutableSortedMap.of();
    private String rDotJavaPackage;
    private SourcePath assets;
    private ImmutableSortedMap<Path, SourcePath> assetsSrcs = ImmutableSortedMap.of();
    private SourcePath manifest;
    private boolean hasWhitelistedStrings = false;

    public AndroidResource build() {
      return new AndroidResource(
          projectFilesystem,
          buildRuleParams,
          ruleFinder,
          deps,
          res,
          resSrcs,
          rDotJavaPackage,
          assets,
          assetsSrcs,
          manifest,
          hasWhitelistedStrings);
    }

    public Builder setBuildRuleParams(BuildRuleParams params) {
      this.buildRuleParams = params;
      return this;
    }

    public Builder setRuleFinder(SourcePathRuleFinder ruleFinder) {
      this.ruleFinder = ruleFinder;
      return this;
    }

    public Builder setBuildTarget(BuildTarget buildTarget) {
      buildRuleParams = TestBuildRuleParams.create(buildTarget);
      return this;
    }

    public Builder setDeps(ImmutableSortedSet<BuildRule> deps) {
      this.deps = deps;
      return this;
    }

    public Builder setRes(SourcePath res) {
      this.res = res;
      return this;
    }

    public Builder setResSrcs(ImmutableSortedMap<Path, SourcePath> resSrcs) {
      this.resSrcs = resSrcs;
      return this;
    }

    public Builder setRDotJavaPackage(String rDotJavaPackage) {
      this.rDotJavaPackage = rDotJavaPackage;
      return this;
    }

    public Builder setAssets(SourcePath assets) {
      this.assets = assets;
      return this;
    }

    public Builder setAssetsSrcs(ImmutableSortedMap<Path, SourcePath> assetsSrcs) {
      this.assetsSrcs = assetsSrcs;
      return this;
    }

    public Builder setManifest(SourcePath manifest) {
      this.manifest = manifest;
      return this;
    }
  }
}

@@ -773,56 +773,8 @@
 le;%0A
-import com.facebook.buck.rules.BuildRuleParams;%0A
 impo
@@ -812,16 +812,16 @@
 cePath;%0A
+
 import c
@@ -1466,34 +1466,26 @@
 uild
-RuleParams buildRuleParams
+Target buildTarget
 ;%0A  
@@ -2013,25 +2013,29 @@
 ,%0A          
-b
+TestB
 uildRulePara
@@ -2036,16 +2036,36 @@
 leParams
+.create(buildTarget)
 ,%0A      
@@ -2262,135 +2262,8 @@
  %7D%0A%0A
-    public Builder setBuildRuleParams(BuildRuleParams params) %7B%0A      this.buildRuleParams = params;%0A      return this;%0A    %7D%0A%0A
     
@@ -2459,53 +2459,27 @@
     
-buildRuleParams = TestBuildRuleParams.create(
+this.buildTarget = 
 buil
@@ -2485,17 +2485,16 @@
 ldTarget
-)
 ;%0A      

Store BuildTarget not BuildRuleParams