All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.wassilak.emom.message.header.Header Maven / Gradle / Ivy

There is a newer version: 2.5
Show newest version
package com.wassilak.emom.message.header;

import java.io.Serializable;
import java.util.Date;

/**
 * The Header interface defines the behavior of the emom Header object, which
 * represents the header of a Message. Headers contain metadata about it's
 * Message, and as such are typically used to locate the desired message
 * without having to load and inspect the Message's payload.
 * 

* Copyright (C) 2014 John Wassilak ([email protected]) *

* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. *

* This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. *

* You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. */ public interface Header extends Serializable, Comparable

{ /** * The MIN_TTL constant represents the minimum allowable value of a * Header's timeToLive property. */ public static final Long MIN_TTL = 0L; /** * The MAX_TTL constant represents the maximum allowable value of a * Header's timeToLive property. */ public static final Long MAX_TTL = Long.MAX_VALUE - 1; /** * The MIN_ID_LENGTH constant represents the minimum allowable length * of a Header's id property. */ public static final Integer MIN_ID_LENGTH = 1; /** * The MAX_ID_LENGTH constant represents the maximum allowable length * of a Header's id property. */ public static final Integer MAX_ID_LENGTH = 20; /** * The getID method returns the ID of the message. * * @return The ID of the message. */ public String getID(); /** * The getTimeToLive method returns the time that the message can live * before it expires, in milliseconds. * * @return The length of time before the message should expire. */ public Long getTimeToLive(); /** * The getTimeStamp method returns the date/time that the message was sent. * If the message hasn't been sent yet, this will typically be null. * * @return The date/time that the message was sent, null if it hasn't been * sent. */ public Date getTimeStamp(); /** * The setTimeStamp method sets the date/time that the message was sent. * * @param timeStamp The date/time to set the message's timestamp to. */ public void setTimeStamp(Date timeStamp); /** * The equals method indicates whether some other object is "equal to" * this one. * * @param obj the reference object with which to compare. * @return true if this object is the same as the obj argument; * false otherwise. */ @Override public boolean equals(Object obj); /** * The hashCode method returns a hash code value for the object. * * @return a hash code value for this object. */ @Override public int hashCode(); /** * The compareTo method compares this object with the specified object * for order. Returns a negative integer, zero, or a positive integer as * this object is less than, equal to, or greater than the specified * object. The comparison is based on timeStamp, so Headers with a later * timeStamp are placed later in a list. Null timeStamps are handled such * that Headers with null timestamps are less than those with populated * ones. Not that, per java spec, null Headers throw an exception. * * @param o the object to be compared. * @return a negative integer, zero, or a positive integer as this object * is less than, equal to, or greater than the specified object. */ @Override public int compareTo(Header o); }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy