public class InstanceContainerImpl<E extends Entity> extends java.lang.Object implements InstanceContainer<E>, HasLoader, ItemPropertyChangeNotifier
InstanceContainer.ItemChangeEvent<T extends Entity>, InstanceContainer.ItemPropertyChangeEvent<T extends Entity>
Modifier and Type | Field and Description |
---|---|
protected MetaClass |
entityMetaClass |
protected EventHub |
events |
protected E |
item |
protected Instance.PropertyChangeListener |
listener |
protected boolean |
listenersEnabled |
protected DataLoader |
loader |
protected View |
view |
Constructor and Description |
---|
InstanceContainerImpl(MetaClass entityMetaClass) |
Modifier and Type | Method and Description |
---|---|
Subscription |
addItemChangeListener(java.util.function.Consumer<InstanceContainer.ItemChangeEvent<E>> listener)
Adds listener to
InstanceContainer.ItemChangeEvent s. |
Subscription |
addItemPropertyChangeListener(java.util.function.Consumer<InstanceContainer.ItemPropertyChangeEvent<E>> listener)
Adds listener to
InstanceContainer.ItemPropertyChangeEvent s. |
protected void |
attachListener(Instance entity) |
protected void |
detachListener(Instance entity) |
protected void |
fireItemChanged(E prevItem) |
MetaClass |
getEntityMetaClass()
Returns the meta-class of entities that can be stored in the container.
|
E |
getItem()
Returns the contained entity instance.
|
E |
getItemOrNull()
Returns the contained entity instance or null if there is no entity in the container.
|
DataLoader |
getLoader()
Returns the loader of this container.
|
View |
getView()
Returns the view which was set by previous call to
InstanceContainer.setView(View) . |
void |
itemPropertyChanged(Instance.PropertyChangeEvent e) |
void |
mute()
Disables all event listeners on container data change.
|
void |
setItem(E item)
Sets the given entity instance to the container.
|
void |
setLoader(DataLoader loader)
Sets the loader for this container.
|
void |
setView(View view)
Sets a view to be used when loading entities for this container.
|
java.lang.String |
toString() |
void |
unmute()
Enables all event listeners.
|
protected MetaClass entityMetaClass
protected View view
protected EventHub events
protected Instance.PropertyChangeListener listener
protected DataLoader loader
protected boolean listenersEnabled
public InstanceContainerImpl(MetaClass entityMetaClass)
@Nullable public E getItemOrNull()
InstanceContainer
getItemOrNull
in interface InstanceContainer<E extends Entity>
@Nonnull public E getItem()
InstanceContainer
getItem
in interface InstanceContainer<E extends Entity>
public void setItem(@Nullable E item)
InstanceContainer
setItem
in interface InstanceContainer<E extends Entity>
public MetaClass getEntityMetaClass()
InstanceContainer
getEntityMetaClass
in interface InstanceContainer<E extends Entity>
@Nullable public View getView()
InstanceContainer
InstanceContainer.setView(View)
.
The view is normally used when loading entities for this container.getView
in interface InstanceContainer<E extends Entity>
public void setView(View view)
InstanceContainer
setView
in interface InstanceContainer<E extends Entity>
public Subscription addItemPropertyChangeListener(java.util.function.Consumer<InstanceContainer.ItemPropertyChangeEvent<E>> listener)
InstanceContainer
InstanceContainer.ItemPropertyChangeEvent
s.addItemPropertyChangeListener
in interface InstanceContainer<E extends Entity>
public Subscription addItemChangeListener(java.util.function.Consumer<InstanceContainer.ItemChangeEvent<E>> listener)
InstanceContainer
InstanceContainer.ItemChangeEvent
s.addItemChangeListener
in interface InstanceContainer<E extends Entity>
protected void attachListener(Instance entity)
protected void detachListener(Instance entity)
public java.lang.String toString()
toString
in class java.lang.Object
@Nullable public DataLoader getLoader()
HasLoader
public void setLoader(DataLoader loader)
HasLoader
protected void fireItemChanged(E prevItem)
public void itemPropertyChanged(Instance.PropertyChangeEvent e)
itemPropertyChanged
in interface ItemPropertyChangeNotifier
public void mute()
InstanceContainer
InstanceContainer.unmute()
for bulk data modification as a perfomance optimization.mute
in interface InstanceContainer<E extends Entity>
public void unmute()
InstanceContainer
unmute
in interface InstanceContainer<E extends Entity>