1 | package geniusweb.voting;
|
---|
2 |
|
---|
3 | import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
---|
4 | import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
|
---|
5 | import com.fasterxml.jackson.annotation.JsonSubTypes;
|
---|
6 | import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
---|
7 | import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
|
---|
8 |
|
---|
9 | import geniusweb.inform.Agreements;
|
---|
10 | import geniusweb.voting.evaluatorwithvalue.LargestAgreementWithValue;
|
---|
11 |
|
---|
12 | /**
|
---|
13 | * Evaluates the {@link CollectedVotes}, determining the agreements and if the
|
---|
14 | * negotiation should continue.
|
---|
15 | *
|
---|
16 | * Implementations should be immutable and not serialize internal variables (eg
|
---|
17 | * @JsonIgnore them).
|
---|
18 | */
|
---|
19 | @JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, isGetterVisibility = Visibility.NONE)
|
---|
20 | @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = As.WRAPPER_OBJECT)
|
---|
21 | @JsonSubTypes({ @JsonSubTypes.Type(value = LargestAgreementWithValue.class) })
|
---|
22 | public interface VotingEvaluatorWithValue {
|
---|
23 | /**
|
---|
24 | * This function is the effective constructor. This mechanism serves several
|
---|
25 | * purposes:
|
---|
26 | * <ul>
|
---|
27 | * <li>It defines the constructor at interface level, so that we can ensure
|
---|
28 | * it's available and can call it given an instance,
|
---|
29 | * <li>We can use a (typically blank) instance of this to make more
|
---|
30 | * instances
|
---|
31 | * <li>You can cache intermediate results in the object for caching
|
---|
32 | * </ul>
|
---|
33 | *
|
---|
34 | * @param votes the Votes made by parties in the round to be evaluated.. All
|
---|
35 | * active parties in the negotiation must be available, even if
|
---|
36 | * they did not vote, to ensure that {@link #isFinished()} can
|
---|
37 | * work properly.
|
---|
38 | *
|
---|
39 | * @return new VotingEvaluation object containing the given votes.
|
---|
40 | */
|
---|
41 | VotingEvaluatorWithValue create(CollectedVotesWithValue votes);
|
---|
42 |
|
---|
43 | /**
|
---|
44 | *
|
---|
45 | * @return the agreements that is contained in the current available votes.
|
---|
46 | * The exact procedure varies with the implementation.
|
---|
47 | */
|
---|
48 | Agreements getAgreements();
|
---|
49 |
|
---|
50 | /**
|
---|
51 | *
|
---|
52 | * @return true iff the negotiation is finished after taking the agreement
|
---|
53 | * returned by {@link #getAgreements()}
|
---|
54 | */
|
---|
55 | boolean isFinished();
|
---|
56 | }
|
---|