= CommandOutcomeHandler
: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 by xref:refguide:applib:index/services/command/CommandExecutorService.adoc[CommandExecutorService] , to update a xref:refguide:applib:index/services/command/Command.adoc[Command] after it has been executed.

== API

[source,java]
.CommandOutcomeHandler.java
----
interface CommandOutcomeHandler {
  CommandOutcomeHandler NULL;
  Timestamp getStartedAt()     // <.>
  void setStartedAt(Timestamp startedAt)     // <.>
  void setCompletedAt(Timestamp completedAt)     // <.>
  void setResult(Try<Bookmark> result)     // <.>
}
----

<.> xref:#getStartedAt_[getStartedAt()]
+
--
Reads the `startedAt` field from the underlying xref:refguide:applib:index/services/command/Command.adoc[Command] (or persistent equivalent)
--
<.> xref:#setStartedAt_Timestamp[setStartedAt(Timestamp)]
+
--
Sets the `startedAt` field on the underlying xref:refguide:applib:index/services/command/Command.adoc[Command] (or persistent equivalent)
--
<.> xref:#setCompletedAt_Timestamp[setCompletedAt(Timestamp)]
+
--
Sets the `completedAt` field on the underlying xref:refguide:applib:index/services/command/Command.adoc[Command] (or persistent equivalent)
--
<.> xref:#setResult_Try[setResult(Try)]
+
--
Handle the result of the execute, represented either as a xref:refguide:applib:index/services/bookmark/Bookmark.adoc[Bookmark] (success case) or an exception (failure), on the underlying xref:refguide:applib:index/services/command/Command.adoc[Command] (or persistent equivalent).
--

== Members

[#getStartedAt_]
=== getStartedAt()

Reads the `startedAt` field from the underlying xref:refguide:applib:index/services/command/Command.adoc[Command] (or persistent equivalent)

This is to ensure that it isn't overwritten by _#setStartedAt(Timestamp)_ .

[#setStartedAt_Timestamp]
=== setStartedAt(Timestamp)

Sets the `startedAt` field on the underlying xref:refguide:applib:index/services/command/Command.adoc[Command] (or persistent equivalent)

[#setCompletedAt_Timestamp]
=== setCompletedAt(Timestamp)

Sets the `completedAt` field on the underlying xref:refguide:applib:index/services/command/Command.adoc[Command] (or persistent equivalent)

[#setResult_Try]
=== setResult(Try)

Handle the result of the execute, represented either as a xref:refguide:applib:index/services/bookmark/Bookmark.adoc[Bookmark] (success case) or an exception (failure), on the underlying xref:refguide:applib:index/services/command/Command.adoc[Command] (or persistent equivalent).
