Home » openjdk-7 » javax.lang » model » element » [javadoc | source]
javax.lang.model.element
public enum class: NestingKind [javadoc | source]
java.lang.Enum
   javax.lang.model.element.NestingKind
The nesting kind of a type element. Type elements come in four varieties: top-level, member, local, and anonymous. Nesting kind is a non-standard term used here to denote this classification.

Note that it is possible additional nesting kinds will be added in future versions of the platform.

Example: The classes below are annotated with their nesting kind.


import java.lang.annotation.*;
import static java.lang.annotation.RetentionPolicy.*;
import javax.lang.model.element.*;
import static javax.lang.model.element.NestingKind.*;

@Nesting(TOP_LEVEL)
public class NestingExamples {
    @Nesting(MEMBER)
    static class MemberClass1{}

    @Nesting(MEMBER)
    class MemberClass2{}

    public static void main(String... argv) {
        @Nesting(LOCAL)
        class LocalClass{};

        Class<?>[] classes = {
            NestingExamples.class,
            MemberClass1.class,
            MemberClass2.class,
            LocalClass.class
        };

        for(Class<?> clazz : classes) {
            System.out.format("%s is %s%n",
                              clazz.getName(),
                              clazz.getAnnotation(Nesting.class).value());
        }
    }
}

@Retention(RUNTIME)
@interface Nesting {
    NestingKind value();
}
Field Summary
public  NestingKind TOP_LEVEL     
public  NestingKind MEMBER     
public  NestingKind LOCAL     
public  NestingKind ANONYMOUS     
Method from javax.lang.model.element.NestingKind Summary:
isNested
Method from javax.lang.model.element.NestingKind Detail:
 public boolean isNested() 
    Does this constant correspond to a nested type element? A nested type element is any that is not top-level. An inner type element is any nested type element that is not {@linkplain Modifier#STATIC static}.