/*
 * Copyright 2013-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.model.BuildTarget;
import com.facebook.buck.rules.AbstractDescriptionArg;
import com.facebook.buck.rules.BuildRuleParams;
import com.facebook.buck.rules.BuildRuleResolver;
import com.facebook.buck.rules.CellPathResolver;
import com.facebook.buck.rules.Description;
import com.facebook.buck.rules.SourcePath;
import com.facebook.buck.rules.TargetGraph;
import com.facebook.infer.annotation.SuppressFieldNotInitialized;
import com.google.common.collect.ImmutableSortedSet;

public class GenAidlDescription implements Description<GenAidlDescription.Arg> {

  @Override
  public Class<Arg> getConstructorArgType() {
    return Arg.class;
  }

  @Override
  public GenAidl createBuildRule(
      TargetGraph targetGraph,
      BuildRuleParams params,
      BuildRuleResolver resolver,
      CellPathResolver cellRoots,
      Arg args) {
    return new GenAidl(params, args.aidl, args.importPath);
  }

  @SuppressFieldNotInitialized
  public static class Arg extends AbstractDescriptionArg {
    public SourcePath aidl;

    // import_path is an anomaly: it is a path that is relative to the project root rather than
    // relative to the build file directory.
    public String importPath;

    public ImmutableSortedSet<BuildTarget> deps = ImmutableSortedSet.of();
  }
}

@@ -640,107 +640,8 @@
 d;%0A%0A
-import com.facebook.buck.model.BuildTarget;%0Aimport com.facebook.buck.rules.AbstractDescriptionArg;%0A
 impo
@@ -814,27 +814,128 @@
 k.rules.
-Description
+CommonDescriptionArg;%0Aimport com.facebook.buck.rules.Description;%0Aimport com.facebook.buck.rules.HasDeclaredDeps
 ;%0Aimport
@@ -1039,105 +1039,82 @@
 ook.
-infer.annotation.SuppressFieldNotInitialized;%0Aimport com.google.common.collect.ImmutableSortedSet
+buck.util.immutables.BuckStyleImmutable;%0Aimport org.immutables.value.Value
 ;%0A%0Ap
@@ -1185,17 +1185,16 @@
 cription
-.
 Arg%3E %7B%0A%0A
@@ -1220,16 +1220,34 @@
 c Class%3C
+GenAidlDescription
 Arg%3E get
@@ -1280,16 +1280,34 @@
  return 
+GenAidlDescription
 Arg.clas
@@ -1495,16 +1495,34 @@
 ,%0A      
+GenAidlDescription
 Arg args
@@ -1565,20 +1565,28 @@
 rgs.
-a
+getA
 idl
+()
 , args.
-i
+getI
 mpor
@@ -1590,16 +1590,18 @@
 portPath
+()
 );%0A  %7D%0A%0A
@@ -1607,58 +1607,84 @@
 %0A  @
-SuppressFieldNotInitialized%0A  public static class 
+BuckStyleImmutable%0A  @Value.Immutable%0A  interface AbstractGenAidlDescription
 Arg 
@@ -1691,24 +1691,22 @@
 extends 
-Abstract
+Common
 Descript
@@ -1715,21 +1715,31 @@
 nArg
- %7B%0A    public
+, HasDeclaredDeps %7B%0A   
  Sou
@@ -1750,12 +1750,17 @@
 ath 
-a
+getA
 idl
+()
 ;%0A%0A 
@@ -1907,106 +1907,28 @@
     
-public String importPath;%0A%0A    public ImmutableSortedSet%3CBuildTarget%3E deps = ImmutableSortedSet.of
+String getImportPath
 ();%0A

Convert gen_aidl Arg to be Immutable