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

Used to serialize the intention to invoke an action or edit a property as a _CommandDto_ , for example such that it can be persisted and then executed at some later time or even against some external system.

There are some similarities to _org.apache.causeway.core.metamodel.services.ixn.InteractionDtoFactory_ , which is used to instantiate an _org.apache.causeway.schema.ixn.v2.InteractionDto_ that represents the _actual_ execution of the action invocation or property edit.

== API

[source,java]
.CommandDtoFactory.java
----
interface CommandDtoFactory {
  CommandDto asCommandDto(UUID interactionId, InteractionHead targetHead, ObjectAction objectAction, Can<ManagedObject> argAdapters)     // <.>
  CommandDto asCommandDto(UUID interactionId, InteractionHead targetHead, OneToOneAssociation association, ManagedObject valueAdapterOrNull)     // <.>
  void addActionArgs(InteractionHead head, ObjectAction objectAction, ActionDto actionDto, Can<ManagedObject> argAdapters)     // <.>
  void addPropertyValue(InteractionHead interactionHead, OneToOneAssociation property, PropertyDto propertyDto, ManagedObject valueAdapter)     // <.>
}
----

<.> xref:#asCommandDto_UUID_InteractionHead_ObjectAction_Can[asCommandDto(UUID, InteractionHead, ObjectAction, Can)]
+
--
Returns a _CommandDto_ that represents the intention to invoke an action on a target object (or target objects, to support the notion of bulk actions).
--
<.> xref:#asCommandDto_UUID_InteractionHead_OneToOneAssociation_ManagedObject[asCommandDto(UUID, InteractionHead, OneToOneAssociation, ManagedObject)]
+
--
Returns a _CommandDto_ that represents the intention to edit (set or clear) a property on a target (or possibly many targets, for symmetry with actions).
--
<.> xref:#addActionArgs_InteractionHead_ObjectAction_ActionDto_Can[addActionArgs(InteractionHead, ObjectAction, ActionDto, Can)]
+
--
Adds the arguments of an action to an _ActionDto_ (the element within a _CommandDto_ representing an action invocation).
--
<.> xref:#addPropertyValue_InteractionHead_OneToOneAssociation_PropertyDto_ManagedObject[addPropertyValue(InteractionHead, OneToOneAssociation, PropertyDto, ManagedObject)]
+
--
Adds the new value argument of a property to a _PropertyDto_ (the element a _CommandDto_ representing an property edit).
--

== Members

[#asCommandDto_UUID_InteractionHead_ObjectAction_Can]
=== asCommandDto(UUID, InteractionHead, ObjectAction, Can)

Returns a _CommandDto_ that represents the intention to invoke an action on a target object (or target objects, to support the notion of bulk actions).

[#asCommandDto_UUID_InteractionHead_OneToOneAssociation_ManagedObject]
=== asCommandDto(UUID, InteractionHead, OneToOneAssociation, ManagedObject)

Returns a _CommandDto_ that represents the intention to edit (set or clear) a property on a target (or possibly many targets, for symmetry with actions).

[#addActionArgs_InteractionHead_ObjectAction_ActionDto_Can]
=== addActionArgs(InteractionHead, ObjectAction, ActionDto, Can)

Adds the arguments of an action to an _ActionDto_ (the element within a _CommandDto_ representing an action invocation).

This is used when the command is actually executed to populate the parameters of the equivalent _org.apache.causeway.schema.ixn.v2.ActionInvocationDto_

[#addPropertyValue_InteractionHead_OneToOneAssociation_PropertyDto_ManagedObject]
=== addPropertyValue(InteractionHead, OneToOneAssociation, PropertyDto, ManagedObject)

Adds the new value argument of a property to a _PropertyDto_ (the element a _CommandDto_ representing an property edit).

This is used when the command is actually executed to set the the new value of the equivalent _org.apache.causeway.schema.ixn.v2.PropertyEditDto_ .
