44 lines
1.1 KiB
Java
44 lines
1.1 KiB
Java
package envoy.data;
|
|
|
|
import java.io.IOException;
|
|
import java.io.Serializable;
|
|
|
|
import envoy.util.SerializationUtils;
|
|
|
|
/**
|
|
* This interface should be used for any type supposed to be a {@link Message}
|
|
* attachment (i.e. images or sound).<br>
|
|
* <br>
|
|
* Project: <strong>envoy-common</strong><br>
|
|
* File: <strong>MessageAttachment.java</strong><br>
|
|
* Created: <strong>30 Dec 2019</strong><br>
|
|
*
|
|
* @author Leon Hofmeister
|
|
* @param <T> the type of this message attachment
|
|
* @since Envoy Common v0.2-alpha
|
|
*/
|
|
public class MessageAttachment<T> implements Serializable {
|
|
|
|
private static final long serialVersionUID = 0L;
|
|
private T value;
|
|
|
|
/**
|
|
* @return the type implementing this interface
|
|
* @since Envoy Common v0.2-alpha
|
|
*/
|
|
T getValue() { return value; }
|
|
|
|
/**
|
|
* @return the {@link MessageAttachment} as a byte array
|
|
* @throws IOException if the serialization failed
|
|
* @since Envoy Common v0.2-alpha
|
|
*/
|
|
byte[] toByteArray() throws IOException { return SerializationUtils.writeToByteArray(this); }
|
|
|
|
/**
|
|
* @param value the value to set
|
|
* @since Envoy Common v0.2-alpha
|
|
*/
|
|
public void setValue(T value) { this.value = value; }
|
|
}
|