Renamed MessageIdGenerator to IdGenerator, added IdGeneratorRequest
Also removed src/test/resources from pom.xml.
This commit is contained in:
parent
e0fef6af54
commit
09b803ed4b
@ -24,10 +24,5 @@
|
||||
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
5
pom.xml
5
pom.xml
@ -18,6 +18,11 @@
|
||||
|
||||
<build>
|
||||
<finalName>envoy-common</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
@ -1,32 +1,39 @@
|
||||
package envoy.data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Generates increasing IDs between two numbers.<br>
|
||||
* <br>
|
||||
* Project: <strong>envoy-common</strong><br>
|
||||
* File: <strong>MessageIdGenerator.java</strong><br>
|
||||
* File: <strong>IdGenerator.java</strong><br>
|
||||
* Created: <strong>31.12.2019</strong><br>
|
||||
*
|
||||
*
|
||||
* @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
|
@ -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;
|
||||
}
|
||||
}
|
@ -14,6 +14,5 @@ public interface Event<T> {
|
||||
/**
|
||||
* @return the data associated with this event
|
||||
*/
|
||||
T get();
|
||||
default T get() { return null; }
|
||||
}
|
||||
|
||||
|
14
src/main/java/envoy/event/IdGeneratorRequest.java
Normal file
14
src/main/java/envoy/event/IdGeneratorRequest.java
Normal file
@ -0,0 +1,14 @@
|
||||
package envoy.event;
|
||||
|
||||
/**
|
||||
* Signifies to the server that the client needs a new
|
||||
* {@link envoy.data.IdGenerator} instance.<br>
|
||||
* <br>
|
||||
* Project: <strong>envoy-common</strong><br>
|
||||
* File: <strong>IdGeneratorRequest.java</strong><br>
|
||||
* Created: <strong>28 Jan 2020</strong><br>
|
||||
*
|
||||
* @author Kai S. K. Engelbart
|
||||
*/
|
||||
public class IdGeneratorRequest implements Event<Void> {
|
||||
}
|
Reference in New Issue
Block a user