• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 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.
14 package com.google.devtools.build.android.desugar.scan;
15 
16 import static com.google.common.base.Preconditions.checkArgument;
17 
18 import com.google.auto.value.AutoValue;
19 import com.google.errorprone.annotations.Immutable;
20 
21 @AutoValue
22 @Immutable
23 abstract class KeepReference {
classReference(String internalName)24   public static KeepReference classReference(String internalName) {
25     checkArgument(!internalName.isEmpty());
26     return new AutoValue_KeepReference(internalName, "", "");
27   }
28 
memberReference(String internalName, String name, String desc)29   public static KeepReference memberReference(String internalName, String name, String desc) {
30     checkArgument(!internalName.isEmpty());
31     checkArgument(!name.isEmpty());
32     checkArgument(!desc.isEmpty());
33     return new AutoValue_KeepReference(internalName, name, desc);
34   }
35 
isMemberReference()36   public final boolean isMemberReference() {
37     return !name().isEmpty();
38   }
39 
isMethodReference()40   public final boolean isMethodReference() {
41     return desc().startsWith("(");
42   }
43 
isFieldReference()44   public final boolean isFieldReference() {
45     return isMemberReference() && !isMethodReference();
46   }
47 
internalName()48   public abstract String internalName();
name()49   public abstract String name();
desc()50   public abstract String desc();
51 }
52