
js.email.javamail.MessageIDConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of js-javamail Show documentation
Show all versions of js-javamail Show documentation
Reference implementation of j(s)-email API base on JavaMail.
The newest version!
package js.email.javamail;
import js.converter.Converter;
import js.email.EmailException;
/**
* RFC2822 message identifier. This is a unique message identifier that refers to a particular version of a particular message.
* It is structured as bellow:
*
*
* msg-id = [CFWS] "<" id-left "@" id-right ">" [CFWS]
*
*
* where optional CFWS
means comment, folding or white-space whereas, in our case, id-left
is a random
* UUID and id-right
is a mailer exchange unique identifier. Note that the same id-left
is used to set
* envelope sender, as described by VERP algorithm.
*/
public final class MessageIDConverter implements Converter {
/**
* Create an email message ID from given string. Return newly create message ID instance. If given string
value
* is empty returns null.
*
* @param string RFC2822 email message ID string representation.
* @param valueType unused value type, always MessageID.class.
* @return message ID instance or null.
* @throws EmailException if string argument is not a well formed email message ID.
*/
@SuppressWarnings("unchecked")
@Override
public T asObject(String string, Class valueType) throws EmailException {
if (string.isEmpty()) {
return null;
}
return (T) new MessageID(string);
}
/**
* Return string representation of an email message ID instance.
*
* @param object email message ID instance.
* @return given message ID string representation.
*/
@Override
public String asString(Object object) {
return ((MessageID) object).getValue();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy