Package com.tonic.analysis.typeinference
Enum Nullability
- java.lang.Object
-
- java.lang.Enum<Nullability>
-
- com.tonic.analysis.typeinference.Nullability
-
- All Implemented Interfaces:
Serializable,Comparable<Nullability>
public enum Nullability extends Enum<Nullability>
Lattice of nullability states for a value, from BOTTOM (unreachable) up to UNKNOWN.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisDefinitelyNotNull()booleanisDefinitelyNull()Nullabilityjoin(Nullability other)Merges two states at a dataflow confluence, widening to UNKNOWN when they disagree.booleanmayBeNonNull()booleanmayBeNull()Nullabilitymeet(Nullability other)Narrows two states, falling to BOTTOM when they disagree.static NullabilityvalueOf(String name)Returns the enum constant of this type with the specified name.static Nullability[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
NULL
public static final Nullability NULL
Value is definitely null
-
NOT_NULL
public static final Nullability NOT_NULL
Value is definitely not null
-
UNKNOWN
public static final Nullability UNKNOWN
Value may be null or not null
-
BOTTOM
public static final Nullability BOTTOM
Bottom - no information (unreachable)
-
-
Method Detail
-
values
public static Nullability[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (Nullability c : Nullability.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static Nullability valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
join
public Nullability join(Nullability other)
Merges two states at a dataflow confluence, widening to UNKNOWN when they disagree.- Parameters:
other- the state to join with- Returns:
- the merged state
-
meet
public Nullability meet(Nullability other)
Narrows two states, falling to BOTTOM when they disagree.- Parameters:
other- the state to meet with- Returns:
- the narrowed state
-
mayBeNull
public boolean mayBeNull()
- Returns:
- true for NULL or UNKNOWN
-
mayBeNonNull
public boolean mayBeNonNull()
- Returns:
- true for NOT_NULL or UNKNOWN
-
isDefinitelyNull
public boolean isDefinitelyNull()
- Returns:
- true only for NULL
-
isDefinitelyNotNull
public boolean isDefinitelyNotNull()
- Returns:
- true only for NOT_NULL
-
-