This repository has been archived on 2021-12-05. You can view files and clone it, but cannot push or open issues or pull requests.
envoy/src/main/java/envoy/data/MessageAttachment.java

44 lines
1.2 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 = 262683855157198013L;
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; }
}