org.eclipse.jdt.annotation.DefaultLocation Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of org.eclipse.jdt.annotation Show documentation
Show all versions of org.eclipse.jdt.annotation Show documentation
JDT Annotations for Enhanced Null Analysis
/*******************************************************************************
* Copyright (c) 2014 Stephan Herrmann and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Stephan Herrmann - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.annotation;
/**
* Locations that can be affected by a {@link 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 {@link NonNullByDefault}.
* @since 2.0
*/
public enum DefaultLocation {
/**
* Defines that a given {@link NonNullByDefault} annotation 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 Number
will be interpreted as @NonNull Number
.
*
*/
PARAMETER,
/**
* Defines that a given {@link NonNullByDefault} annotation should affect all unannotated
* method return types within the scope of the annotated declaration.
*
* Example
* @NonNullByDefault(RETURN_TYPE)
* interface X {
* Number getNumber();
* }
*
* Here Number
will be interpreted as @NonNull Number
.
*
*/
RETURN_TYPE,
/**
* Defines that a given {@link NonNullByDefault} annotation should affect all unannotated
* field types within the scope of the annotated declaration.
*
* Example
* @NonNullByDefault(FIELD)
* class X {
* Number number = Integer.MAX_VALUE;
* }
*
* Here Number
will be interpreted as @NonNull Number
.
*
*/
FIELD,
/**
* Defines that a given {@link NonNullByDefault} annotation 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_PARAMETER,
/**
* Defines that a given {@link NonNullByDefault} annotation should affect all unannotated
* explicit type bounds within the scope of the annotated declaration. A type bound of
* type {@link java.lang.Object} is never considered as an explicit bound,
* i.e., T extends Object
is never affected by {@link NonNullByDefault}.
*
* Example
* @NonNullByDefault(TYPE_BOUND)
* interface X {
* <T extends Number> void process(T t, List<? super Number> l);
* }
*
* Here both occurrences of Number
will be interpreted as @NonNull Number
.
*
*/
TYPE_BOUND,
/**
* Defines that a given {@link NonNullByDefault} annotation 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 Number
will be interpreted as @NonNull Number
,
* but the use of type variable T
is not affected.
*
*/
TYPE_ARGUMENT,
/**
* Defines that a given {@link NonNullByDefault} annotation 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 be
* null
(at any dimension).
*
*/
ARRAY_CONTENTS
}