1// Copyright 2017 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.
14package com.google.devtools.common.options;
15
16import javax.annotation.Nullable;
17
18/**
19 * Contains metadata describing the origin of an option. This includes its priority, a message about
20 * where it came from, and whether it was set explicitly or expanded/implied by other flags.
21 */
22public class OptionInstanceOrigin {
23  private final OptionPriority priority;
24  @Nullable private final String source;
25  @Nullable private final OptionDefinition implicitDependent;
26  @Nullable private final OptionDefinition expandedFrom;
27
28  public OptionInstanceOrigin(
29      OptionPriority priority,
30      String source,
31      OptionDefinition implicitDependent,
32      OptionDefinition expandedFrom) {
33    this.priority = priority;
34    this.source = source;
35    this.implicitDependent = implicitDependent;
36    this.expandedFrom = expandedFrom;
37  }
38
39  public OptionPriority getPriority() {
40    return priority;
41  }
42
43  @Nullable
44  public String getSource() {
45    return source;
46  }
47
48  @Nullable
49  public OptionDefinition getImplicitDependent() {
50    return implicitDependent;
51  }
52
53  @Nullable
54  public OptionDefinition getExpandedFrom() {
55    return expandedFrom;
56  }
57}
58