= AbstractDomainEvent
:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR  CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Superclass for all domain events that are raised by the framework when interacting with actions, properties or collections.

The main purpose of the class is to define the protocol by which subscribers can influence an interaction (eg hide a collection, disable a property, validate action arguments).

The class also provides a simple mechanism to allow adhoc sharing of user data between different phases.

== API

[source,java]
.AbstractDomainEvent.java
----
class AbstractDomainEvent<S> {
  AbstractDomainEvent()     // <.>
  AbstractDomainEvent(S source)     // <.>
  AbstractDomainEvent(S source, Identifier identifier)
  S getSource()     // <.>
  void setMixedIn(Object mixedIn)     // <.>
  T getSubject()     // <.>
  void setEventPhase(Phase phase)     // <.>
  void setIdentifier(Identifier identifier)     // <.>
  void hide()     // <.>
  void hideIf(boolean condition)     // <.>
  void hideIf(BooleanSupplier shouldHide)     // <.>
  boolean isDisabled()
  void disable(String reason)     // <.>
  void disable(TranslatableString reason)     // <.>
  void disableIfReason(Supplier<String> reasonSupplier)     // <.>
  void disableIfTranslatableReason(Supplier<TranslatableString> reasonSupplier)     // <.>
  boolean isInvalid()
  void invalidate(String reason)     // <.>
  void invalidate(TranslatableString reason)     // <.>
  void invalidateIfReason(Supplier<String> reasonSupplier)     // <.>
  void invalidateIfTranslatableReason(Supplier<TranslatableString> reasonSupplier)     // <.>
  void veto(String reason, Object... args)     // <.>
  void veto(TranslatableString translatableReason)     // <.>
  Object get(Object key)     // <.>
  void put(Object key, Object value)     // <.>
  String toString()
}
----

<.> xref:#AbstractDomainEvent_[AbstractDomainEvent()]
+
--
If used then the framework will set state via (non-API) setters.
--
<.> xref:#AbstractDomainEvent_S[AbstractDomainEvent(S)]
+
--
If used then the framework will set the remaining state via (non-API) setters.
--
<.> xref:#getSource_[getSource()]
+
--
The domain object raising this event.
--
<.> xref:#setMixedIn_Object[setMixedIn(Object)]
+
--
Not API - set by the framework.
--
<.> xref:#getSubject_[getSubject()]
+
--
The subject of the event, which will be either the _#getSource() source_ for a regular action, or the _#getMixedIn() mixed-in_ domain object for a mixin.
--
<.> xref:#setEventPhase_Phase[setEventPhase(Phase)]
+
--
Not API, set by the framework.
--
<.> xref:#setIdentifier_Identifier[setIdentifier(Identifier)]
+
--
Not API, set by the framework if the no-arg constructor is used.
--
<.> xref:#hide_[hide()]
+
--
API for subscribers to hide the member.
--
<.> xref:#hideIf_boolean[hideIf(boolean)]
+
--
Same as ... _if(condition) hide();_
--
<.> xref:#hideIf_BooleanSupplier[hideIf(BooleanSupplier)]
+
--
Same as ... _if(shouldHide.getAsBoolean()) hide();_
--
<.> xref:#disable_String[disable(String)]
+
--
API for subscribers to disable the member, specifying the reason why.
--
<.> xref:#disable_TranslatableString[disable(TranslatableString)]
+
--
API for subscribers to disable the member, specifying the reason why as a xref:refguide:applib:index/services/i18n/TranslatableString.adoc[TranslatableString] .
--
<.> xref:#disableIfReason_Supplier[disableIfReason(Supplier)]
+
--
Same as ... _if(reasonSupplier.get()!=null) disable(reasonSupplier.get());_
--
<.> xref:#disableIfTranslatableReason_Supplier[disableIfTranslatableReason(Supplier)]
+
--
Same as ... _if(reasonSupplier.get()!=null) disable(reasonSupplier.get());_
--
<.> xref:#invalidate_String[invalidate(String)]
+
--
API for subscribers to invalidate an interaction, eg invalid arguments to an action.
--
<.> xref:#invalidate_TranslatableString[invalidate(TranslatableString)]
+
--
API for subscribers to invalidate an interaction, specifying the reason as a xref:refguide:applib:index/services/i18n/TranslatableString.adoc[TranslatableString] .
--
<.> xref:#invalidateIfReason_Supplier[invalidateIfReason(Supplier)]
+
--
Same as ... _if(reasonSupplier.get()!=null) invalidate(reasonSupplier.get());_
--
<.> xref:#invalidateIfTranslatableReason_Supplier[invalidateIfTranslatableReason(Supplier)]
+
--
Same as ... _if(reasonSupplier.get()!=null) invalidate(reasonSupplier.get());_
--
<.> xref:#veto_String_Object[veto(String, Object)]
+
--
Use instead of _#hide()_ , _#disable(String)_ and _#invalidate(String)_ ; just delegates to appropriate vetoing method based upon the _#getEventPhase() phase_ .
--
<.> xref:#veto_TranslatableString[veto(TranslatableString)]
+
--
Use instead of _#hide()_ , _#disable(org.apache.isis.applib.services.i18n.TranslatableString)_ and _#invalidate(org.apache.isis.applib.services.i18n.TranslatableString)_ ; just delegates to appropriate vetoing method based upon the _#getEventPhase() phase_ .
--
<.> xref:#get_Object[get(Object)]
+
--
Obtain user-data, as set by a previous _#getEventPhase() phase_ .
--
<.> xref:#put_Object_Object[put(Object, Object)]
+
--
Mechanism to allow subscribers to share arbitrary information between phases. One event instance is used for both the hide and disable phases, and a different event instance is shared between validate/pre-execute/post-execute. Set user-data, for the use of a subsequent _#getEventPhase() phase_ .
--

