Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This

...

page

...

exists

...

so

...

that

...

we

...

can

...

discuss

...

the

...

on-going

...

@ListenerList

...

implementation.

...

Basic

...

Usage

...

This

...

example

...

shows

...

the

...

most

...

basic

...

usage

...

of

...

the

...

@ListenerList

...

annotation.

...

The

...

easiest

...

way

...

to

...

use

...

this

...

annotation

...

is

...

to

...

annotate

...

a

...

field

...

of

...

type

...

List

...

and

...

give

...

the

...

List

...

a

...

generic

...

type.

...

In

...

this

...

example

...

we

...

use

...

a

...

List

...

of

...

type

...

MyListener.

...

MyListener

...

is

...

a

...

one

...

method

...

interface

...

that

...

takes

...

a

...

MyEvent

...

as

...

a

...

parameter.

...

The

...

following

...

code

...

is

...

some

...

sample

...

source

...

code

...

showing

...

the

...

simplest

...

scenario.

...

}
Code Block
{code}
interface MyListener {
    void eventOccurred(MyEvent event)
}
class MyEvent {    def source
    String message

    TestEvent(def source, String message) {
        this.source = source
        this.message = message
    }
}
class MyBeanClass {
    @ListenerList
    List<MyListener> listeners
}
{code}
* + 
  • + addMyListener(MyListener)

...

  • :

...

  • void

...

  • -

...

  • This

...

  • method

...

  • is

...

  • created

...

  • based

...

  • on

...

  • the

...

  • generic

...

  • type

...

  • of

...

  • your

...

  • annotated

...

  • List

...

  • field.

...

  • The

...

  • name

...

  • and

...

  • parameter

...

  • type

...

  • is

...

  • are

...

  • based

...

  • on

...

  • the

...

  • List

...

  • field's

...

  • generic

...

  • parameter.

...

  • +

...

  • removeMyListener(MyListener)

...

  • :

...

  • void

...

  • -

...

  • This

...

  • method

...

  • is

...

  • created

...

  • based

...

  • on

...

  • the

...

  • generic

...

  • type

...

  • of

...

  • your

...

  • annotated

...

  • List

...

  • field.

...

  • The

...

  • name

...

  • and

...

  • parameter

...

  • type

...

  • is

...

  • are

...

  • based

...

  • on

...

  • the

...

  • List

...

  • field's

...

  • generic

...

  • parameter.

...

  • +

...

  • getMyListeners()

...

  • :

...

  • MyListener

...

  • [

...

  • ]

...

  • -

...

  • This

...

  • method

...

  • is

...

  • created

...

  • based

...

  • on

...

  • the

...

  • generic

...

  • type

...

  • of

...

  • your

...

  • annotated

...

  • List

...

  • field.The

...

  • name

...

  • is

...

  • the

...

  • plural

...

  • form

...

  • of

...

  • the

...

  • List

...

  • field's

...

  • generic

...

  • parameter,

...

  • and

...

  • the

...

  • return

...

  • type

...

  • is

...

  • an

...

  • array

...

  • of

...

  • the

...

  • generic

...

  • parameter.

...

  • +

...

  • fireEventOccurred(MyEvent)

...

  • :

...

  • void

...

  • -

...

  • This

...

  • method

...

  • is

...

  • created

...

  • based

...

  • on

...

  • the

...

  • type

...

  • that

...

  • the

...

  • List's

...

  • generic

...

  • type

...

  • points

...

  • to.

...

  • In

...

  • this

...

  • case,

...

  • MyListener

...

  • is

...

  • a

...

  • one

...

  • method

...

  • interface

...

  • with

...

  • an

...

  • eventOccurred(MyEvent)

...

  • method.

...

  • The

...

  • method

...

  • name

...

  • is

...

  • fire

...

  • [MethodName

...

  • of

...

  • the

...

  • interface

...

  • ]

...

  • and

...

  • the

...

  • parameter

...

  • is

...

  • the

...

  • parameter

...

  • list

...

  • from

...

  • the

...

  • interface.

...

  • (Note:

...

  • what

...

  • happens

...

  • where

...

  • there

...

  • are

...

  • two

...

  • parameters

...

  • on

...

  • the

...

  • method?)

