diff options
author | Carmi Grushko <carmi@google.com> | 2016-07-14 23:52:41 +0000 |
---|---|---|
committer | Dmitry Lomov <dslomov@google.com> | 2016-07-15 13:31:35 +0000 |
commit | 49a65368c918b815f30aa3c412a9b7e5f83d8b3f (patch) | |
tree | e47e64b0898388f0121b877d50f333124ee7151a /src/main/java/com/google/devtools/build/lib/cmdline | |
parent | 937cb800767178b245587276d81d17b94384e44b (diff) |
java_proto_library: add support for avoiding generating code for protos that are already compiled into a proto runtime.
--
MOS_MIGRATED_REVID=127489419
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/cmdline')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/cmdline/Label.java | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/cmdline/Label.java b/src/main/java/com/google/devtools/build/lib/cmdline/Label.java index 9ca11b6e07..65f0ce867d 100644 --- a/src/main/java/com/google/devtools/build/lib/cmdline/Label.java +++ b/src/main/java/com/google/devtools/build/lib/cmdline/Label.java @@ -13,6 +13,7 @@ // limitations under the License. package com.google.devtools.build.lib.cmdline; +import com.google.common.base.Function; import com.google.common.collect.ComparisonChain; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Interner; @@ -28,11 +29,11 @@ import com.google.devtools.build.lib.util.Preconditions; import com.google.devtools.build.lib.util.StringCanonicalizer; import com.google.devtools.build.lib.util.StringUtilities; import com.google.devtools.build.lib.vfs.PathFragment; - import java.io.IOException; import java.io.InvalidObjectException; import java.io.ObjectInputStream; import java.io.Serializable; +import javax.annotation.Nullable; /** * A class to identify a BUILD target. All targets belong to exactly one package. The name of a @@ -143,6 +144,15 @@ public final class Label implements Comparable<Label>, Serializable, SkylarkPrin return parseAbsoluteUnchecked(absName, true); } + /** A long way to say '(String) s -> parseAbsoluteUnchecked(s)'. */ + public static final Function<String, Label> PARSE_ABSOLUTE_UNCHECKED = + new Function<String, Label>() { + @Override + public Label apply(@Nullable String s) { + return s == null ? null : parseAbsoluteUnchecked(s); + } + }; + /** * Factory for Labels from separate components. * @@ -341,14 +351,6 @@ public final class Label implements Comparable<Label>, Serializable, SkylarkPrin return packageIdentifier.getPackageFragment(); } - public static final com.google.common.base.Function<Label, PathFragment> PACKAGE_FRAGMENT = - new com.google.common.base.Function<Label, PathFragment>() { - @Override - public PathFragment apply(Label label) { - return label.getPackageFragment(); - } - }; - /** * Returns the label as a path fragment, using the package and the label name. */ |