= Nature _(enum)_
: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.

The different sorts of domain objects recognized by Causeway.

== API

[source,java]
.Nature.java
----
enum Nature {
  NOT_SPECIFIED     // <.>
  ENTITY     // <.>
  VIEW_MODEL     // <.>
  MIXIN     // <.>
  BEAN     // <.>
  boolean isNotSpecified()
  boolean isEntity()
  boolean isMixin()
  boolean isViewModel()
  boolean isBean()
}
----

<.> xref:#NOT_SPECIFIED[NOT_SPECIFIED]
+
--
The default; allows the programmer to combine `@DomainObject` annotation with the xref:refguide:applib:index/ViewModel.adoc[ViewModel] annotation, or the _XmlRootElement_ annotation, or by implementing the xref:refguide:applib:index/ViewModel.adoc[ViewModel] interface.
--
<.> xref:#ENTITY[ENTITY]
+
--
A domain entity whose persistence is managed internally by Causeway, using JPA or JDO as the persistence implementation.
--
<.> xref:#VIEW_MODEL[VIEW_MODEL]
+
--
An object that is conceptually part of the application layer, and which surfaces behavior and/or state that is aggregate of one or more domain entity.
--
<.> xref:#MIXIN[MIXIN]
+
--
An object that acts as a mix-in to some other object, contributing behavior and/or derived state based on the domain object.
--
<.> xref:#BEAN[BEAN]
+
--
An object that is entirely managed by the underlying IoC container.
--

== Members

[#NOT_SPECIFIED]
=== NOT_SPECIFIED

The default; allows the programmer to combine `@DomainObject` annotation with the xref:refguide:applib:index/ViewModel.adoc[ViewModel] annotation, or the _XmlRootElement_ annotation, or by implementing the xref:refguide:applib:index/ViewModel.adoc[ViewModel] interface.

[#ENTITY]
=== ENTITY

A domain entity whose persistence is managed internally by Causeway, using JPA or JDO as the persistence implementation.

Domain entities are considered to be part of the domain model layer.

Currently implies no additional semantics other than documentation.

[#VIEW_MODEL]
=== VIEW_MODEL

An object that is conceptually part of the application layer, and which surfaces behavior and/or state that is aggregate of one or more domain entity.

The identity of a view model is determined solely by the state of object's properties. Using this nature should be considered exactly equivalent to annotating with xref:refguide:applib:index/ViewModel.adoc[ViewModel] .

Note that collections are ignored; if their state is required to fully identify the view model, define the view model using the JAXB _XmlRootElement_ annotation instead (where the object's state is serialized to an arbitrarily deep graph of data, with references to persistent entities transparently resolved to `<oid-dto>` elements).

[#MIXIN]
=== MIXIN

An object that acts as a mix-in to some other object, contributing behavior and/or derived state based on the domain object.

[#BEAN]
=== BEAN

An object that is entirely managed by the underlying IoC container.

Some possible use cases for this are:

* As a helper service that is used to emit messages through _Action#executionPublishing()_ .
+
--
The service itself isn't rendered anywhere, but its actions can be invoked through the _org.apache.causeway.applib.services.wrapper.WrapperFactory_ . (Or as a variant, it might expose a xref:refguide:applib:index/annotation/Programmatic.adoc[Programmatic] API and then delegate to its own action via the _org.apache.causeway.applib.services.wrapper.WrapperFactory_ .
--
* As a service representing a facade to a module, so that code in another (untrusted) module can only execute through xref:refguide:applib:index/annotation/Action.adoc[Action] s
+
--
Again, either the calling module is expected to use the _org.apache.causeway.applib.services.wrapper.WrapperFactory_ when invoking the facade service, or - since the calling code is treated untrusted - then the same self-delegation approach as for the previous example could be used, whereby the facade service exposes a xref:refguide:applib:index/annotation/Programmatic.adoc[Programmatic] API and then delegates to its own action via the _org.apache.causeway.applib.services.wrapper.WrapperFactory_ .
--

 *IMPORTANT* the class must _also_ be annotated with an appropriate _org.springframework.context.annotation.Scope_ , eg `@Scope("singleton")` or `@Scope("prototype")` 