...

  • +

...

  • fireEventOccurred(Object,

...

  • String)

...

  • :

...

  • void

...

  • -

...

  • This

...

  • should

...

  • be

...

  • removed

...

  • as

...

  • it

...

  • is

...

  • too

...

  • complex

...

  • to

...

  • generate

...

  • a

...

  • proper

...

  • parameter

...

  • list.

...

  • What

...

  • if

...

  • the

...

  • object

...

  • has

...

  • 2

...

  • constructors?

...

  • Are

...

  • there

...

  • two

...

  • methods

...

  • generated?

...

  • 10

...

  • constructors

...

  • =

...

  • 10

...

  • methods?

...

  • Yuck.

...


  • Gets turned into:
    Code Block
    
    public class MyBeanClass {
    
        @groovy.beans.ListenerList
        private List<MyListener> listeners
    
        public void addMyListener(MyListener listener) {
            if ( listeners == null) { listeners = [] }
            listeners.add(listener)
        }
    
        public void removeMyListener(MyListener listener) {
            if ( listeners == null) { listeners = [] }
            listeners.remove(listener)
        }
    
        public MyListener[] getMyListeners() {
            def __result = []
            if ( listeners != null) {
                __result.addAll(listeners)
            }
            __result as MyListener[]
        }
    
        public void fireEventOccurred(MyEvent p0) {
            if ( listeners != null) {
                def __list = new ArrayList(listeners)
                for (listener : __list ) {
                    listener.eventOccurred(p0)
                }
            }
        }
    
        public void fireEventOccurred(java.lang.Object p0, java.lang.String p1) {
            if ( listeners != null) {
                def __list = new ArrayList(listeners)
                for (listener : __list ) {
                    listener.eventOccurred(new MyEvent(p0, p1))
                }
            }
        }
    }
    

...

  • Notes

...

  • -

...

  • 1)

...

  • add

...

  • listener

...

  • and

...

  • remove

...

  • listener

...

  • have

...

  • conflicting

...

  • code.

...

  • There

...

  • is

...

  • a

...

  • guard

...

  • clause

...

  • that

...

  • returns

...

  • null

...

  • when

...

  • parameter

...

  • is

...

  • null

...

  • and

...

  • a

...

  • guard

...

  • clause

...

  • that

...

  • lazy

...

  • instantiates

...

  • the

...

  • listener.

...

  • Can't

...

  • have

...

  • both.

...

  • 2)

...

  • The

...

  • fireEvent

...

  • methods

...

  • do

...

  • not

...

  • seem

...

  • to

...

  • be

...

  • part

...

  • of

...

  • the

...

  • bean

...

  • spec.

...

  • To

...

  • simplify,

...

  • let's

...

  • remove

...

  • the

...

  • 2nd

...

  • one

...

  • with

...

  • 2

...

  • parameters.

...

Next Example

This example shows the basic usage of the @ListenerList annotation.

Code Block
class TestEvent {
    def source
    String message

    TestEvent(def source, String message) {
        this.source = source
        this.message = message
    }
}

interface TestListener {
    void eventOccurred(TestEvent event)
}
class TestClass {
     @ListenerList(listener = TestListener, event = TestEvent)
     def listeners
}
{code}

Gets

...

turned

...

into:

...

}
Code Block
public class TestClass1 {

    @groovy.beans.ListenerList(event = TestEvent, listener = TestListener)
    private Object listeners

    public void addTestListener(TestListener listener) {
        if ( listeners == null) { listeners = [] }
        listeners.add(listener)
    }

    public void removeTestListener(TestListener listener) {
        if ( listeners == null) { listeners = [] }
        listeners.remove(listener)
    }

    public TestListener[] getTestListeners() {
        def __result = []
        if ( listeners != null) {
            __result.addAll(listeners)
        }
        return  __result as TestListener[]
    }

    public void fireEventOccurred(TestEvent p0) {
        if ( listeners != null) {
            def __list = new ArrayList(listeners)
            for (listener : __list ) {
                listener.eventOccurred(p0)
            }
        }
    }

