Class SymbolicValue.SymEnum

java.lang.Object
net.sourceforge.pmd.lang.java.symbols.SymbolicValue.SymEnum
All Implemented Interfaces:
SymbolicValue
Enclosing interface:
SymbolicValue

public static final class SymbolicValue.SymEnum extends Object implements SymbolicValue
Symbolic representation of an enum constant.
  • Method Details

    • toEnum

      public <E extends Enum<E>> @Nullable E toEnum(Class<E> enumClass)
      If this enum constant is declared in the given enum class, returns its value. Otherwise returns null.
      Type Parameters:
      E - Return type
      Parameters:
      enumClass - Class of an enum
    • fromEnum

      public static SymbolicValue fromEnum(TypeSystem ts, Enum<?> value)
      Returns the symbolic value for the given enum constant.
      Parameters:
      ts - Type system
      value - An enum constant
      Throws:
      NullPointerException - if the parameter is null
    • fromBinaryName

      public static SymbolicValue.SymEnum fromBinaryName(TypeSystem ts, String enumBinaryName, String enumConstName)
      Parameters:
      ts - Type system
      enumBinaryName - A binary name, eg com.MyEnum
      enumConstName - Simple name of the enum constant
      Throws:
      NullPointerException - if any parameter is null
    • fromTypeDescriptor

      public static SymbolicValue.SymEnum fromTypeDescriptor(TypeSystem ts, String enumTypeDescriptor, String enumConstName)
      Parameters:
      ts - Type system
      enumTypeDescriptor - The type descriptor, eg Lcom/MyEnum;
      enumConstName - Simple name of the enum constant
    • valueEquals

      public boolean valueEquals(Object o)
      Description copied from interface: SymbolicValue
      Returns true if this symbolic value represents the same value as the given object. If the parameter is null, returns false.
      Specified by:
      valueEquals in interface SymbolicValue
    • equals

      public boolean equals(Object o)
      Description copied from interface: SymbolicValue
      Returns true if this value is equal to the other one. The parameter must be a SymbolicValue of the same type. Use SymbolicValue.valueEquals(Object) to compare to a java object.
      Specified by:
      equals in interface SymbolicValue
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object