package geniusweb.protocol; import java.util.List; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonSubTypes.Type; import com.fasterxml.jackson.annotation.JsonTypeInfo; import geniusweb.protocol.session.SessionResult; import geniusweb.protocol.session.SessionState; import geniusweb.protocol.tournament.TournamentState; /** * The current state of the session/tournament. Must be (de)serializabl;e so * that it can be restarted if a crash occurs. Notice that this restart * functionality is not yet available. *

* In general the state contains all the information to control the flow of the * negotiation: who did what, are we finished, etc. This object may be stored to * record the final result as well */ @JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, isGetterVisibility = Visibility.NONE) @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.WRAPPER_OBJECT) @JsonSubTypes({ @Type(value = SessionState.class), @Type(value = TournamentState.class) }) public interface NegoState { /** * @return the settings that were used to create this Nego */ NegoSettings getSettings(); /** * @param currentTimeMs the current time in ms since 1970, see * {@link System#currentTimeMillis()} * @return true iff this is the final state. A state can be final because * the protocol decided so, eg a deal was achieved, the deadline was * reached or someone made a protocol error. If true, no more state * changes can occur, including no more protocol errors. */ boolean isFinal(long currentTimeMs); /** * * @return List of the{@link SessionResult}s. Each SessionResult is a short * report of the final outcome. Assumes {@link #isFinal(long)}. * result may be undefined if not. */ List getResults(); }