View Javadoc
1   /*
2    * MIT License
3    * Copyright (c) 2006-2025 JMockit developers
4    * See LICENSE file for full license text.
5    */
6   package mockit.asm.constantPool;
7   
8   import edu.umd.cs.findbugs.annotations.NonNull;
9   
10  import org.checkerframework.checker.index.qual.NonNegative;
11  
12  public final class StringItem extends Item {
13      @NonNull
14      @SuppressWarnings("NullableProblems")
15      String strVal;
16  
17      StringItem() {
18          super(0);
19          strVal = "";
20      }
21  
22      public StringItem(@NonNegative int index, int type, @NonNull String strVal) {
23          super(index);
24          set(type, strVal);
25      }
26  
27      StringItem(@NonNegative int index, @NonNull StringItem item) {
28          super(index, item);
29          strVal = item.strVal;
30      }
31  
32      @NonNull
33      public String getValue() {
34          return strVal;
35      }
36  
37      /**
38       * Sets this string item value.
39       */
40      void set(int type, @NonNull String strVal) {
41          this.type = type;
42          this.strVal = strVal;
43          setHashCode(strVal.hashCode());
44      }
45  
46      @Override
47      boolean isEqualTo(@NonNull Item item) {
48          return ((StringItem) item).strVal.equals(strVal);
49      }
50  }