Subversion Repository Public Repository

litesoft

Diff Revisions 949 vs 950 for /trunk/Java/GWT/OldClient/src/org/litesoft/GWT/eventbus/client/EventSubscriptionCollector.java

Diff revisions: vs.
  @@ -1,76 +1,76 @@
1 - // This Source Code is in the Public Domain per: http://unlicense.org
2 - package org.litesoft.GWT.eventbus.client;
3 -
4 - import java.util.*;
5 -
6 - public class EventSubscriptionCollector {
7 - /**
8 - * Add a handler to be triggered for the events of the given name.
9 - *
10 - * @param pEventName - nonNull
11 - * @param pListener - nonNull
12 - */
13 - public final EventSubscriptionCollector subscribe( String pEventName, EventPackageListener pListener ) {
14 - LLsubscribe( new EventSimpleSubscriptionStructure( pEventName, pListener ) );
15 - return this;
16 - }
17 -
18 - /**
19 - * Add a handler to be triggered for the events of the given name from pSubscriber.
20 - *
21 - * @param pSubscriber - null ignored
22 - */
23 - public final EventSubscriptionCollector subscribe( EventPackageSubscriber pSubscriber ) {
24 - if ( pSubscriber != null ) {
25 - LLsubscribe( new EventSubscriberStructure( pSubscriber ) );
26 - }
27 - return this;
28 - }
29 -
30 - /**
31 - * Add a handler to be triggered for the events of the given name from pStructure.
32 - *
33 - * @param pStructure - null ignored
34 - */
35 - public final EventSubscriptionCollector subscribe( EventSubscriptionStructure pStructure ) {
36 - if ( pStructure != null ) {
37 - LLsubscribe( pStructure );
38 - }
39 - return this;
40 - }
41 -
42 - /**
43 - * Add handlers to be triggered for the events of the given name from the pStructures.
44 - *
45 - * @param pStructures - null/ ignored
46 - */
47 - public final synchronized EventSubscriptionCollector subscribe(
48 - EventSubscriptionStructure[] pStructures ) {
49 - if ( pStructures != null ) {
50 - for ( int i = 0; i < pStructures.length; i++ ) {
51 - subscribe( pStructures[i] );
52 - }
53 - }
54 - return this;
55 - }
56 -
57 - /**
58 - * @return !null, and no nulls in array
59 - */
60 - public final synchronized EventSubscriptionStructure[] getSubscriptions() {
61 - if ( mSubscriptions.isEmpty() ) {
62 - return EventSubscriptionStructure.EMPTY_ARRAY;
63 - }
64 - EventSubscriptionStructure[] rv = new EventSubscriptionStructure[mSubscriptions.size()];
65 - for ( int i = 0; i < mSubscriptions.size(); i++ ) {
66 - rv[i] = mSubscriptions.get( i );
67 - }
68 - return rv;
69 - }
70 -
71 - private List<EventSubscriptionStructure> mSubscriptions = new ArrayList<EventSubscriptionStructure>();
72 -
73 - private synchronized void LLsubscribe( EventSubscriptionStructure pSubscription ) {
74 - mSubscriptions.add( pSubscription );
75 - }
76 - }
1 + // This Source Code is in the Public Domain per: http://unlicense.org
2 + package org.litesoft.GWT.eventbus.client;
3 +
4 + import java.util.*;
5 +
6 + public class EventSubscriptionCollector {
7 + /**
8 + * Add a handler to be triggered for the events of the given name.
9 + *
10 + * @param pEventName - nonNull
11 + * @param pListener - nonNull
12 + */
13 + public final EventSubscriptionCollector subscribe( String pEventName, EventPackageListener pListener ) {
14 + LLsubscribe( new EventSimpleSubscriptionStructure( pEventName, pListener ) );
15 + return this;
16 + }
17 +
18 + /**
19 + * Add a handler to be triggered for the events of the given name from pSubscriber.
20 + *
21 + * @param pSubscriber - null ignored
22 + */
23 + public final EventSubscriptionCollector subscribe( EventPackageSubscriber pSubscriber ) {
24 + if ( pSubscriber != null ) {
25 + LLsubscribe( new EventSubscriberStructure( pSubscriber ) );
26 + }
27 + return this;
28 + }
29 +
30 + /**
31 + * Add a handler to be triggered for the events of the given name from pStructure.
32 + *
33 + * @param pStructure - null ignored
34 + */
35 + public final EventSubscriptionCollector subscribe( EventSubscriptionStructure pStructure ) {
36 + if ( pStructure != null ) {
37 + LLsubscribe( pStructure );
38 + }
39 + return this;
40 + }
41 +
42 + /**
43 + * Add handlers to be triggered for the events of the given name from the pStructures.
44 + *
45 + * @param pStructures - null/ ignored
46 + */
47 + public final synchronized EventSubscriptionCollector subscribe(
48 + EventSubscriptionStructure[] pStructures ) {
49 + if ( pStructures != null ) {
50 + for ( int i = 0; i < pStructures.length; i++ ) {
51 + subscribe( pStructures[i] );
52 + }
53 + }
54 + return this;
55 + }
56 +
57 + /**
58 + * @return !null, and no nulls in array
59 + */
60 + public final synchronized EventSubscriptionStructure[] getSubscriptions() {
61 + if ( mSubscriptions.isEmpty() ) {
62 + return EventSubscriptionStructure.EMPTY_ARRAY;
63 + }
64 + EventSubscriptionStructure[] rv = new EventSubscriptionStructure[mSubscriptions.size()];
65 + for ( int i = 0; i < mSubscriptions.size(); i++ ) {
66 + rv[i] = mSubscriptions.get( i );
67 + }
68 + return rv;
69 + }
70 +
71 + private List<EventSubscriptionStructure> mSubscriptions = new ArrayList<EventSubscriptionStructure>();
72 +
73 + private synchronized void LLsubscribe( EventSubscriptionStructure pSubscription ) {
74 + mSubscriptions.add( pSubscription );
75 + }
76 + }