001: /*
002: * <copyright>
003: *
004: * Copyright 2002-2004 BBNT Solutions, LLC
005: * under sponsorship of the Defense Advanced Research Projects
006: * Agency (DARPA).
007: *
008: * You can redistribute this software and/or modify it under the
009: * terms of the Cougaar Open Source License as published on the
010: * Cougaar Open Source Website (www.cougaar.org).
011: *
012: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
013: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
014: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
015: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
016: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
017: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
018: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
019: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
020: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
021: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
022: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
023: *
024: * </copyright>
025: */
026: package org.cougaar.core.examples.mobility.ldm;
027:
028: import java.io.Serializable;
029: import org.cougaar.core.mobility.Ticket;
030: import org.cougaar.core.mts.MessageAddress;
031:
032: /**
033: * Immutable step configuration options.
034: */
035: public final class StepOptions implements Serializable {
036:
037: private final Object ownerId;
038: private final MessageAddress source;
039: private final MessageAddress target;
040: private final Ticket ticket;
041: private final long pauseTime;
042: private final long timeoutTime;
043:
044: public StepOptions(Object ownerId, MessageAddress source,
045: MessageAddress target, Ticket ticket, long pauseTime,
046: long timeoutTime) {
047: this .ownerId = ownerId;
048: this .source = source;
049: this .target = target;
050: this .ticket = ticket;
051: this .pauseTime = pauseTime;
052: this .timeoutTime = timeoutTime;
053: if (ticket == null) {
054: throw new IllegalArgumentException("null ticket");
055: }
056: if ((pauseTime > 0) && (timeoutTime > 0)
057: && (pauseTime > timeoutTime)) {
058: throw new IllegalArgumentException("pause time ("
059: + pauseTime + ") must be <="
060: + " to the timeout time (" + timeoutTime + ")");
061: }
062: }
063:
064: public Object getOwnerId() {
065: return ownerId;
066: }
067:
068: public MessageAddress getSource() {
069: return source;
070: }
071:
072: public MessageAddress getTarget() {
073: return target;
074: }
075:
076: public Ticket getTicket() {
077: return ticket;
078: }
079:
080: public long getPauseTime() {
081: return pauseTime;
082: }
083:
084: public long getTimeoutTime() {
085: return timeoutTime;
086: }
087:
088: public boolean equals(Object o) {
089: if (o == this ) {
090: return true;
091: } else if (!(o instanceof StepOptions)) {
092: return false;
093: } else {
094: StepOptions so = (StepOptions) o;
095: return ((ownerId != null) ? (ownerId.equals(so.ownerId))
096: : (so.ownerId == null))
097: && ((source != null) ? (source.equals(so.source))
098: : (so.source == null))
099: && ((target != null) ? (target.equals(so.target))
100: : (so.target == null))
101: && ticket.equals(so.ticket)
102: && (pauseTime == so.pauseTime)
103: && (timeoutTime == so.timeoutTime);
104: }
105: }
106:
107: public int hashCode() {
108: return ((ownerId != null) ? ownerId.hashCode() : 5)
109: ^ ticket.hashCode()
110: ^ ((source != null) ? source.hashCode() : 7);
111: }
112:
113: public String toString() {
114: return "step {" + "\n ownerId: " + ownerId + "\n source: "
115: + source + "\n target: " + target + "\n ticket: "
116: + ticket + "\n pause: " + pauseTime
117: + "\n timeout: " + timeoutTime + "\n}";
118: }
119: }
|