1 | package geniusweb.protocol;
|
---|
2 |
|
---|
3 | import java.util.List;
|
---|
4 |
|
---|
5 | import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
---|
6 | import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
|
---|
7 | import com.fasterxml.jackson.annotation.JsonSubTypes;
|
---|
8 | import com.fasterxml.jackson.annotation.JsonSubTypes.Type;
|
---|
9 | import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
---|
10 |
|
---|
11 | import geniusweb.protocol.session.SessionResult;
|
---|
12 | import geniusweb.protocol.session.SessionState;
|
---|
13 | import geniusweb.protocol.tournament.TournamentState;
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * The current state of the session/tournament. Must be (de)serializabl;e so
|
---|
17 | * that it can be restarted if a crash occurs. Notice that this restart
|
---|
18 | * functionality is not yet available.
|
---|
19 | * <p>
|
---|
20 | * In general the state contains all the information to control the flow of the
|
---|
21 | * negotiation: who did what, are we finished, etc. This object may be stored to
|
---|
22 | * record the final result as well
|
---|
23 | */
|
---|
24 | @JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, isGetterVisibility = Visibility.NONE)
|
---|
25 | @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.WRAPPER_OBJECT)
|
---|
26 | @JsonSubTypes({ @Type(value = SessionState.class),
|
---|
27 | @Type(value = TournamentState.class) })
|
---|
28 | public interface NegoState {
|
---|
29 |
|
---|
30 | /**
|
---|
31 | * @return the settings that were used to create this Nego
|
---|
32 | */
|
---|
33 | NegoSettings getSettings();
|
---|
34 |
|
---|
35 | /**
|
---|
36 | * @param currentTimeMs the current time in ms since 1970, see
|
---|
37 | * {@link System#currentTimeMillis()}
|
---|
38 | * @return true iff this is the final state. A state can be final because
|
---|
39 | * the protocol decided so, eg a deal was achieved, the deadline was
|
---|
40 | * reached or someone made a protocol error. If true, no more state
|
---|
41 | * changes can occur, including no more protocol errors.
|
---|
42 | */
|
---|
43 | boolean isFinal(long currentTimeMs);
|
---|
44 |
|
---|
45 | /**
|
---|
46 | *
|
---|
47 | * @return List of the{@link SessionResult}s. Each SessionResult is a short
|
---|
48 | * report of the final outcome. Assumes {@link #isFinal(long)}.
|
---|
49 | * result may be undefined if not.
|
---|
50 | */
|
---|
51 | List<SessionResult> getResults();
|
---|
52 | }
|
---|