Proceed.java

 1package eu.siacs.conversations.xmpp.jingle.stanzas;
 2
 3import com.google.common.base.Preconditions;
 4import com.google.common.primitives.Ints;
 5
 6import eu.siacs.conversations.xml.Element;
 7import eu.siacs.conversations.xml.Namespace;
 8
 9public class Proceed extends Element {
10    private Proceed() {
11        super("propose", Namespace.JINGLE_MESSAGE);
12    }
13
14    public static Proceed upgrade(final Element element) {
15        Preconditions.checkArgument("proceed".equals(element.getName()));
16        Preconditions.checkArgument(Namespace.JINGLE_MESSAGE.equals(element.getNamespace()));
17        final Proceed propose = new Proceed();
18        propose.setAttributes(element.getAttributes());
19        propose.setChildren(element.getChildren());
20        return propose;
21    }
22
23    public Integer getDeviceId() {
24        final Element device = this.findChild("device");
25        final String id = device == null ? null : device.getAttribute("id");
26        if (id == null) {
27            return null;
28        }
29        return Ints.tryParse(id);
30    }
31}