Skip to content

Commit db83b39

Browse files
committed
fixes #139: Refactoring: annotating ArchivedMessage
This adds documentation that helps define how ArchivedMessage is to be used.
1 parent adf4df0 commit db83b39

File tree

1 file changed

+68
-1
lines changed

1 file changed

+68
-1
lines changed

src/java/com/reucon/openfire/plugin/archive/model/ArchivedMessage.java

+68-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
import org.jivesoftware.database.JiveID;
44
import org.xmpp.packet.JID;
55

6+
import javax.annotation.Nonnull;
7+
import javax.annotation.Nullable;
8+
import javax.annotation.concurrent.Immutable;
69
import java.util.Date;
710

811
/**
912
* An archived message.
1013
*/
1114
@JiveID(601)
15+
@Immutable
1216
public class ArchivedMessage {
1317
public enum Direction {
1418
/**
@@ -22,15 +26,28 @@ public enum Direction {
2226
from
2327
}
2428

29+
@Nullable
2530
private final Long id;
31+
32+
@Nonnull
2633
private final Date time;
34+
35+
@Nonnull
2736
private final Direction direction;
37+
38+
@Nullable
2839
private final String body;
40+
41+
@Nullable
2942
private final JID with;
43+
44+
@Nullable
3045
private final String stanza;
46+
47+
@Nullable
3148
private final String stableId;
3249

33-
public ArchivedMessage( Long id, Date time, Direction direction, JID with, String stableId, String body, String stanza) {
50+
public ArchivedMessage(@Nullable final Long id, @Nonnull final Date time, @Nonnull final Direction direction, @Nullable final JID with, @Nullable final String stableId, @Nullable final String body, @Nullable final String stanza) {
3451
this.id = id;
3552
this.time = time;
3653
this.direction = direction;
@@ -40,30 +57,80 @@ public ArchivedMessage( Long id, Date time, Direction direction, JID with, Strin
4057
this.stanza = stanza;
4158
}
4259

60+
/**
61+
* The database identifier used to store this message. Expected to be non-null, unless an instance has not been
62+
* persisted in the database yet.
63+
*
64+
* @return A database identifier
65+
*/
66+
@Nullable
4367
public Long getId() {
4468
return id;
4569
}
4670

71+
/**
72+
* The instant when the message was originally sent.
73+
*
74+
* @return date that the message wos originally sent.
75+
*/
76+
@Nonnull
4777
public Date getTime() {
4878
return time;
4979
}
5080

81+
/**
82+
* Defines if the message was originally sent, or received, by the owner of the archive that this message is part of.
83+
*
84+
* @return indication if message was originally sent or received.
85+
*/
86+
@Nonnull
5187
public Direction getDirection() {
5288
return direction;
5389
}
5490

91+
/**
92+
* The textual content of the message that was sent, if the message had any text.
93+
*
94+
* @return Message content
95+
*/
96+
@Nullable
5597
public String getBody() {
5698
return body;
5799
}
58100

101+
/**
102+
* The XML representation of the XMPP stanza that was used to transmit the message.
103+
*
104+
* Note that older version of the Monitoring plugin did not store the XMPP stanza to the database. As a result,
105+
* messages that were archived by those versions of the plugin do not include a stanza.
106+
*
107+
* @return XMPP packet
108+
*/
109+
@Nullable
59110
public String getStanza() {
60111
return stanza;
61112
}
62113

114+
/**
115+
* The message peer (the 'other side' of the conversation), in respect to the owner of the archive that this message
116+
* is part of.
117+
*
118+
* This value will only have meaning when the original message was sent in a one-to-one conversation. When the
119+
* archived message was originally shared in a group chat, this value can be null.
120+
*
121+
* @return The conversation peer.
122+
*/
123+
@Nullable
63124
public JID getWith() {
64125
return with;
65126
}
66127

128+
/**
129+
* The first stable and unique stanza-id value in the stanza, if the stanza contains such a value.
130+
*
131+
* @return a stable and unique stanza-id value.
132+
*/
133+
@Nullable
67134
public String getStableId()
68135
{
69136
return stableId;

0 commit comments

Comments
 (0)