    public void fireEventOccurred(java.lang.Object p0, java.lang.String p1) {
        if ( listeners != null) {
            def __list = new ArrayList(listeners)
            for (listener : __list ) {
                listener.eventOccurred(new TestEvent(p0, p1))
            }
        }
    }
}
{code}

h3. Advanced Examples

All of these examples assume the following:

{code}

Advanced Examples

All of these examples assume the following:

Code Block
import groovy.beans.*

/**
 * These test event is used as a sample event.
 */
class TestEvent {
    def source
    String message

    TestEvent(def source, String message) {
        this.source = source
        this.message = message
    }
}

class SomeOtherTestEvent {
    def source
    String message

    SomeOtherTestEvent(def source, String message) {
        this.source = source
        this.message = message
    }
}

/**
 * These interfaces are all used as variations on producing listener lists.
 */
interface TestListener {
    void eventOccurred(TestEvent event)
}

interface SomeOtherTestListener {
    void event2Occurred(SomeOtherTestEvent event)
}
ths
interface TestObjectListener {
  void eventOccurred(Object event)
}

interface TestListListener {
  void eventOccurred(List event)
}

interface TestMapListener {
  void eventOccurred(Map event)
}

interface TestTwoMethodListener {
  void eventOccurred1(TestEvent event)
  void eventOccurred2(TestEvent event)
}
{code}



This 

This example:

...

}
Code Block
class TestClass2 {
     @ListenerList(listener = TestListener, event = TestEvent, fire = "eventOccurred2", name = "someOtherTestListener")
     def listeners
}
{code}

Gets

...

turned

...

into:

...

}
Code Block
public class TestClass2 extends java.lang.Object {

    @groovy.beans.ListenerList(event = TestEvent, name = 'someOtherTestListener', listener = TestListener, fire = 'eventOccurred2')
    private java.lang.Object listeners

    public void addSomeOtherTestListener(TestListener listener) {
        if ( listener == null) {
            return null
        }
        if ( listeners == null) {
            listeners = []
        }
        listeners.add(listener)
    }

    public void removeSomeOtherTestListener(TestListener listener) {
        if ( listener == null) {
            return null
        }
        if ( listeners == null) {
            listeners = []
        }
        listeners.remove(listener)
    }

    public TestListener[] getSomeOtherTestListeners() {
        java.lang.Object __result = []
        if ( listeners != null) {
            __result.addAll(listeners)
        }
        return (( __result ) as TestListener[])
    }

    public void fireEventOccurred2(TestEvent p0) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(p0)
            }
        }
    }

    public void fireEventOccurred2(java.lang.Object p0, java.lang.String p1) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(new TestEvent(p0, p1))
            }
        }
    }

}
{code}

This

...

example:

...

}
Code Block
class TestClass3 {
     @ListenerList(listener = TestTwoMethodListener, event = TestEvent)
     def listeners
}
{code}

Gets

...

turned

...

into:

...

}
Code Block
public class TestClass3 extends java.lang.Object {

    @groovy.beans.ListenerList(event = TestEvent, listener = TestTwoMethodListener)
    private java.lang.Object listeners

    public void addTestTwoMethodListener(TestTwoMethodListener listener) {
        if ( listener == null) {
            return null
        }
        if ( listeners == null) {
            listeners = []
        }
        listeners.add(listener)
    }

    public void removeTestTwoMethodListener(TestTwoMethodListener listener) {
        if ( listener == null) {
            return null
        }
        if ( listeners == null) {
            listeners = []
        }
        listeners.remove(listener)
    }

    public TestTwoMethodListener[] getTestTwoMethodListeners() {
        java.lang.Object __result = []
        if ( listeners != null) {
            __result.addAll(listeners)
        }
        return (( __result ) as TestTwoMethodListener[])
    }

    public void fireEventOccurred1(TestEvent p0) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred1(p0)
            }
        }
    }

    public void fireEventOccurred1(java.lang.Object p0, java.lang.String p1) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred1(new TestEvent(p0, p1))
            }
        }
    }

    public void fireEventOccurred2(TestEvent p0) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred2(p0)
            }
        }
    }

    public void fireEventOccurred2(java.lang.Object p0, java.lang.String p1) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred2(new TestEvent(p0, p1))
            }
        }
    }

}
{code}

