Skip to content

Method: getEndTime()

1: /*
2: * *********************************************************************************************************************
3: *
4: * TheseFoolishThings: Miscellaneous utilities
5: * http://tidalwave.it/projects/thesefoolishthings
6: *
7: * Copyright (C) 2009 - 2023 by Tidalwave s.a.s. (http://tidalwave.it)
8: *
9: * *********************************************************************************************************************
10: *
11: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
12: * the License. You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
17: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations under the License.
19: *
20: * *********************************************************************************************************************
21: *
22: * git clone https://bitbucket.org/tidalwave/thesefoolishthings-src
23: * git clone https://github.com/tidalwave-it/thesefoolishthings-src
24: *
25: * *********************************************************************************************************************
26: */
27: package it.tidalwave.actor;
28:
29: import javax.annotation.Nonnull;
30: import javax.annotation.concurrent.Immutable;
31: import it.tidalwave.actor.annotation.Message;
32: import org.joda.time.DateTime;
33: import org.joda.time.Duration;
34: import lombok.EqualsAndHashCode;
35: import lombok.ToString;
36:
37: /***********************************************************************************************************************
38: *
39: * This message notifies that a {@link Collaboration} has been completed.
40: *
41: * @author Fabrizio Giudici
42: *
43: **********************************************************************************************************************/
44: @Message @Immutable @EqualsAndHashCode @ToString
45: public class CollaborationCompletedMessage extends MessageSupport
46: {
47: private final long endTime = System.currentTimeMillis();
48:
49: /*******************************************************************************************************************
50: *
51: *
52: *
53: ******************************************************************************************************************/
54: private CollaborationCompletedMessage (@Nonnull final Collaboration collaboration)
55: {
56: super(collaboration);
57: }
58:
59: /*******************************************************************************************************************
60: *
61: * Creates a new instance for the given {@link Collaboration}.
62: *
63: * @param collaboration the {@code Collaboration}
64: * @return the new instance
65: *
66: ******************************************************************************************************************/
67: @Nonnull
68: public static CollaborationCompletedMessage forCollaboration (@Nonnull final Collaboration collaboration)
69: {
70: return new CollaborationCompletedMessage(collaboration);
71: }
72:
73: /*******************************************************************************************************************
74: *
75: * Returns the time when the {@link Collaboration} has been started.
76: *
77: * @return the start time
78: *
79: ******************************************************************************************************************/
80: @Nonnull
81: public DateTime getStartTime()
82: {
83: return collaboration.getStartTime();
84: }
85:
86: /*******************************************************************************************************************
87: *
88: * Returns the time when the {@link Collaboration} has been completed.
89: *
90: * @return the end time
91: *
92: ******************************************************************************************************************/
93: @Nonnull
94: public DateTime getEndTime()
95: {
96: return new DateTime(endTime);
97: }
98:
99: /*******************************************************************************************************************
100: *
101: * Returns the time this {@link Collaboration} took to complete.
102: *
103: * @return the duration
104: *
105: ******************************************************************************************************************/
106: @Nonnull
107: public Duration getDuration()
108: {
109: return new Duration(getStartTime().getMillis(), endTime);
110: }
111: }