Ignore:
Timestamp:
01/28/20 10:19:54 (4 years ago)
Author:
bart
Message:

Update 28 jan 2020

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocol/src/main/java/geniusweb/protocol/session/saop/SAOPSettings.java

    r1 r10  
    44import java.util.LinkedList;
    55import java.util.List;
     6import java.util.stream.Collectors;
    67
    78import com.fasterxml.jackson.annotation.JsonCreator;
     
    1112import geniusweb.protocol.session.SessionProtocol;
    1213import geniusweb.protocol.session.SessionSettings;
     14import geniusweb.protocol.session.TeamOfPartiesAndProfiles;
    1315import geniusweb.references.PartyWithProfile;
    1416import tudelft.utilities.logging.Reporter;
    1517
    1618public class SAOPSettings implements SessionSettings {
    17         private final List<PartyWithProfile> participants;
     19        private final List<SaopPartyWithProfile> participants;
    1820        private final Deadline deadline;
    1921
     
    2830        @JsonCreator
    2931        public SAOPSettings(
    30                         @JsonProperty("participants") List<PartyWithProfile> participants,
     32                        @JsonProperty("participants") List<SaopPartyWithProfile> participants,
    3133                        @JsonProperty("deadline") Deadline deadline) {
    3234                this.participants = participants;
     
    5153
    5254        @Override
    53         public List<PartyWithProfile> getParticipants() {
     55        public List<TeamOfPartiesAndProfiles> getTeams() {
    5456                return Collections.unmodifiableList(participants);
    5557        }
     
    6062        public Deadline getDeadline() {
    6163                return deadline;
     64        }
     65
     66        @Override
     67        public List<PartyWithProfile> getAllParties() {
     68                return participants.stream()
     69                                .map(particip -> particip.getAllParties().get(0))
     70                                .collect(Collectors.toList());
    6271        }
    6372
     
    101110
    102111        @Override
    103         public SessionSettings with(PartyWithProfile party) {
    104                 List<PartyWithProfile> newparts = new LinkedList<>(participants);
    105                 newparts.add(party);
     112        public SessionSettings with(TeamOfPartiesAndProfiles party) {
     113                if (!(party instanceof SaopPartyWithProfile))
     114                        throw new IllegalArgumentException(
     115                                        "Added party must be SaopPartyWithProfile but got "
     116                                                        + party);
     117                List<SaopPartyWithProfile> newparts = new LinkedList<>(participants);
     118                newparts.add((SaopPartyWithProfile) party);
    106119                return new SAOPSettings(newparts, deadline);
    107120        }
Note: See TracChangeset for help on using the changeset viewer.