This

...

example:

...

}
Code Block
class TestClass4 {
     @ListenerList(listener = TestListener, event = TestEvent)
     def listeners
     @ListenerList(listener = TestListener, event = TestEvent, fire = "eventOccurred2->eventOccurred", name = "someOtherTestListener")
     def listeners2
}
{code}

Gets

...

turned

...

into:

...

}
Code Block
public class TestClass4 extends java.lang.Object {

    @groovy.beans.ListenerList(event = TestEvent, listener = TestListener)
    private java.lang.Object listeners
    @groovy.beans.ListenerList(event = TestEvent, name = 'someOtherTestListener', listener = TestListener, fire = 'eventOccurred2->eventOccurred')
    private java.lang.Object listeners2

    public void addTestListener(TestListener listener) {
        if ( listener == null) {
            return null
        }
        if ( listeners == null) {
            listeners = []
        }
        listeners.add(listener)
    }

    public void removeTestListener(TestListener listener) {
        if ( listener == null) {
            return null
        }
        if ( listeners == null) {
            listeners = []
        }
        listeners.remove(listener)
    }

    public TestListener[] getTestListeners() {
        java.lang.Object __result = []
        if ( listeners != null) {
            __result.addAll(listeners)
        }
        return (( __result ) as TestListener[])
    }

    public void fireEventOccurred(TestEvent p0) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(p0)
            }
        }
    }

    public void fireEventOccurred(java.lang.Object p0, java.lang.String p1) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(new TestEvent(p0, p1))
            }
        }
    }

    public void addSomeOtherTestListener(TestListener listener) {
        if ( listener == null) {
            return null
        }
        if ( listeners2 == null) {
            listeners2 = []
        }
        listeners2.add(listener)
    }

    public void removeSomeOtherTestListener(TestListener listener) {
        if ( listener == null) {
            return null
        }
        if ( listeners2 == null) {
            listeners2 = []
        }
        listeners2.remove(listener)
    }

    public TestListener[] getSomeOtherTestListeners() {
        java.lang.Object __result = []
        if ( listeners2 != null) {
            __result.addAll(listeners2)
        }
        return (( __result ) as TestListener[])
    }

    public void fireEventOccurred2(TestEvent p0) {
        if ( listeners2 != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners2)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(p0)
            }
        }
    }

    public void fireEventOccurred2(java.lang.Object p0, java.lang.String p1) {
        if ( listeners2 != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners2)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(new TestEvent(p0, p1))
            }
        }
    }

}
{code}

This

...

example:

...

}
Code Block
class TestClass5 {
     @ListenerList(listener = TestTwoMethodListener, event = TestEvent, fire = ["eventOccurred->eventOccurred1", "nextEventOccurred->eventOccurred2"])
     def listeners
}
{code}

Gets

...

turned

...

into:

...

}
Code Block
public class TestClass5 extends java.lang.Object {

    @groovy.beans.ListenerList(event = TestEvent, listener = TestTwoMethodListener, fire = ['eventOccurred->eventOccurred1', 'nextEventOccurred->eventOccurred2'])
    private java.lang.Object listeners

    public void addTestTwoMethodListener(TestTwoMethodListener listener) {
        if ( listener == null) {
            return null
        }
        if ( listeners == null) {
            listeners = []
        }
        listeners.add(listener)
    }

    public void removeTestTwoMethodListener(TestTwoMethodListener listener) {
        if ( listener == null) {
            return null
        }
        if ( listeners == null) {
            listeners = []
        }
        listeners.remove(listener)
    }

    public TestTwoMethodListener[] getTestTwoMethodListeners() {
        java.lang.Object __result = []
        if ( listeners != null) {
            __result.addAll(listeners)
        }
        return (( __result ) as TestTwoMethodListener[])
    }

