blob: 622efff4cbbafbc39faeef495d9c52b3d7444fdb [file] [log] [blame]
Janak Ramakrishnane9cd0f32016-04-29 22:46:16 +00001// Copyright 2016 The Bazel Authors. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.package com.google.devtools.build.lib.flags;
ccalvarinf39dc6f2017-06-09 11:51:45 -040014package com.google.devtools.common.options;
Janak Ramakrishnane9cd0f32016-04-29 22:46:16 +000015
16import com.google.common.collect.ImmutableSet;
17
18/** Cache mapping a command to the names of all commands it inherits from, including itself. */
Jonathan Bluett-Duncan0df3ddbd2017-08-09 11:13:54 +020019@FunctionalInterface
Janak Ramakrishnane9cd0f32016-04-29 22:46:16 +000020public interface CommandNameCache {
21 /** Class that exists only to expose a static instance variable that can be set and retrieved. */
22 class CommandNameCacheInstance implements CommandNameCache {
23 public static final CommandNameCacheInstance INSTANCE = new CommandNameCacheInstance();
24 private CommandNameCache delegate;
25
26 private CommandNameCacheInstance() {}
27
28 /** Only for use by {@code BlazeRuntime}. */
29 public void setCommandNameCache(CommandNameCache cache) {
30 // Can be set multiple times in tests.
31 this.delegate = cache;
32 }
33
34 @Override
35 public ImmutableSet<String> get(String commandName) {
36 return delegate.get(commandName);
37 }
38 }
39
40 /** Returns the names of all commands {@code commandName} inherits from, including itself. */
41 ImmutableSet<String> get(String commandName);
42}