aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main
diff options
context:
space:
mode:
authorGravatar Carmi Grushko <carmi@google.com>2016-04-08 14:14:56 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2016-04-08 14:34:55 +0000
commit97f8148005a8e974b9460c3c7b77d708b33a7e36 (patch)
treefff24e951a99d58ca1f7c8f3bb775bc03a5afe20 /src/main
parentfd308b61cc5a74eab583689a5d750cacab0a6124 (diff)
In RuleDefintion, use AutoValue and delete the checked-in generated code for it.
-- MOS_MIGRATED_REVID=119369970
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/google/devtools/build/lib/BUILD1
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/AutoValueRuleDefinitionMetadata.java180
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/RuleDefinition.java5
3 files changed, 5 insertions, 181 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/BUILD b/src/main/java/com/google/devtools/build/lib/BUILD
index 917a0a434c..e0e2e81490 100644
--- a/src/main/java/com/google/devtools/build/lib/BUILD
+++ b/src/main/java/com/google/devtools/build/lib/BUILD
@@ -491,6 +491,7 @@ java_library(
"//src/main/protobuf:extra_actions_base_java_proto",
"//src/main/protobuf:invocation_policy_java_proto",
"//src/main/protobuf:test_status_java_proto",
+ "//third_party:auto_value",
"//third_party:guava",
"//third_party:jsr305",
"//third_party/protobuf",
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/AutoValueRuleDefinitionMetadata.java b/src/main/java/com/google/devtools/build/lib/analysis/AutoValueRuleDefinitionMetadata.java
deleted file mode 100644
index a9e3f05a3e..0000000000
--- a/src/main/java/com/google/devtools/build/lib/analysis/AutoValueRuleDefinitionMetadata.java
+++ /dev/null
@@ -1,180 +0,0 @@
-// Copyright 2014 The Bazel Authors. All rights reserved.
-//
-// 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.
-
-/**
- * TODO(bazel-team): This file has been generated by @AutoValue, and copied here because we do not
- * support @AutoValue yet. Remove this file and add @AutoValue annotations to RuleDefinition
- * once possible.
- */
-package com.google.devtools.build.lib.analysis;
-
-import com.google.devtools.build.lib.packages.RuleClass.Builder.RuleClassType;
-import com.google.devtools.build.lib.rules.RuleConfiguredTargetFactory;
-
-import java.util.List;
-
-import javax.annotation.Generated;
-
-@Generated("com.google.auto.value.processor.AutoValueProcessor")
-final class AutoValueRuleDefinitionMetadata extends RuleDefinition.Metadata {
-
- private final String name;
- private final RuleClassType type;
- private final Class<? extends RuleConfiguredTargetFactory> factoryClass;
- private final List<Class<? extends RuleDefinition>> ancestors;
-
- private AutoValueRuleDefinitionMetadata(
- String name,
- RuleClassType type,
- Class<? extends RuleConfiguredTargetFactory> factoryClass,
- List<Class<? extends RuleDefinition>> ancestors) {
- if (name == null) {
- throw new NullPointerException("Null name");
- }
- this.name = name;
- if (type == null) {
- throw new NullPointerException("Null type");
- }
- this.type = type;
- if (factoryClass == null) {
- throw new NullPointerException("Null factoryClass");
- }
- this.factoryClass = factoryClass;
- if (ancestors == null) {
- throw new NullPointerException("Null ancestors");
- }
- this.ancestors = ancestors;
- }
-
- @Override
- public String name() {
- return name;
- }
-
- @Override
- public RuleClassType type() {
- return type;
- }
-
- @Override
- public Class<? extends RuleConfiguredTargetFactory> factoryClass() {
- return factoryClass;
- }
-
- @Override
- public List<Class<? extends RuleDefinition>> ancestors() {
- return ancestors;
- }
-
- @Override
- public String toString() {
- return "Metadata{"
- + "name=" + name + ", "
- + "type=" + type + ", "
- + "factoryClass=" + factoryClass + ", "
- + "ancestors=" + ancestors
- + "}";
- }
-
- @Override
- public boolean equals(Object o) {
- if (o == this) {
- return true;
- }
- if (o instanceof RuleDefinition.Metadata) {
- RuleDefinition.Metadata that = (RuleDefinition.Metadata) o;
- return (this.name.equals(that.name()))
- && (this.type.equals(that.type()))
- && (this.factoryClass.equals(that.factoryClass()))
- && (this.ancestors.equals(that.ancestors()));
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- int h = 1;
- h *= 1000003;
- h ^= name.hashCode();
- h *= 1000003;
- h ^= type.hashCode();
- h *= 1000003;
- h ^= factoryClass.hashCode();
- h *= 1000003;
- h ^= ancestors.hashCode();
- return h;
- }
-
- static final class Builder extends RuleDefinition.Metadata.Builder {
- private String name;
- private RuleClassType type;
- private Class<? extends RuleConfiguredTargetFactory> factoryClass;
- private List<Class<? extends RuleDefinition>> ancestors;
- Builder() {
- }
- Builder(RuleDefinition.Metadata source) {
- name(source.name());
- type(source.type());
- factoryClass(source.factoryClass());
- ancestors(source.ancestors());
- }
- @Override
- public RuleDefinition.Metadata.Builder name(String name) {
- this.name = name;
- return this;
- }
- @Override
- public RuleDefinition.Metadata.Builder type(RuleClassType type) {
- this.type = type;
- return this;
- }
- @Override
- public RuleDefinition.Metadata.Builder factoryClass(
- Class<? extends RuleConfiguredTargetFactory> factoryClass) {
- this.factoryClass = factoryClass;
- return this;
- }
- @Override
- public RuleDefinition.Metadata.Builder ancestors(
- List<Class<? extends RuleDefinition>> ancestors) {
- this.ancestors = ancestors;
- return this;
- }
- @Override
- public RuleDefinition.Metadata build() {
- String missing = "";
- if (name == null) {
- missing += " name";
- }
- if (type == null) {
- missing += " type";
- }
- if (factoryClass == null) {
- missing += " factoryClass";
- }
- if (ancestors == null) {
- missing += " ancestors";
- }
- if (!missing.isEmpty()) {
- throw new IllegalStateException("Missing required properties:" + missing);
- }
- RuleDefinition.Metadata result = new AutoValueRuleDefinitionMetadata(
- this.name,
- this.type,
- this.factoryClass,
- this.ancestors);
- return result;
- }
- }
-}
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/RuleDefinition.java b/src/main/java/com/google/devtools/build/lib/analysis/RuleDefinition.java
index 21fc1ee2b9..2096b2bd0a 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/RuleDefinition.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/RuleDefinition.java
@@ -14,6 +14,7 @@
package com.google.devtools.build.lib.analysis;
+import com.google.auto.value.AutoValue;
import com.google.devtools.build.lib.packages.RuleClass;
import com.google.devtools.build.lib.packages.RuleClass.Builder.RuleClassType;
import com.google.devtools.build.lib.rules.RuleConfiguredTargetFactory;
@@ -52,6 +53,7 @@ public interface RuleDefinition {
* Value class that contains the name, type, ancestors of a rule, as well as a reference to the
* configured target factory.
*/
+ @AutoValue
public abstract static class Metadata {
/**
* The name of the rule, as it appears in the BUILD file. If it starts with
@@ -78,7 +80,7 @@ public interface RuleDefinition {
public abstract List<Class<? extends RuleDefinition>> ancestors();
public static Builder builder() {
- return new AutoValueRuleDefinitionMetadata.Builder()
+ return new AutoValue_RuleDefinition_Metadata.Builder()
.type(RuleClassType.NORMAL)
.factoryClass(RuleConfiguredTargetFactory.class)
.ancestors(Collections.<Class<? extends RuleDefinition>>emptyList());
@@ -91,6 +93,7 @@ public interface RuleDefinition {
/**
* Builder class for the Metadata class.
*/
+ @AutoValue.Builder
public abstract static class Builder {
public abstract Builder name(String s);
public abstract Builder type(RuleClassType type);