= ManagedObject
: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.

Represents an instance of some element of the meta-model recognized by the framework, that is _Spring_ managed beans, persistence-stack provided entities, view-models, mixins or instances of value types.

== API

[source,java]
.ManagedObject.java
----
interface ManagedObject {
  Specialization getSpecialization()     // <.>
  BookmarkPolicy getBookmarkPolicy()
  ObjectSpecification getSpecification()     // <.>
  Object getPojo()     // <.>
  EntityState getEntityState()
  Supplier<ManagedObject> asSupplier()
  T assertCompliance(T pojo)     // <.>
  String getTitle()     // <.>
  String getIconName()     // <.>
  ObjectIcon getIcon()
  Either<ObjectIcon, FontAwesomeLayers> eitherIconOrFaLayers()     // <.>
  Either<ManagedObject, ManagedObject> asEitherWithOrWithoutMemoizedBookmark()
  ManagedObject unspecified()     // <.>
  ManagedObject empty(ObjectSpecification spec)     // <.>
  ManagedObject value(ObjectSpecification spec, Object pojo)     // <.>
  ManagedObject service(ObjectSpecification spec, Object pojo)     // <.>
  ManagedObject viewmodel(ObjectSpecification spec, Object pojo, Optional<Bookmark> bookmarkIfKnown)     // <.>
  ManagedObject entity(ObjectSpecification spec, Object pojo, Optional<Bookmark> bookmarkIfKnown)     // <.>
  ManagedObject entityHypridBookmarked(ObjectSpecification spec, Object pojo, Optional<Bookmark> bookmarkIfKnown)
  ManagedObject entityHybirdTransient(ObjectSpecification spec, Object pojo)
  ManagedObject mixin(ObjectSpecification spec, Object pojo)     // <.>
  ManagedObject other(ObjectSpecification spec, Object pojo)     // <.>
  PackedManagedObject packed(ObjectSpecification elementSpec, Can<ManagedObject> nonScalar)     // <.>
  ManagedObject adaptSingular(SpecificationLoader specLoader, Object pojo)     // <.>
  ManagedObject adaptSingular(ObjectSpecification guess, Object pojo)
  ManagedObject adaptProperty(OneToOneAssociation oneToOneAssociation, Object pojo)
  ManagedObject adaptParameter(ObjectActionParameter param, Object paramValue)
  Can<ManagedObject> adaptParameters(Can<ObjectActionParameter> objectActionParameters, List<Object> args)
  ManagedObject bookmarked(ObjectSpecification spec, Object pojo, Bookmark bookmark)     // <.>
  ManagedObject adaptSingularInternal(ObjectSpecification guess, Object pojo, Optional<Bookmark> bookmarkIfAny)     // <.>
}
----