    public void fireEventOccurred(TestEvent p0) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred1(p0)
            }
        }
    }

    public void fireEventOccurred(java.lang.Object p0, java.lang.String p1) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred1(new TestEvent(p0, p1))
            }
        }
    }

    public void fireNextEventOccurred(TestEvent p0) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred2(p0)
            }
        }
    }

    public void fireNextEventOccurred(java.lang.Object p0, java.lang.String p1) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred2(new TestEvent(p0, p1))
            }
        }
    }

}
{code}

This

...

example:

...

}
Code Block
class TestClass6 {
     @ListenerList(listener = TestMapListener, event = Map)
     def listeners
}
{code}

Gets

...

turned

...

into:

...

}
Code Block
public class TestClass6 extends java.lang.Object {

    @groovy.beans.ListenerList(event = java.util.Map, listener = TestMapListener)
    private java.lang.Object listeners

    public void addTestMapListener(TestMapListener listener) {
        if ( listener == null) {
            return null
        }
        if ( listeners == null) {
            listeners = []
        }
        listeners.add(listener)
    }

    public void removeTestMapListener(TestMapListener listener) {
        if ( listener == null) {
            return null
        }
        if ( listeners == null) {
            listeners = []
        }
        listeners.remove(listener)
    }

    public TestMapListener[] getTestMapListeners() {
        java.lang.Object __result = []
        if ( listeners != null) {
            __result.addAll(listeners)
        }
        return (( __result ) as TestMapListener[])
    }

    public void fireEventOccurred(java.util.Map p0) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(p0)
            }
        }
    }

}
{code}

This

...

example:

...

}
Code Block
class TestClass7 {
     @ListenerList(event = TestEvent, name = "testListener", fire = "eventOccurred")
     def listeners
}
{code}

Gets

...

turned

...

into:

...

}
Code Block
public class TestClass7 extends java.lang.Object {

    @groovy.beans.ListenerList(event = TestEvent, name = 'testListener', fire = 'eventOccurred')
    private java.lang.Object listeners

    public void addTestListener(java.util.Map<K extends java.lang.Object, V extends java.lang.Object> listener) {
        if ( listener == null) {
            return null
        }
        if ( listeners == null) {
            listeners = []
        }
        listeners.add(listener)
    }

    public void removeTestListener(java.util.Map<K extends java.lang.Object, V extends java.lang.Object> listener) {
        if ( listener == null) {
            return null
        }
        if ( listeners == null) {
            listeners = []
        }
        listeners.remove(listener)
    }

    public java.util.Map[] getTestListeners() {
        java.lang.Object __result = []
        if ( listeners != null) {
            __result.addAll(listeners)
        }
        return (( __result ) as java.util.Map[])
    }

    public void fireEventOccurred(TestEvent p0) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(p0)
            }
        }
    }

    public void fireEventOccurred(java.lang.Object p0, java.lang.String p1) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(new TestEvent(p0, p1))
            }
        }
    }

}
{code}

This

...

example:

...

}
Code Block
class TestClass8 {
     @ListenerList(event = TestEvent, name = "testListener", fire = ["eventOccurred", "eventOccurred2"])
     def listeners
}
{code}

Gets

...

turned

...

into:

...

}
Code Block
public class TestClass8 extends java.lang.Object {

    @groovy.beans.ListenerList(event = TestEvent, name = 'testListener', fire = ['eventOccurred', 'eventOccurred2'])
    private java.lang.Object listeners

    public void addTestListener(java.util.Map<K extends java.lang.Object, V extends java.lang.Object> listener) {
        if ( listener == null) {
            return null
        }
        if ( listeners == null) {
            listeners = []
        }
        listeners.add(listener)
    }

    public void removeTestListener(java.util.Map<K extends java.lang.Object, V extends java.lang.Object> listener) {
        if ( listener == null) {
            return null
        }
        if ( listeners == null) {
            listeners = []
        }
        listeners.remove(listener)
    }

    public java.util.Map[] getTestListeners() {
        java.lang.Object __result = []
        if ( listeners != null) {
            __result.addAll(listeners)
        }
        return (( __result ) as java.util.Map[])
    }