== Members

[#AbstractDomainEvent_]
=== AbstractDomainEvent()

If used then the framework will set state via (non-API) setters.

Because the xref:refguide:applib:index/events/EventObjectBase.adoc[EventObjectBase] superclass prohibits a null source, a dummy value is temporarily used.

[#AbstractDomainEvent_S]
=== AbstractDomainEvent(S)

If used then the framework will set the remaining state via (non-API) setters.

Provided to allow nested non-static implementations, for use in nested non-static mixins.

[#getSource_]
=== getSource()

The domain object raising this event.

For a "regular" action, property or collection then this will be the target domain object.

But for a "mixin" action, this will be an instance of the mixin itself.

[#setMixedIn_Object]
=== setMixedIn(Object)

Not API - set by the framework.

[#getSubject_]
=== getSubject()

The subject of the event, which will be either the _#getSource() source_ for a regular action, or the _#getMixedIn() mixed-in_ domain object for a mixin.

[#setEventPhase_Phase]
=== setEventPhase(Phase)

Not API, set by the framework.

[#setIdentifier_Identifier]
=== setIdentifier(Identifier)

Not API, set by the framework if the no-arg constructor is used.

[#hide_]
=== hide()

API for subscribers to hide the member.

[#hideIf_boolean]
=== hideIf(boolean)

Same as ... _if(condition) hide();_

[#hideIf_BooleanSupplier]
=== hideIf(BooleanSupplier)

Same as ... _if(shouldHide.getAsBoolean()) hide();_

[#disable_String]
=== disable(String)

API for subscribers to disable the member, specifying the reason why.

[#disable_TranslatableString]
=== disable(TranslatableString)

API for subscribers to disable the member, specifying the reason why as a xref:refguide:applib:index/services/i18n/TranslatableString.adoc[TranslatableString] .

[#disableIfReason_Supplier]
=== disableIfReason(Supplier)

Same as ... _if(reasonSupplier.get()!=null) disable(reasonSupplier.get());_

[#disableIfTranslatableReason_Supplier]
=== disableIfTranslatableReason(Supplier)

Same as ... _if(reasonSupplier.get()!=null) disable(reasonSupplier.get());_

[#invalidate_String]
=== invalidate(String)

API for subscribers to invalidate an interaction, eg invalid arguments to an action.

[#invalidate_TranslatableString]
=== invalidate(TranslatableString)

API for subscribers to invalidate an interaction, specifying the reason as a xref:refguide:applib:index/services/i18n/TranslatableString.adoc[TranslatableString] .

[#invalidateIfReason_Supplier]
=== invalidateIfReason(Supplier)

Same as ... _if(reasonSupplier.get()!=null) invalidate(reasonSupplier.get());_

[#invalidateIfTranslatableReason_Supplier]
=== invalidateIfTranslatableReason(Supplier)

Same as ... _if(reasonSupplier.get()!=null) invalidate(reasonSupplier.get());_

[#veto_String_Object]
=== veto(String, Object)

Use instead of _#hide()_ , _#disable(String)_ and _#invalidate(String)_ ; just delegates to appropriate vetoing method based upon the _#getEventPhase() phase_ .

If hiding, just pass `null` for the parameter.

[#veto_TranslatableString]
=== veto(TranslatableString)

Use instead of _#hide()_ , _#disable(org.apache.isis.applib.services.i18n.TranslatableString)_ and _#invalidate(org.apache.isis.applib.services.i18n.TranslatableString)_ ; just delegates to appropriate vetoing method based upon the _#getEventPhase() phase_ .

If hiding, just pass `null` for the parameter.

[#get_Object]
=== get(Object)

Obtain user-data, as set by a previous _#getEventPhase() phase_ .

[#put_Object_Object]
=== put(Object, Object)

Mechanism to allow subscribers to share arbitrary information between phases. One event instance is used for both the hide and disable phases, and a different event instance is shared between validate/pre-execute/post-execute. Set user-data, for the use of a subsequent _#getEventPhase() phase_ .