<.> xref:#getSpecialization_[getSpecialization()]
+
--
Returns the specific _Specialization_ this xref:refguide:core:index/metamodel/object/ManagedObject.adoc[ManagedObject] implements, which governs this object's behavior.
--
<.> xref:#getSpecification_[getSpecification()]
+
--
Returns the specification that details the structure (meta-model) of this object.
--
<.> xref:#getPojo_[getPojo()]
+
--
Returns the adapted domain object, the 'plain old java' object this managed object represents with the framework.
--
<.> xref:#assertCompliance_T[assertCompliance(T)]
+
--
Unary operator asserting that _pojo_ and _#getSpecification()_ are compliant with the policies from _#getSpecialization()_ .
--
<.> xref:#getTitle_[getTitle()]
+
--
The (untranslated) title of the wrapped pojo.
--
<.> xref:#getIconName_[getIconName()]
+
--
Returns the name of an icon to use for this object.
--
<.> xref:#eitherIconOrFaLayers_[eitherIconOrFaLayers()]
+
--
Domain Objects may either have an icon corresponding to an icon resource, or they use a font awesome icon.
--
<.> xref:#unspecified_[unspecified()]
+
--
Factory for Specialization#UNSPECIFIED.
--
<.> xref:#empty_ObjectSpecification[empty(ObjectSpecification)]
+
--
EMPTY
--
<.> xref:#value_ObjectSpecification_Object[value(ObjectSpecification, Object)]
+
--
VALUE
--
<.> xref:#service_ObjectSpecification_Object[service(ObjectSpecification, Object)]
+
--
SERVICE
--
<.> xref:#viewmodel_ObjectSpecification_Object_Optional[viewmodel(ObjectSpecification, Object, Optional)]
+
--
VIEWMODEL
--
<.> xref:#entity_ObjectSpecification_Object_Optional[entity(ObjectSpecification, Object, Optional)]
+
--
ENTITY
--
<.> xref:#mixin_ObjectSpecification_Object[mixin(ObjectSpecification, Object)]
+
--
MIXIN
--
<.> xref:#other_ObjectSpecification_Object[other(ObjectSpecification, Object)]
+
--
OTHER
--
<.> xref:#packed_ObjectSpecification_Can[packed(ObjectSpecification, Can)]
+
--
PACKED
--
<.> xref:#adaptSingular_SpecificationLoader_Object[adaptSingular(SpecificationLoader, Object)]
+
--
For cases, when the pojo's specification is not available and needs to be looked up.
--
<.> xref:#bookmarked_ObjectSpecification_Object_Bookmark[bookmarked(ObjectSpecification, Object, Bookmark)]
+
--
Optimized for cases, when the pojo's specification and bookmark are already available.
--
<.> xref:#adaptSingularInternal_ObjectSpecification_Object_Optional[adaptSingularInternal(ObjectSpecification, Object, Optional)]
+
--
spec and pojo don't need to be strictly in sync, we adapt if required
--

== Members

[#getSpecialization_]
=== getSpecialization()

Returns the specific _Specialization_ this xref:refguide:core:index/metamodel/object/ManagedObject.adoc[ManagedObject] implements, which governs this object's behavior.

[#getSpecification_]
=== getSpecification()

Returns the specification that details the structure (meta-model) of this object.

[#getPojo_]
=== getPojo()

Returns the adapted domain object, the 'plain old java' object this managed object represents with the framework.

[#assertCompliance_T]
=== assertCompliance(T)

Unary operator asserting that _pojo_ and _#getSpecification()_ are compliant with the policies from _#getSpecialization()_ .

[#getTitle_]
=== getTitle()

The (untranslated) title of the wrapped pojo.

[#getIconName_]
=== getIconName()

Returns the name of an icon to use for this object.

May return `null` if no icon is specified.

[#eitherIconOrFaLayers_]
=== eitherIconOrFaLayers()

Domain Objects may either have an icon corresponding to an icon resource, or they use a font awesome icon.

[#unspecified_]
=== unspecified()

Factory for Specialization#UNSPECIFIED.

[#empty_ObjectSpecification]
=== empty(ObjectSpecification)

EMPTY

[#value_ObjectSpecification_Object]
=== value(ObjectSpecification, Object)

VALUE

[#service_ObjectSpecification_Object]
=== service(ObjectSpecification, Object)

SERVICE

[#viewmodel_ObjectSpecification_Object_Optional]
=== viewmodel(ObjectSpecification, Object, Optional)

VIEWMODEL

[#entity_ObjectSpecification_Object_Optional]
=== entity(ObjectSpecification, Object, Optional)

ENTITY

[#mixin_ObjectSpecification_Object]
=== mixin(ObjectSpecification, Object)

MIXIN

[#other_ObjectSpecification_Object]
=== other(ObjectSpecification, Object)

OTHER

[#packed_ObjectSpecification_Can]
=== packed(ObjectSpecification, Can)

PACKED

[#adaptSingular_SpecificationLoader_Object]
=== adaptSingular(SpecificationLoader, Object)

For cases, when the pojo's specification is not available and needs to be looked up.

Fails if the pojo is not a singular (eg. collection).

[#bookmarked_ObjectSpecification_Object_Bookmark]
=== bookmarked(ObjectSpecification, Object, Bookmark)

Optimized for cases, when the pojo's specification and bookmark are already available.

[#adaptSingularInternal_ObjectSpecification_Object_Optional]
=== adaptSingularInternal(ObjectSpecification, Object, Optional)

spec and pojo don't need to be strictly in sync, we adapt if required
