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