    public void fireEventOccurred(TestEvent p0) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(p0)
            }
        }
    }

    public void fireEventOccurred(java.lang.Object p0, java.lang.String p1) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(new TestEvent(p0, p1))
            }
        }
    }

    public void fireEventOccurred2(TestEvent p0) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred2(p0)
            }
        }
    }

    public void fireEventOccurred2(java.lang.Object p0, java.lang.String p1) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred2(new TestEvent(p0, p1))
            }
        }
    }

}
{code}

This

...

example:

...

}
Code Block
class TestClass9 {
     @ListenerList(name = "testListener", fire = "eventOccurred", event = Map)
     def listeners
}
{code}

Gets

...

turned

...

into:

...

}
Code Block
public class TestClass9 extends java.lang.Object {

    @groovy.beans.ListenerList(event = java.util.Map, name = 'testListener', fire = 'eventOccurred')
    private java.lang.Object listeners

    public void addTestListener(java.util.Map<K extends java.lang.Object, V extends java.lang.Object> listener) {
        if ( listener == null) {
            return null
        }
        if ( listeners == null) {
            listeners = []
        }
        listeners.add(listener)
    }

    public void removeTestListener(java.util.Map<K extends java.lang.Object, V extends java.lang.Object> listener) {
        if ( listener == null) {
            return null
        }
        if ( listeners == null) {
            listeners = []
        }
        listeners.remove(listener)
    }

    public java.util.Map[] getTestListeners() {
        java.lang.Object __result = []
        if ( listeners != null) {
            __result.addAll(listeners)
        }
        return (( __result ) as java.util.Map[])
    }

    public void fireEventOccurred(java.util.Map p0) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(p0)
            }
        }
    }

}
{code}

This

...

example:

...

}
Code Block
class TestClass10 {
     @ListenerList(listener = TestListListener)
     def listeners
}
{code}

Gets

...

turned

...

into:

...

}
Code Block
public class TestClass10 extends java.lang.Object {

    @groovy.beans.ListenerList(listener = TestListListener)
    private java.lang.Object listeners

    public void addTestListListener(TestListListener listener) {
        if ( listener == null) {
            return null
        }
        if ( listeners == null) {
            listeners = []
        }
        listeners.add(listener)
    }

    public void removeTestListListener(TestListListener listener) {
        if ( listener == null) {
            return null
        }
        if ( listeners == null) {
            listeners = []
        }
        listeners.remove(listener)
    }

    public TestListListener[] getTestListListeners() {
        java.lang.Object __result = []
        if ( listeners != null) {
            __result.addAll(listeners)
        }
        return (( __result ) as TestListListener[])
    }

    public void fireEventOccurred(java.util.List p0) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(p0)
            }
        }
    }

}
{code}

This

...

example:

...

}
Code Block
class TestClass11 {
     @ListenerList(listener = TestObjectListener)
     def listeners
}
{code}

Gets

...

turned

...

into:

...

}
Code Block
public class TestClass11 extends java.lang.Object {

    @groovy.beans.ListenerList(listener = TestObjectListener)
    private java.lang.Object listeners

    public void addTestObjectListener(TestObjectListener listener) {
        if ( listener == null) {
            return null
        }
        if ( listeners == null) {
            listeners = []
        }
        listeners.add(listener)
    }

    public void removeTestObjectListener(TestObjectListener listener) {
        if ( listener == null) {
            return null
        }
        if ( listeners == null) {
            listeners = []
        }
        listeners.remove(listener)
    }

    public TestObjectListener[] getTestObjectListeners() {
        java.lang.Object __result = []
        if ( listeners != null) {
            __result.addAll(listeners)
        }
        return (( __result ) as TestObjectListener[])
    }

    public void fireEventOccurred(java.lang.Object p0) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(p0)
            }
        }
    }

    public void fireEventOccurred() {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(new java.lang.Object())
            }
        }
    }

}
{code}

This

...

example:

...

}
Code Block
class TestClass12 {
     @ListenerList(event = String)
     List<TestObjectListener> listeners
}
{code}

Gets

...

turned

...

into:

...

}
Code Block
public class TestClass12 extends java.lang.Object {

    @groovy.beans.ListenerList(event = java.lang.String)
    private java.util.List<TestObjectListener> listeners

    public void addTestObjectListener(TestObjectListener listener) {
        if ( listener == null) {
            return null
        }
        if ( listeners == null) {
            listeners = []
        }
        listeners.add(listener)
    }

    public void removeTestObjectListener(TestObjectListener listener) {
        if ( listener == null) {
            return null
        }
        if ( listeners == null) {
            listeners = []
        }
        listeners.remove(listener)
    }

    public TestObjectListener[] getTestObjectListeners() {
        java.lang.Object __result = []
        if ( listeners != null) {
            __result.addAll(listeners)
        }
        return (( __result ) as TestObjectListener[])
    }

    public void fireEventOccurred(java.lang.String p0) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(p0)
            }
        }
    }

    public void fireEventOccurred() {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(new java.lang.String())
            }
        }
    }

    public void fireEventOccurred([C p0) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(new java.lang.String(p0))
            }
        }
    }

    public void fireEventOccurred([C p0, int p1, int p2) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(new java.lang.String(p0, p1, p2))
            }
        }
    }

    public void fireEventOccurred([I p0, int p1, int p2) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(new java.lang.String(p0, p1, p2))
            }
        }
    }

    public void fireEventOccurred([B p0, int p1, int p2, int p3) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(new java.lang.String(p0, p1, p2, p3))
            }
        }
    }

    public void fireEventOccurred([B p0, int p1) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(new java.lang.String(p0, p1))
            }
        }
    }

    public void fireEventOccurred([B p0, int p1, int p2, java.lang.String p3) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(new java.lang.String(p0, p1, p2, p3))
            }
        }
    }

    public void fireEventOccurred([B p0, int p1, int p2, java.nio.charset.Charset p3) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(new java.lang.String(p0, p1, p2, p3))
            }
        }
    }

    public void fireEventOccurred([B p0, java.lang.String p1) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(new java.lang.String(p0, p1))
            }
        }
    }

    public void fireEventOccurred([B p0, java.nio.charset.Charset p1) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(new java.lang.String(p0, p1))
            }
        }
    }

    public void fireEventOccurred([B p0, int p1, int p2) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(new java.lang.String(p0, p1, p2))
            }
        }
    }

    public void fireEventOccurred([B p0) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(new java.lang.String(p0))
            }
        }
    }

    public void fireEventOccurred(java.lang.StringBuffer p0) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(new java.lang.String(p0))
            }
        }
    }

    public void fireEventOccurred(java.lang.StringBuilder p0) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(new java.lang.String(p0))
            }
        }
    }

    public void fireEventOccurred(int p0, int p1, [C p2) {
        if ( listeners != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(listeners)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(new java.lang.String(p0, p1, p2))
            }
        }
    }

}
{code}

This

...

example:

...

}
Code Block
@ListenerList(listener = TestListener, event = TestEvent)
class TestClass14 {
}
{code}

Gets

...

turned

...

into:

...

}
Code Block
public class TestClass14 extends java.lang.Object {

    private java.util.List<E extends java.lang.Object> testListenerList

    public void addTestListener(TestListener listener) {
        if ( listener == null) {
            return null
        }
        if ( testListenerList == null) {
            testListenerList = []
        }
        testListenerList.add(listener)
    }

    public void removeTestListener(TestListener listener) {
        if ( listener == null) {
            return null
        }
        if ( testListenerList == null) {
            testListenerList = []
        }
        testListenerList.remove(listener)
    }

    public TestListener[] getTestListeners() {
        java.lang.Object __result = []
        if ( testListenerList != null) {
            __result.addAll(testListenerList)
        }
        return (( __result ) as TestListener[])
    }

    public void fireEventOccurred(TestEvent p0) {
        if ( testListenerList != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(testListenerList)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(p0)
            }
        }
    }

    public void fireEventOccurred(java.lang.Object p0, java.lang.String p1) {
        if ( testListenerList != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(testListenerList)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(new TestEvent(p0, p1))
            }
        }
    }

}
{code}

This

...

example:

...

}
Code Block
@ListenerList(listener = TestListener, event = TestEvent)
class TestClass15 {
     def testListenerList
}
{code}

Gets

...

turned

...

into:

...

}
Code Block
public class TestClass15 extends java.lang.Object {

    private java.lang.Object testListenerList

    public void addTestListener(TestListener listener) {
        if ( listener == null) {
            return null
        }
        if ( testListenerList == null) {
            testListenerList = []
        }
        testListenerList.add(listener)
    }

    public void removeTestListener(TestListener listener) {
        if ( listener == null) {
            return null
        }
        if ( testListenerList == null) {
            testListenerList = []
        }
        testListenerList.remove(listener)
    }

    public TestListener[] getTestListeners() {
        java.lang.Object __result = []
        if ( testListenerList != null) {
            __result.addAll(testListenerList)
        }
        return (( __result ) as TestListener[])
    }

    public void fireEventOccurred(TestEvent p0) {
        if ( testListenerList != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(testListenerList)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(p0)
            }
        }
    }

    public void fireEventOccurred(java.lang.Object p0, java.lang.String p1) {
        if ( testListenerList != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(testListenerList)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(new TestEvent(p0, p1))
            }
        }
    }

}
{code}

This

...

example:

...

}
Code Block
@ListenerList(listener = TestListener, event = TestEvent)
@ListenerList(listener = SomeOtherTestListener, event = SomeOtherTestEvent)
class TestClass16 {
}
{code}

Gets

...

turned

...

into:

...

}
Code Block
public class TestClass16 extends java.lang.Object {

    private java.util.List<E extends java.lang.Object> testListenerList
    private java.util.List<E extends java.lang.Object> someOtherTestListenerList

    public void addTestListener(TestListener listener) {
        if ( listener == null) {
            return null
        }
        if ( testListenerList == null) {
            testListenerList = []
        }
        testListenerList.add(listener)
    }

    public void removeTestListener(TestListener listener) {
        if ( listener == null) {
            return null
        }
        if ( testListenerList == null) {
            testListenerList = []
        }
        testListenerList.remove(listener)
    }

    public TestListener[] getTestListeners() {
        java.lang.Object __result = []
        if ( testListenerList != null) {
            __result.addAll(testListenerList)
        }
        return (( __result ) as TestListener[])
    }

    public void fireEventOccurred(TestEvent p0) {
        if ( testListenerList != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(testListenerList)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(p0)
            }
        }
    }

    public void fireEventOccurred(java.lang.Object p0, java.lang.String p1) {
        if ( testListenerList != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(testListenerList)
            for (java.lang.Object listener : __list ) {
                listener.eventOccurred(new TestEvent(p0, p1))
            }
        }
    }

    public void addSomeOtherTestListener(SomeOtherTestListener listener) {
        if ( listener == null) {
            return null
        }
        if ( someOtherTestListenerList == null) {
            someOtherTestListenerList = []
        }
        someOtherTestListenerList.add(listener)
    }

    public void removeSomeOtherTestListener(SomeOtherTestListener listener) {
        if ( listener == null) {
            return null
        }
        if ( someOtherTestListenerList == null) {
            someOtherTestListenerList = []
        }
        someOtherTestListenerList.remove(listener)
    }

    public SomeOtherTestListener[] getSomeOtherTestListeners() {
        java.lang.Object __result = []
        if ( someOtherTestListenerList != null) {
            __result.addAll(someOtherTestListenerList)
        }
        return (( __result ) as SomeOtherTestListener[])
    }

    public void fireEvent2Occurred(SomeOtherTestEvent p0) {
        if ( someOtherTestListenerList != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(someOtherTestListenerList)
            for (java.lang.Object listener : __list ) {
                listener.event2Occurred(p0)
            }
        }
    }

    public void fireEvent2Occurred(java.lang.Object p0, java.lang.String p1) {
        if ( someOtherTestListenerList != null) {
            java.util.ArrayList<E extends java.lang.Object> __list = new java.util.ArrayList<E extends java.lang.Object>(someOtherTestListenerList)
            for (java.lang.Object listener : __list ) {
                listener.event2Occurred(new SomeOtherTestEvent(p0, p1))
            }
        }
    }

}


{code}