1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-25 20:18:00 +01:00

Wip: Add first business classes

This commit is contained in:
Paul Schaub 2020-03-14 13:05:53 +01:00
parent 310a48f161
commit 1923d174e4
4 changed files with 99 additions and 2 deletions

View file

@ -0,0 +1,5 @@
package org.jivesoftware.smackx.mix.core;
public class MixChannel {
}

View file

@ -0,0 +1,26 @@
package org.jivesoftware.smackx.mix.core;
import org.jxmpp.jid.EntityBareJid;
public class MixParticipant {
private EntityBareJid jid;
private String nick;
public MixParticipant(EntityBareJid jid) {
this(jid, null);
}
public MixParticipant(EntityBareJid jid, String nick) {
this.jid = jid;
this.nick = nick;
}
public EntityBareJid getJid() {
return jid;
}
public String getNick() {
return nick;
}
}

View file

@ -0,0 +1,68 @@
package org.jivesoftware.smackx.mix.core;
import java.util.stream.IntStream;
import org.jivesoftware.smack.util.StringUtils;
public final class StableParticipantId implements CharSequence {
private final String id;
private StableParticipantId(String string) {
String id = StringUtils.requireNotNullNorEmpty(string.trim(),
"Stable Participant ID MUST NOT be null, nor empty.");
if (id.contains("#") || id.contains("/") || id.contains("@")) {
throw new IllegalArgumentException("Stable Participant ID MUST NOT contain the '#', '/' or '@' characters.");
}
this.id = id;
}
@Override
public int length() {
return id.length();
}
@Override
public char charAt(int i) {
return id.charAt(i);
}
@Override
public CharSequence subSequence(int i, int i1) {
return id.subSequence(i, i1);
}
@Override
public IntStream chars() {
return id.chars();
}
@Override
public IntStream codePoints() {
return id.codePoints();
}
@Override
public int hashCode() {
return id.hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (this == obj) {
return true;
}
if (!(obj instanceof StableParticipantId)) {
return false;
}
return toString().equals(((StableParticipantId) obj).toString());
}
@Override
public String toString() {
return id;
}
}

View file

@ -17,7 +17,6 @@
package org.jivesoftware.smackx.mix.core.provider;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
@ -40,6 +39,5 @@ public class LeaveElementProviderTest {
LeaveElement element = provider.parse(parser);
assertNotNull(element);
assertTrue(element instanceof LeaveElement.V1);
}
}