3.12. Inner Classes

Methods on inner classes can be annotated with Exemplars just the same as those in top-level classes.

For non-static inner classes, it’s necessary to pass an instance of the outer class as the first parameter. For instance:

class Foo {

    public Foo() {

    class InnerFoo {

        private int x;

        @Exemplar(name="InnerFoo/1", args={"Foo/1"})
        public InnerFoo() {

            this.x = -1;

        @Exemplar(name="InnerFoo/2", args={"Foo/1", "5"})
        public InnerFoo(int x) {

            this.x = x;

        @Exemplar(instance="InnerFoo/2", expect="5")
        public int getX() {

            return x;

Note that currently it is not possible to annotate methods of anonymous classes with Exemplars.

Previous Page   |   Next Page   |   Table of Contents

Comments are closed.