sventon subversion web client - http://www.sventon.org
[show recent changes]
 
  Help
HEAD
Rev: 53085 - http://anonsvn.icesoft.org/repo / icenotify / trunk / icenotify / cloud / src / main / java / org / icesoft / notify / cloud / core / email / EmailNotification.java
Unified Diff View - EmailNotification.java
/icenotify/trunk/icenotify/cloud/src/main/java/org/icesoft/notify/cloud/core/email/EmailNotification.java @ revision 53084
/icenotify/trunk/icenotify/cloud/src/main/java/org/icesoft/notify/cloud/core/email/EmailNotification.java @ revision 53085
@@ -1,69 +1,35 @@ package org.icesoft.notify.cloud.core.email; import static org.icesoft.util.ObjectUtilities.isEqual; +import static org.icesoft.util.ObjectUtilities.isNotNull; +import static org.icesoft.util.PreCondition.checkIfIsNotNull; import static org.icesoft.util.PreCondition.checkIfIsNotNullAndIsNotEmpty; -import com.google.common.primitives.Ints; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.concurrent.Delayed; -import java.util.concurrent.TimeUnit; +import java.util.logging.Level; import java.util.logging.Logger; import org.icesoft.notify.cloud.core.CloudNotificationEndpoint; -public class EmailNotification -implements Comparable<Delayed>, Delayed { +public class EmailNotification {     private static final Logger LOGGER = Logger.getLogger(EmailNotification.class.getName()); -    private final List<CloudNotificationEndpoint> cloudNotificationEndpointList = -        new ArrayList<CloudNotificationEndpoint>(); -    private final List<String> notifyBackURIList = -        new ArrayList<String>(); - +    private final CloudNotificationEndpoint notificationEndpoint;     private final String content;     private final String contentType; -    private final long delay;     private final String personal; -    private final int priorityLevel; -    private final long startTime;     private final String subject;     public EmailNotification( -        final List<CloudNotificationEndpoint> cloudNotificationEndpointList, final List<String> notifyBackURIList, -        final String personal, final String subject, final String content, final String contentType, -        final int priorityLevel) +        final CloudNotificationEndpoint notificationEndpoint, final String personal, final String subject, +        final String content, final String contentType)     throws IllegalArgumentException, NullPointerException { -        this( -            cloudNotificationEndpointList, notifyBackURIList, personal, subject, content, contentType, priorityLevel, 0L -        ); -    } - -    public EmailNotification( -        final List<CloudNotificationEndpoint> cloudNotificationEndpointList, final List<String> notifyBackURIList, -        final String personal, final String subject, final String content, final String contentType, -        final int priorityLevel, final long delay) -    throws IllegalArgumentException { -        this.cloudNotificationEndpointList. -            addAll( +        this.notificationEndpoint =                 // throws IllegalArgumentException -                checkIfIsNotNullAndIsNotEmpty( -                    cloudNotificationEndpointList, -                    "Illegal argument cloudNotificationEndpointList: '" + cloudNotificationEndpointList + "'. " + -                        "Argument cannot be null or empty." -                ) -            ); -        this.notifyBackURIList. -            addAll( -                // throws IllegalArgumentException -                checkIfIsNotNullAndIsNotEmpty( -                    notifyBackURIList, -                    "Illegal argument notifyBackURIList: '" + notifyBackURIList + "'. " + -                        "Argument cannot be null or empty." -                ) -            ); +                checkIfIsNotNull( +                    notificationEndpoint, +                    "Illegal argument notificationEndpoint: '" + notificationEndpoint + "'. " + +                        "Argument cannot be null." +                );         this.personal = personal;         this.subject =             // throws IllegalArgumentException @@ -86,59 +52,21 @@                 "Illegal argument contentType: '" + contentType + "'. " +                     "Argument cannot be null or empty."             ); -        this.priorityLevel = Math.max(priorityLevel, 0); -        this.delay = Math.max(delay, 0L); -        this.startTime = System.currentTimeMillis() + getDelay(); -    } - -    public int compareTo(final Delayed delayed) { -        return Ints.saturatedCast(getStartTime() - ((EmailNotification)delayed).getStartTime());     }     @Override     public boolean equals(final Object object) {         return             object instanceof EmailNotification && -                isEqual( -                    ((EmailNotification)object).getModifiableCloudNotificationEndpointList(), -                    getModifiableCloudNotificationEndpointList() -                ) && -                isEqual( -                    ((EmailNotification)object).getContent(), -                    getContent() -                ) && -                isEqual( -                    ((EmailNotification)object).getContentType(), -                    getContentType() -                ) && -                isEqual( -                    ((EmailNotification)object).getDelay(), -                    getDelay() -                ) && -                isEqual( -                    ((EmailNotification)object).getModifiableNotifyBackURIList(), -                    getModifiableNotifyBackURIList() -                ) && -                isEqual( -                    ((EmailNotification)object).getPersonal(), -                    getPersonal() -                ) && -                isEqual( -                    ((EmailNotification)object).getPriorityLevel(), -                    getPriorityLevel() -                ) && -                isEqual( -                    ((EmailNotification)object).getStartTime(), -                    getStartTime() -                ) && -                isEqual( -                    ((EmailNotification)object).getSubject(), -                    getSubject() -                ); +                isEqual(((EmailNotification)object).getNotificationEndpoint(), getNotificationEndpoint()) && +                isEqual(((EmailNotification)object).getContent(), getContent()) && +                isEqual(((EmailNotification)object).getContentType(), getContentType()) && +                isEqual(((EmailNotification)object).getPersonal(), getPersonal()) && +                isEqual(((EmailNotification)object).getSubject(), getSubject());     } -    public List<CloudNotificationEndpoint> getCloudNotificationEndpointList() { -        return Collections.unmodifiableList(getModifiableCloudNotificationEndpointList()); +    public CloudNotificationEndpoint getNotificationEndpoint() { +        return notificationEndpoint;     }     public String getContent() { @@ -149,30 +77,10 @@         return contentType;     } -    public long getDelay() { -        return delay; -    } - -    public long getDelay(final TimeUnit timeUnit) { -        return timeUnit.convert(startTime - System.currentTimeMillis(), TimeUnit.MILLISECONDS); -    } - -    public List<String> getNotifyBackURIList() { -        return Collections.unmodifiableList(getModifiableNotifyBackURIList()); -    } -     public String getPersonal() {         return personal;     } -    public int getPriorityLevel() { -        return priorityLevel; -    } - -    public long getStartTime() { -        return startTime; -    } -     public String getSubject() {         return subject;     } @@ -180,33 +88,11 @@     @Override     public int hashCode() {         int _hashCode; -        _hashCode = -            getModifiableCloudNotificationEndpointList() != null ? -                getModifiableCloudNotificationEndpointList().hashCode() : 0; -        _hashCode = -            31 * _hashCode + -                (getContent() != null ? getContent().hashCode() : 0); -        _hashCode = -            31 * _hashCode + -                (getContentType() != null ? getContentType().hashCode() : 0); -        _hashCode = -            31 * _hashCode + -                (int)(getDelay() ^ (getDelay() >>> 32)); -        _hashCode = -            31 * _hashCode + -                (getModifiableNotifyBackURIList() != null ? getModifiableNotifyBackURIList().hashCode() : 0); -        _hashCode = -            31 * _hashCode + -                (getPersonal() != null ? getPersonal().hashCode() : 0); -        _hashCode = -            31 * _hashCode + -                getPriorityLevel(); -        _hashCode = -            31 * _hashCode + -                (int)(getStartTime() ^ (getStartTime() >>> 32)); -        _hashCode = -            31 * _hashCode + -                (getSubject() != null ? getSubject().hashCode() : 0); +        _hashCode = isNotNull(getNotificationEndpoint()) ? getNotificationEndpoint().hashCode() : 0; +        _hashCode = 31 * _hashCode + (isNotNull(getContent()) ? getContent().hashCode() : 0); +        _hashCode = 31 * _hashCode + (isNotNull(getContentType()) ? getContentType().hashCode() : 0); +        _hashCode = 31 * _hashCode + (isNotNull(getPersonal()) ? getPersonal().hashCode() : 0); +        _hashCode = 31 * _hashCode + (isNotNull(getSubject()) ? getSubject().hashCode() : 0);         return _hashCode;     } @@ -217,22 +103,10 @@     protected String classMembersToString() {         return -            "cloudNotificationEndpoint: '" + getModifiableCloudNotificationEndpointList() + "', " + +            "notificationEndpoint: '" + getNotificationEndpoint() + "', " +             "content: '" + getContent() + "', " +             "contentType: '" + getContentType() + "', " + -            "delay: '" + getDelay() + "', " + -            "notifyBackURIList: '" + getModifiableNotifyBackURIList() + "', " +             "personal: '" + getPersonal() + "', " + -            "priorityLevel: '" + getPriorityLevel() + "', " + -            "startTime: '" + getStartTime() + "', " +             "subject: '" + getSubject() + "'";     } - -    protected List<CloudNotificationEndpoint> getModifiableCloudNotificationEndpointList() { -        return cloudNotificationEndpointList; -    } - -    protected List<String> getModifiableNotifyBackURIList() { -        return notifyBackURIList; -    } }


feed icon

sventon 2.5.1