Last change
on this file was 127, checked in by Wouter Pasman, 6 years ago |
#41 ROLL BACK of rev.126 . So this version is equal to rev. 125
|
File size:
1.4 KB
|
Line | |
---|
1 | package genius.core.protocol;
|
---|
2 |
|
---|
3 | import java.util.ArrayList;
|
---|
4 | import java.util.List;
|
---|
5 |
|
---|
6 | import genius.core.parties.Mediator;
|
---|
7 | import genius.core.parties.NegotiationParty;
|
---|
8 |
|
---|
9 | /**
|
---|
10 | * Base class for all mediator-based protocols
|
---|
11 | *
|
---|
12 | * @author David Festen
|
---|
13 | */
|
---|
14 | public abstract class MediatorProtocol extends DefaultMultilateralProtocol {
|
---|
15 |
|
---|
16 | /**
|
---|
17 | * Returns the first mediator from a list of parties
|
---|
18 | *
|
---|
19 | * @param parties
|
---|
20 | * The list of parties to find the mediator in
|
---|
21 | * @return The first mediator in the given list, or null if no such entity
|
---|
22 | * exists.
|
---|
23 | */
|
---|
24 | public static Mediator getMediator(List<NegotiationParty> parties) {
|
---|
25 |
|
---|
26 | // Mediator should be first item, but this should find it wherever it
|
---|
27 | // is.
|
---|
28 | for (NegotiationParty party : parties) {
|
---|
29 | if (party instanceof Mediator) {
|
---|
30 | return (Mediator) party;
|
---|
31 | }
|
---|
32 | }
|
---|
33 |
|
---|
34 | // default case, no mediator found, return null
|
---|
35 | return null;
|
---|
36 | }
|
---|
37 |
|
---|
38 | /**
|
---|
39 | * Get the non-mediator parties. assumption: there are only zero or one
|
---|
40 | * mediators in the list
|
---|
41 | *
|
---|
42 | * @param parties
|
---|
43 | * The list of parties with mediator
|
---|
44 | * @return The given without the mediators
|
---|
45 | */
|
---|
46 | public static List<NegotiationParty> getNonMediators(List<NegotiationParty> parties) {
|
---|
47 |
|
---|
48 | List<NegotiationParty> nonMediators = new ArrayList<NegotiationParty>(parties);
|
---|
49 | nonMediators.remove(getMediator(parties));
|
---|
50 | return nonMediators;
|
---|
51 | }
|
---|
52 |
|
---|
53 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.