diff --git a/.classpath b/.classpath index 88d37ef..907ff21 100644 --- a/.classpath +++ b/.classpath @@ -24,10 +24,5 @@ - - - - - diff --git a/pom.xml b/pom.xml index eee2dcf..1feb64c 100644 --- a/pom.xml +++ b/pom.xml @@ -18,6 +18,11 @@ envoy-common + + + src/main/resources + + org.apache.maven.plugins diff --git a/src/main/java/envoy/data/MessageIdGenerator.java b/src/main/java/envoy/data/IdGenerator.java similarity index 65% rename from src/main/java/envoy/data/MessageIdGenerator.java rename to src/main/java/envoy/data/IdGenerator.java index dbd27a2..9b61a20 100644 --- a/src/main/java/envoy/data/MessageIdGenerator.java +++ b/src/main/java/envoy/data/IdGenerator.java @@ -1,32 +1,39 @@ package envoy.data; +import java.io.Serializable; + /** * Generates increasing IDs between two numbers.
*
* Project: envoy-common
- * File: MessageIdGenerator.java
+ * File: IdGenerator.java
* Created: 31.12.2019
- * + * * @author Kai S. K. Engelbart * @since Envoy Common v0.2-alpha */ -public class MessageIdGenerator { +public class IdGenerator implements Serializable { private final long end; private long current; + private static final long serialVersionUID = -1517378307055845147L; + /** - * Creates an instance of {@link MessageIdGenerator}. + * Creates an instance of {@link IdGenerator}. * * @param begin the first ID * @param end the last ID * @since Envoy Common v0.2-alpha */ - public MessageIdGenerator(long begin, long end) { + public IdGenerator(long begin, long end) { current = begin; this.end = end; } + @Override + public String toString() { return String.format("MessageIdGenerator[current=%d,end=%d]", current, end); } + /** * @return {@code true} if there are unused IDs remaining * @since Envoy Common v0.2-alpha diff --git a/src/main/java/envoy/data/Message.java b/src/main/java/envoy/data/Message.java index 50a2f09..dea58cf 100644 --- a/src/main/java/envoy/data/Message.java +++ b/src/main/java/envoy/data/Message.java @@ -24,7 +24,7 @@ public class Message implements Serializable { * * @since Envoy Common v0.2-alpha */ - public static enum MessageStatus { + public enum MessageStatus { /** * is selected, if a message was sent but not received by the server yet. @@ -77,7 +77,7 @@ public class Message implements Serializable { this.id = id; this.senderId = senderId; this.recipientId = recipientId; - this.creationDate = date; + creationDate = date; this.text = text; this.attachment = attachment; this.status = status; @@ -186,6 +186,6 @@ public class Message implements Serializable { */ public void setStatus(MessageStatus status) { if (status.ordinal() < this.status.ordinal()) throw new IllegalStateException("This message is moving backwards in time"); - else this.status = status; + this.status = status; } } \ No newline at end of file diff --git a/src/main/java/envoy/event/Event.java b/src/main/java/envoy/event/Event.java index f17b95b..1aee5a4 100644 --- a/src/main/java/envoy/event/Event.java +++ b/src/main/java/envoy/event/Event.java @@ -14,6 +14,5 @@ public interface Event { /** * @return the data associated with this event */ - T get(); + default T get() { return null; } } - diff --git a/src/main/java/envoy/event/IdGeneratorRequest.java b/src/main/java/envoy/event/IdGeneratorRequest.java new file mode 100644 index 0000000..ab80515 --- /dev/null +++ b/src/main/java/envoy/event/IdGeneratorRequest.java @@ -0,0 +1,14 @@ +package envoy.event; + +/** + * Signifies to the server that the client needs a new + * {@link envoy.data.IdGenerator} instance.
+ *
+ * Project: envoy-common
+ * File: IdGeneratorRequest.java
+ * Created: 28 Jan 2020
+ * + * @author Kai S. K. Engelbart + */ +public class IdGeneratorRequest implements Event { +}