Merge branch 'develop' into f/new_ui

Conflicts:
	client/src/main/java/envoy/client/ui/controller/LoginScene.java
This commit is contained in:
2020-07-18 10:49:24 +02:00
40 changed files with 323 additions and 328 deletions

View File

@ -8,15 +8,9 @@
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
@ -24,5 +18,10 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@ -1,35 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>envoy-common</name>
<name>common</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.jboss.tools.jst.web.kb.kbbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.jboss.tools.cdi.core.cdibuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
@ -37,10 +17,7 @@
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures>
</projectDescription>

View File

@ -1,5 +1,4 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8

View File

@ -9,8 +9,14 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=11
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.doc.comment.support=enabled
org.eclipse.jdt.core.compiler.problem.APILeak=warning
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
@ -21,10 +27,10 @@ org.eclipse.jdt.core.compiler.problem.deprecation=warning
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
org.eclipse.jdt.core.compiler.problem.emptyStatement=info
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
@ -35,14 +41,27 @@ org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
org.eclipse.jdt.core.compiler.problem.invalidJavadoc=info
org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
org.eclipse.jdt.core.compiler.problem.missingJavadocComments=info
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=all_standard_tags
org.eclipse.jdt.core.compiler.problem.missingJavadocTags=info
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
@ -63,12 +82,12 @@ org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
@ -79,18 +98,18 @@ org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning
org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled
org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unstableAutoModuleName=warning
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
@ -104,7 +123,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=warning
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.release=disabled
@ -226,7 +245,7 @@ org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_label=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=insert
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
@ -420,7 +439,7 @@ org.eclipse.jdt.core.formatter.keep_code_block_on_one_line=one_line_if_empty
org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=true
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line=one_line_never
org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line=one_line_never
org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line=one_line_if_empty
org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line=one_line_if_single_item
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line=one_line_always
@ -431,7 +450,7 @@ org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false
org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line=true
org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=true
org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line=one_line_never
org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line=one_line_if_empty
org.eclipse.jdt.core.formatter.lineSplit=150
org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false

File diff suppressed because one or more lines are too long

View File

@ -1,37 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="envoy-common">
<wb-resource deploy-path="/" source-path="/src/main/java"/>
</wb-module>
</project-modules>

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<installed facet="jst.utility" version="1.0"/>
<installed facet="java" version="11"/>
</faceted-project>

View File

@ -1,2 +0,0 @@
disabled=06target
eclipse.preferences.version=1

View File

@ -17,9 +17,10 @@ import java.util.Set;
*/
public abstract class Contact implements Serializable {
private final long id;
private final transient Set<? extends Contact> contacts;
private String name;
protected final long id;
protected final transient Set<? extends Contact> contacts;
protected String name;
private static final long serialVersionUID = 0L;
@ -55,19 +56,13 @@ public abstract class Contact implements Serializable {
*/
public void setName(String name) { this.name = name; }
/**
* {@inheritDoc}
*/
@Override
public String toString() { return String.format("Contact[id=%d,name=%s, contacts=%s]", id, name, contacts); }
/**
* Provides a hash code based on the ID of this contact.
*
* @since Envoy Common v0.1-beta
*/
@Override
public int hashCode() { return Objects.hash(id); }
public final int hashCode() { return Objects.hash(id); }
/**
* Tests equality to another object. If that object is a contact as well,
@ -77,7 +72,7 @@ public abstract class Contact implements Serializable {
* @return {code true} if both objects are contacts and have identical IDs
*/
@Override
public boolean equals(Object obj) {
public final boolean equals(Object obj) {
if (this == obj) return true;
if (!(obj instanceof Contact)) return false;
return id == ((Contact) obj).id;

View File

@ -36,6 +36,9 @@ public final class Group extends Contact {
*/
public Group(long id, String name, Set<User> members) { super(id, name, members); }
@Override
public String toString() { return String.format("Group[id=%d,name=%s,%d member(s)]", id, name, contacts.size()); }
private void readObject(ObjectInputStream inputStream) throws Exception {
inputStream.defaultReadObject();
var contacts = Contact.class.getDeclaredField("contacts");
@ -49,7 +52,6 @@ public final class Group extends Contact {
outputStream.writeObject(getContacts());
}
@SuppressWarnings("unchecked")
@Override
public Set<User> getContacts() { return (Set<User>) super.getContacts(); }
public Set<User> getContacts() { return (Set<User>) contacts; }
}

View File

@ -1,6 +1,6 @@
package envoy.data;
import java.time.LocalDateTime;
import java.time.Instant;
import java.util.Collections;
import java.util.Map;
@ -16,7 +16,7 @@ public final class GroupMessage extends Message {
private final Map<Long, MessageStatus> memberStatuses;
private static final long serialVersionUID = 0L;
private static final long serialVersionUID = 1L;
/**
* Initializes a {@link GroupMessage} with values for all of its properties. The
@ -38,9 +38,9 @@ public final class GroupMessage extends Message {
* @param forwarded whether this message was forwarded
* @param memberStatuses a map of all members and their status according to this
* {@link GroupMessage}
* @since Envoy Common v0.1-beta
* @since Envoy Common v0.2-beta
*/
GroupMessage(long id, long senderID, long groupID, LocalDateTime creationDate, LocalDateTime receivedDate, LocalDateTime readDate, String text,
GroupMessage(long id, long senderID, long groupID, Instant creationDate, Instant receivedDate, Instant readDate, String text,
Attachment attachment, MessageStatus status, boolean forwarded, Map<Long, MessageStatus> memberStatuses) {
super(id, senderID, groupID, creationDate, receivedDate, readDate, text, attachment, status, forwarded);
this.memberStatuses = memberStatuses;
@ -55,10 +55,10 @@ public final class GroupMessage extends Message {
setStatus(Collections.min(memberStatuses.values()));
switch (getStatus()) {
case RECEIVED:
setReceivedDate(LocalDateTime.now());
setReceivedDate(Instant.now());
break;
case READ:
setReadDate(LocalDateTime.now());
setReadDate(Instant.now());
break;
}
}

View File

@ -1,6 +1,7 @@
package envoy.data;
import java.io.Serializable;
import java.time.Instant;
/**
* Contains a {@link User}'s login / registration information as well as the
@ -17,8 +18,9 @@ public final class LoginCredentials implements Serializable {
private final String identifier, password, clientVersion;
private final boolean registration;
private final Instant lastSync;
private static final long serialVersionUID = 2;
private static final long serialVersionUID = 3;
/**
* Initializes login credentials for a handshake.
@ -28,18 +30,24 @@ public final class LoginCredentials implements Serializable {
* @param registration signifies that these credentials are used for user
* registration instead of user login
* @param clientVersion the version of the client sending these credentials
* @since Envoy Common v0.1-beta
* @param lastSync the time stamp of the last synchronization
* @since Envoy Common v0.2-beta
*/
public LoginCredentials(String identifier, String password, boolean registration, String clientVersion) {
public LoginCredentials(String identifier, String password, boolean registration, String clientVersion, Instant lastSync) {
this.identifier = identifier;
this.password = password;
this.registration = registration;
this.clientVersion = clientVersion;
this.lastSync = lastSync;
}
@Override
public String toString() {
return String.format("LoginCredentials[identifier=%s,registration=%b,clientVersion=%s]", identifier, registration, clientVersion);
return String.format("LoginCredentials[identifier=%s,registration=%b,clientVersion=%s,lastSync=%s]",
identifier,
registration,
clientVersion,
lastSync);
}
/**
@ -66,4 +74,10 @@ public final class LoginCredentials implements Serializable {
* @since Envoy Common v0.1-beta
*/
public String getClientVersion() { return clientVersion; }
/**
* @return the time stamp of the last synchronization
* @since Envoy Common v0.2-beta
*/
public Instant getLastSync() { return lastSync; }
}

View File

@ -1,8 +1,7 @@
package envoy.data;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.Instant;
/**
* Represents a unique message with a unique, numeric ID. Further metadata
@ -50,14 +49,14 @@ public class Message implements Serializable {
private final long id, senderID, recipientID;
private final boolean forwarded;
private final LocalDateTime creationDate;
private final Instant creationDate;
private final String text;
private final Attachment attachment;
private LocalDateTime receivedDate, readDate;
private Instant receivedDate, readDate;
private MessageStatus status;
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 2L;
/**
* Initializes a {@link Message} with values for all of its properties. The use
@ -75,9 +74,9 @@ public class Message implements Serializable {
* @param attachment the attachment of the message, if present
* @param status the current {@link MessageStatus} of the message
* @param forwarded whether this message was forwarded
* @since Envoy Common v0.2-alpha
* @since Envoy Common v0.2-beta
*/
Message(long id, long senderID, long recipientID, LocalDateTime creationDate, LocalDateTime receivedDate, LocalDateTime readDate, String text,
Message(long id, long senderID, long recipientID, Instant creationDate, Instant receivedDate, Instant readDate, String text,
Attachment attachment, MessageStatus status, boolean forwarded) {
this.id = id;
this.senderID = senderID;
@ -115,7 +114,7 @@ public class Message implements Serializable {
id,
senderID,
recipientID,
DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm:ss").format(creationDate),
creationDate,
status,
text,
forwarded,
@ -142,34 +141,34 @@ public class Message implements Serializable {
/**
* @return the date at which this message was created
* @since Envoy Common v0.2-alpha
* @since Envoy Common v0.2-beta
*/
public LocalDateTime getCreationDate() { return creationDate; }
public Instant getCreationDate() { return creationDate; }
/**
* @return the date at which the message has been received by the sender
* @since Envoy Common v0.2-alpha
* @since Envoy Common v0.2-beta
*/
public LocalDateTime getReceivedDate() { return receivedDate; }
public Instant getReceivedDate() { return receivedDate; }
/**
* @param receivedDate the date at which the message has been received by the
* sender
* @since Envoy Common v0.2-alpha
* @since Envoy Common v0.2-beta
*/
public void setReceivedDate(LocalDateTime receivedDate) { this.receivedDate = receivedDate; }
public void setReceivedDate(Instant receivedDate) { this.receivedDate = receivedDate; }
/**
* @return the date at which the message has been read by the sender
* @since Envoy Common v0.2-alpha
* @since Envoy Common v0.2-beta
*/
public LocalDateTime getReadDate() { return readDate; }
public Instant getReadDate() { return readDate; }
/**
* @param readDate at which the message has been read by the sender
* @since Envoy Common v0.2-alpha
* @since Envoy Common v0.2-beta
*/
public void setReadDate(LocalDateTime readDate) { this.readDate = readDate; }
public void setReadDate(Instant readDate) { this.readDate = readDate; }
/**
* @return the text content of this message

View File

@ -1,6 +1,6 @@
package envoy.data;
import java.time.LocalDateTime;
import java.time.Instant;
import java.util.HashMap;
import java.util.Map;
@ -23,7 +23,7 @@ public class MessageBuilder {
// Properties with default values
private long id;
private LocalDateTime creationDate, receivedDate, readDate;
private Instant creationDate, receivedDate, readDate;
private String text;
private Attachment attachment;
private Message.MessageStatus status;
@ -70,7 +70,7 @@ public class MessageBuilder {
public MessageBuilder(Message msg, long recipientID, IDGenerator iDGenerator) {
this(msg.getRecipientID(), recipientID, iDGenerator.next());
this.attachment = msg.getAttachment();
this.creationDate = LocalDateTime.now();
this.creationDate = Instant.now();
this.forwarded = true;
this.text = msg.getText();
this.status = MessageStatus.WAITING;
@ -83,7 +83,7 @@ public class MessageBuilder {
* <table border="1">
* <tr>
* <td>{@code date}</td>
* <td>{@code LocalDateTime.now()} and {@code null} for {@code receivedDate} and
* <td>{@code Instant.now()} and {@code null} for {@code receivedDate} and
* {@code readDate}</td>
* <tr>
* <tr>
@ -113,8 +113,8 @@ public class MessageBuilder {
* <br>
* <table border="1">
* <tr>
* <td>{@code date}</td>
* <td>{@code new Date()}</td>
* <td>{@code time stamp}</td>
* <td>{@code Instant.now()}</td>
* <tr>
* <tr>
* <td>{@code text}</td>
@ -140,8 +140,8 @@ public class MessageBuilder {
* <br>
* <table border="1">
* <tr>
* <td>{@code date}</td>
* <td>{@code new Date()}</td>
* <td>{@code time stamp}</td>
* <td>{@code Instant.now()}</td>
* <tr>
* <tr>
* <td>{@code text}</td>
@ -162,7 +162,7 @@ public class MessageBuilder {
}
private void supplyDefaults() {
if (creationDate == null) creationDate = LocalDateTime.now();
if (creationDate == null) creationDate = Instant.now();
if (text == null) text = "";
if (status == null) status = MessageStatus.WAITING;
}
@ -170,9 +170,9 @@ public class MessageBuilder {
/**
* @param creationDate the creation date of the {@link Message} to create
* @return this {@link MessageBuilder}
* @since Envoy Common v0.2-alpha
* @since Envoy Common v0.2-beta
*/
public MessageBuilder setCreationDate(LocalDateTime creationDate) {
public MessageBuilder setCreationDate(Instant creationDate) {
this.creationDate = creationDate;
return this;
}
@ -180,9 +180,9 @@ public class MessageBuilder {
/**
* @param receivedDate the received date of the {@link Message} to create
* @return this {@link MessageBuilder}
* @since Envoy Common v0.1-beta
* @since Envoy Common v0.2-beta
*/
public MessageBuilder setReceivedDate(LocalDateTime receivedDate) {
public MessageBuilder setReceivedDate(Instant receivedDate) {
this.receivedDate = receivedDate;
return this;
}
@ -190,9 +190,9 @@ public class MessageBuilder {
/**
* @param readDate the read date of the {@link Message} to create
* @return this {@link MessageBuilder}
* @since Envoy Common v0.1-beta
* @since Envoy Common v0.2-beta
*/
public MessageBuilder setReadDate(LocalDateTime readDate) {
public MessageBuilder setReadDate(Instant readDate) {
this.readDate = readDate;
return this;
}

View File

@ -99,7 +99,9 @@ public final class User extends Contact {
}
@Override
public String toString() { return String.format("User[id=%d,name=%s,status=%s,contacts=%s]", getID(), getName(), status, getContacts()); }
public String toString() {
return String.format("User[id=%d,name=%s,status=%s", id, name, status) + (contacts.isEmpty() ? "]" : "," + contacts.size() + " contact(s)]");
}
/**
* @return the current status of this user

View File

@ -53,7 +53,6 @@ public class EventBus {
* @param handler the event handler to register
* @since Envoy v0.2-alpha
*/
@SuppressWarnings("unchecked")
public <T extends Event<?>> void register(Class<T> eventClass, Consumer<T> handler) {
if (!handlers.containsKey(eventClass)) handlers.put(eventClass, new ArrayList<>());
handlers.get(eventClass).add((Consumer<Event<?>>) handler);

View File

@ -1,6 +1,6 @@
package envoy.event;
import java.time.LocalDateTime;
import java.time.Instant;
import envoy.data.GroupMessage;
import envoy.data.Message.MessageStatus;
@ -27,9 +27,9 @@ public class GroupMessageStatusChange extends MessageStatusChange {
* @param date the date at which the MessageStatus change occurred for
* this specific member
* @param memberID the ID of the group member that caused the status change
* @since Envoy Common v0.1-beta
* @since Envoy Common v0.2-beta
*/
public GroupMessageStatusChange(long id, MessageStatus status, LocalDateTime date, long memberID) {
public GroupMessageStatusChange(long id, MessageStatus status, Instant date, long memberID) {
super(id, status, date);
this.memberID = memberID;
}

View File

@ -1,6 +1,6 @@
package envoy.event;
import java.time.LocalDateTime;
import java.time.Instant;
import envoy.data.Message;
@ -14,8 +14,8 @@ import envoy.data.Message;
*/
public class MessageStatusChange extends Event<Message.MessageStatus> {
private final long id;
private final LocalDateTime date;
private final long id;
private final Instant date;
private static final long serialVersionUID = 0L;
@ -26,9 +26,9 @@ public class MessageStatusChange extends Event<Message.MessageStatus> {
* @param status the status of the {@link Message} this event is related
* to
* @param date the date at which the MessageStatus change occurred
* @since Envoy Common v0.2-alpha
* @since Envoy Common v0.2-beta
*/
public MessageStatusChange(long id, Message.MessageStatus status, LocalDateTime date) {
public MessageStatusChange(long id, Message.MessageStatus status, Instant date) {
super(status);
this.id = id;
this.date = date;
@ -40,7 +40,7 @@ public class MessageStatusChange extends Event<Message.MessageStatus> {
* @param message the message from which to build the event
* @since Envoy Common v0.2-alpha
*/
public MessageStatusChange(Message message) { this(message.getID(), message.getStatus(), LocalDateTime.now()); }
public MessageStatusChange(Message message) { this(message.getID(), message.getStatus(), Instant.now()); }
/**
* @return the ID of the {@link Message} this event is related to
@ -50,9 +50,9 @@ public class MessageStatusChange extends Event<Message.MessageStatus> {
/**
* @return the date at which the status change occurred
* @since Envoy Common v0.2-alpha
* @since Envoy Common v0.2-beta
*/
public LocalDateTime getDate() { return date; }
public Instant getDate() { return date; }
@Override
public String toString() { return String.format("MessageStatusChange[id=%d,status=%s,date=%s]", id, value, date); }