Package org.eclipse.jdt.annotation
Enum Class DefaultLocation
- All Implemented Interfaces:
Serializable,Comparable<DefaultLocation>,Constable
Locations that can be affected by a
NonNullByDefault annotation.
Each constant of this enum describes a specific kind of type use.
Wildcards and the use of type variables are always excluded from NonNullByDefault.- Since:
- 2.0
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionDefines that a givenNonNullByDefaultannotation should affect all unannotated array components within the scope of the annotated declaration.Defines that a givenNonNullByDefaultannotation should affect all unannotated field types within the scope of the annotated declaration.Defines that a givenNonNullByDefaultannotation should affect all unannotated parameters of any method or constructor within the scope of the annotated declaration.Defines that a givenNonNullByDefaultannotation should affect all unannotated record components within the scope of the annotated declaration.Defines that a givenNonNullByDefaultannotation should affect all unannotated method return types within the scope of the annotated declaration.Defines that a givenNonNullByDefaultannotation should affect all unannotated type arguments within the scope of the annotated declaration (except wildcards and type variables).Defines that a givenNonNullByDefaultannotation should affect all unannotated explicit type bounds within the scope of the annotated declaration.Defines that a givenNonNullByDefaultannotation should affect all unannotated type parameter declarations within the scope of the annotated declaration. -
Method Summary
Modifier and TypeMethodDescriptionstatic DefaultLocationReturns the enum constant of this class with the specified name.static DefaultLocation[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
PARAMETER
Defines that a givenNonNullByDefaultannotation should affect all unannotated parameters of any method or constructor within the scope of the annotated declaration.Example
@NonNullByDefault(PARAMETER) interface X { void print(Number n); }Here
Numberwill be interpreted as@NonNull Number. -
RETURN_TYPE
Defines that a givenNonNullByDefaultannotation should affect all unannotated method return types within the scope of the annotated declaration.Example
@NonNullByDefault(RETURN_TYPE) interface X { Number getNumber(); }Here
Numberwill be interpreted as@NonNull Number. -
FIELD
Defines that a givenNonNullByDefaultannotation should affect all unannotated field types within the scope of the annotated declaration.Example
@NonNullByDefault(FIELD) class X { Number number = Integer.MAX_VALUE; }Here
Numberwill be interpreted as@NonNull Number. -
TYPE_PARAMETER
Defines that a givenNonNullByDefaultannotation should affect all unannotated type parameter declarations within the scope of the annotated declaration.Example
@NonNullByDefault(TYPE_PARAMETER) class X { <T> T identity(T t) { return t; } }Here
<T>will be interpreted as<@NonNull T>. -
TYPE_BOUND
Defines that a givenNonNullByDefaultannotation should affect all unannotated explicit type bounds within the scope of the annotated declaration. A type bound of typeObjectis never considered as an explicit bound, i.e.,T extends Objectis never affected byNonNullByDefault.Example
@NonNullByDefault(TYPE_BOUND) interface X { <T extends Number> void process(T t, List<? super Number> l); }Here both occurrences of
Numberwill be interpreted as@NonNull Number. -
TYPE_ARGUMENT
Defines that a givenNonNullByDefaultannotation should affect all unannotated type arguments within the scope of the annotated declaration (except wildcards and type variables).Example
@NonNullByDefault(TYPE_ARGUMENT) interface X<T> { void process(List<T> tl, List<Number> nl); }Here
Numberwill be interpreted as@NonNull Number, but the use of type variableTis not affected. -
ARRAY_CONTENTS
Defines that a givenNonNullByDefaultannotation should affect all unannotated array components within the scope of the annotated declaration.Example
@NonNullByDefault(ARRAY_CONTENTS) interface X { Number[] n1; Number[][] n2; }These declarations are interpreted as:
@NonNull Number [] n1; @NonNull Number [] @NonNull[] n2;I.e., both fields can still be
null(see the unannotated left-most pair of brackets) but none of the contents of these arrays is allowed to benull(at any dimension). -
RECORD_COMPONENT
Defines that a givenNonNullByDefaultannotation should affect all unannotated record components within the scope of the annotated declaration.Example
@NonNullByDefault(RECORD_COMPONENT) record Person(String name) { }Here
Stringwill be interpreted as@NonNull String.- Since:
- 2.4
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified nameNullPointerException- if the argument is null
-