diff options
author | Googler <noreply@google.com> | 2015-04-07 16:24:07 +0000 |
---|---|---|
committer | Damien Martin-Guillerez <dmarting@google.com> | 2015-04-08 08:46:18 +0000 |
commit | e1b7f7710a654fe64ea3796f5d30f5b71bd7b010 (patch) | |
tree | 9c01d2deea7d5353d30c6b5aaec05c03480131e2 | |
parent | dfe43a2b1dd75a270edc2f8d2ab498e19dec6f8a (diff) |
Switch to @AutoValue for RuleDefintion.Metadata now that it is available.
--
MOS_MIGRATED_REVID=90516252
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/analysis/AutoValueRuleDefinitionMetadata.java | 180 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/analysis/RuleDefinition.java | 5 |
2 files changed, 4 insertions, 181 deletions
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 53568899fe..0000000000 --- a/src/main/java/com/google/devtools/build/lib/analysis/AutoValueRuleDefinitionMetadata.java +++ /dev/null @@ -1,180 +0,0 @@ -// Copyright 2014 Google Inc. 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 77670d567a..92e55a925c 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); |