public abstract class BaseEvent extends Object implements Event
| Modifier and Type | Field and Description |
|---|---|
protected EventClonePolicy |
clonePolicy
Event clone policy.
|
static int |
DEFAULT_PRIORITY
Default event priority.
|
protected String |
id
Event ID.
|
protected String |
name
Event name.
|
protected Instant |
time
Event creation time.
|
| Modifier | Constructor and Description |
|---|---|
protected |
BaseEvent(String name,
EventClonePolicy clonePolicy)
Creates a new event that has no ID and time set (both are 0).
|
| Modifier and Type | Method and Description |
|---|---|
BaseEvent |
clone() |
protected abstract <T> T |
doGet(String name,
boolean useDefault,
T defaultValue) |
boolean |
equalsByAttributes(Event event)
Compares events by attributes.
|
boolean |
equalsById(Event event)
Compares events by ID.
|
<T> T |
get(String name)
Returns the attribute value or throws
IllegalArgumentException if it does't exist. |
<T> T |
get(String name,
Class<T> cls)
Returns attribute value.
|
protected <T> T |
getDefaultAttributeValue(String name,
boolean useDefault,
T defaultValue) |
String |
getId()
Returns event ID.
|
String |
getName()
Returns event name.
|
<T> T |
getOrDefault(String name,
T defaultValue) |
int |
getPriority()
Returns event priority.
|
Instant |
getTime()
Returns event time.
|
void |
setId(String id)
Sets event ID.
|
void |
setTime(Instant time)
Sets event time.
|
String |
toString() |
protected String |
toStringBase() |
protected void |
valudateAttribute(String name,
Object value) |
public static final int DEFAULT_PRIORITY
0.protected String id
protected Instant time
protected String name
protected EventClonePolicy clonePolicy
protected BaseEvent(String name, EventClonePolicy clonePolicy)
name - an event name.clonePolicy - an event clone policy.public String getName()
public Instant getTime()
public void setTime(Instant time)
public String getId()
public void setId(String id)
public int getPriority()
0 for standard events and cannot be changed.getPriority in interface HasPriority<Event>protected abstract <T> T doGet(String name, boolean useDefault, T defaultValue)
protected final <T> T getDefaultAttributeValue(String name, boolean useDefault, T defaultValue)
public final <T> T get(String name)
IllegalArgumentException if it does't exist.public final <T> T getOrDefault(String name, T defaultValue)
getOrDefault in interface Eventpublic boolean equalsById(Event event)
equalsById in interface Eventevent - compared event.true if both events are equal by ID.public boolean equalsByAttributes(Event event)
equalsByAttributes in interface Eventevent - compared event.true if both events are equal by attributes.public BaseEvent clone()
protected final String toStringBase()
Copyright © 2016–2018 Softelnet. All rights reserved.