• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2016 Google Inc. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.google.turbine.binder.bound;
18 
19 import com.google.turbine.model.Const;
20 import com.google.turbine.type.Type;
21 import java.util.Objects;
22 import org.jspecify.nullness.Nullable;
23 
24 /** A class literal constant. */
25 public class TurbineClassValue extends Const {
26 
27   private final Type type;
28 
TurbineClassValue(Type type)29   public TurbineClassValue(Type type) {
30     this.type = type;
31   }
32 
33   @Override
toString()34   public String toString() {
35     return String.format("%s.class", type);
36   }
37 
38   @Override
kind()39   public Kind kind() {
40     return Kind.CLASS_LITERAL;
41   }
42 
43   /** The class name. */
type()44   public Type type() {
45     return type;
46   }
47 
48   @Override
hashCode()49   public int hashCode() {
50     return Objects.hashCode(type);
51   }
52 
53   @Override
equals(@ullable Object obj)54   public boolean equals(@Nullable Object obj) {
55     return obj instanceof TurbineClassValue && type().equals(((TurbineClassValue) obj).type());
56   }
57 }
58