mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-22 18:48:00 +01:00
Enforce jingle s5b transport invariants.
There can only either be one info element or multiple candidates, but not both. Enforced this in the JingleS5BTransportBuilder
This commit is contained in:
parent
541c9ecfdd
commit
bae840ebf7
1 changed files with 12 additions and 1 deletions
|
@ -93,7 +93,7 @@ public class JingleS5BTransport extends JingleContentTransport {
|
|||
private String streamId;
|
||||
private String dstAddr;
|
||||
private Bytestream.Mode mode;
|
||||
private ArrayList<JingleContentTransportCandidate> candidates = new ArrayList<>();
|
||||
private final ArrayList<JingleContentTransportCandidate> candidates = new ArrayList<>();
|
||||
private JingleContentTransportInfo info;
|
||||
|
||||
public Builder setStreamId(String sid) {
|
||||
|
@ -112,11 +112,22 @@ public class JingleS5BTransport extends JingleContentTransport {
|
|||
}
|
||||
|
||||
public Builder addTransportCandidate(JingleS5BTransportCandidate candidate) {
|
||||
if (info != null) {
|
||||
throw new IllegalStateException("Builder has already an info set. " +
|
||||
"The transport can only have either an info or transport candidates, not both.");
|
||||
}
|
||||
this.candidates.add(candidate);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setTransportInfo(JingleContentTransportInfo info) {
|
||||
if (!candidates.isEmpty()) {
|
||||
throw new IllegalStateException("Builder has already at least one candidate set. " +
|
||||
"The transport can only have either an info or transport candidates, not both.");
|
||||
}
|
||||
if (this.info != null) {
|
||||
throw new IllegalStateException("Builder has already an info set.");
|
||||
}
|
||||
this.info = info;
|
||||
return this;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue