2020-07-02 10:58:02 +02:00
|
|
|
package envoy.data;
|
|
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This interface should be used for any type supposed to be a {@link Message}
|
|
|
|
* attachment (i.e. images or sound).
|
|
|
|
* <p>
|
|
|
|
* Project: <strong>envoy-common</strong><br>
|
|
|
|
* File: <strong>Attachment.java</strong><br>
|
|
|
|
* Created: <strong>30 Dec 2019</strong><br>
|
|
|
|
*
|
|
|
|
* @author Leon Hofmeister
|
|
|
|
* @author Kai S. K. Engelbart
|
|
|
|
* @since Envoy Common v0.2-alpha
|
|
|
|
*/
|
|
|
|
public class Attachment implements Serializable {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Defines the type of the attachment.
|
|
|
|
*
|
|
|
|
* @since Envoy Common v0.1-beta
|
|
|
|
*/
|
|
|
|
public enum AttachmentType {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This attachment type denotes a picture.
|
|
|
|
*
|
|
|
|
* @since Envoy Common v0.1-beta
|
|
|
|
*/
|
|
|
|
PICTURE,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This attachment type denotes a voice message.
|
|
|
|
*
|
|
|
|
* @since Envoy Common v0.1-beta
|
|
|
|
*/
|
2020-07-02 17:50:04 +02:00
|
|
|
VOICE,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This attachment type denotes a document.
|
|
|
|
*
|
|
|
|
* @since Envoy Common v0.1-beta
|
|
|
|
*/
|
|
|
|
DOCUMENT
|
2020-07-02 10:58:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private final byte[] data;
|
|
|
|
private final AttachmentType type;
|
|
|
|
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructs an attachment.
|
|
|
|
*
|
|
|
|
* @param data the data of the attachment
|
|
|
|
* @param type the type of the attachment
|
|
|
|
* @since Envoy Common v0.1-beta
|
|
|
|
*/
|
|
|
|
public Attachment(byte[] data, AttachmentType type) {
|
|
|
|
this.data = data;
|
|
|
|
this.type = type;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the data of the attachment
|
|
|
|
* @since Envoy Common v0.1-beta
|
|
|
|
*/
|
|
|
|
public byte[] getData() { return data; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the type of the attachment
|
|
|
|
* @since Envoy Common v0.1-beta
|
|
|
|
*/
|
|
|
|
public AttachmentType getType() { return type; }
|
|
|
|
}
|