PL-9799 Inherit WebAbstractComponent from EventRouter

This commit is contained in:
Yuriy Artamonov 2017-09-30 22:26:20 +04:00
parent ee36c4ad1c
commit d9a3aa91df
2 changed files with 5 additions and 10 deletions

View File

@ -26,9 +26,9 @@ import java.util.function.BiConsumer;
* Generic Event router with lazily initialized events map.
*/
@NotThreadSafe
public final class EventRouter {
protected static final int EVENTS_MAP_EXPECTED_MAX_SIZE = 4;
protected static final int EVENTS_LIST_INITIAL_CAPACITY = 2;
public class EventRouter {
private static final int EVENTS_MAP_EXPECTED_MAX_SIZE = 4;
private static final int EVENTS_LIST_INITIAL_CAPACITY = 2;
// Map with listener classes and listener lists
// Lists are created on demand

View File

@ -36,6 +36,7 @@ import java.util.Collections;
import java.util.List;
public abstract class WebAbstractComponent<T extends com.vaadin.ui.AbstractComponent>
extends EventRouter
implements Component, Component.Wrapper, Component.HasXmlDescriptor, Component.BelongToFrame, Component.HasIcon,
Component.HasCaption {
@ -56,19 +57,13 @@ public abstract class WebAbstractComponent<T extends com.vaadin.ui.AbstractCompo
protected Alignment alignment = Alignment.TOP_LEFT;
protected String icon;
private EventRouter eventRouter;
/**
* Use EventRouter for listeners instead of fields with listeners List.
*
* @return lazily initialized {@link EventRouter} instance.
* @see EventRouter
*/
protected EventRouter getEventRouter() {
if (eventRouter == null) {
eventRouter = new EventRouter();
}
return eventRouter;
return this;
}
@Override