思特奇智慧酒店云平台 v0.0.5版本的 MD5 值为:dedb172bb322639d79d7e0e26262fb5c

以下内容为反编译后的 DiscoverInfo.java 源代码,内容仅作参考


package org.jivesoftware.smackx.disco.packet;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smack.util.TypedCloneable;
import org.jivesoftware.smack.util.XmlStringBuilder;
public class DiscoverInfo extends IQ implements TypedCloneable<DiscoverInfo> {
    public static final String ELEMENT = "query";
    public static final String NAMESPACE = "http://jabber.org/protocol/disco#info";
    public boolean containsDuplicateFeatures;
    public final List<Feature> features;
    public final Set<Feature> featuresSet;
    public final List<Identity> identities;
    public final Set<String> identitiesSet;
    public String node;

    public static class Feature implements TypedCloneable<Feature> {
        public final String variable;

        public Feature(Feature feature) {
            this.variable = feature.variable;
        }

        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (obj == this) {
                return true;
            }
            if (obj.getClass() != Feature.class) {
                return false;
            }
            return this.variable.equals(((Feature) obj).variable);
        }

        public String getVar() {
            return this.variable;
        }

        public int hashCode() {
            return this.variable.hashCode();
        }

        public String toString() {
            return toXML().toString();
        }

        public XmlStringBuilder toXML() {
            XmlStringBuilder xmlStringBuilder = new XmlStringBuilder();
            xmlStringBuilder.halfOpenElement("feature");
            xmlStringBuilder.attribute("var", this.variable);
            xmlStringBuilder.closeEmptyElement();
            return xmlStringBuilder;
        }

        @Override
        public Feature clone() {
            return new Feature(this);
        }

        public Feature(CharSequence charSequence) {
            this(charSequence.toString());
        }

        public Feature(String str) {
            this.variable = (String) StringUtils.requireNotNullOrEmpty(str, "variable cannot be null");
        }
    }

    public static class Identity implements Comparable<Identity>, TypedCloneable<Identity> {
        public final String category;
        public final String key;
        public final String lang;
        public final String name;
        public final String type;

        public Identity(Identity identity) {
            this.category = identity.category;
            this.type = identity.type;
            this.key = identity.type;
            this.name = identity.name;
            this.lang = identity.lang;
        }

        public String getKey() {
            return this.key;
        }

        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (obj == this) {
                return true;
            }
            if (obj.getClass() != Identity.class) {
                return false;
            }
            Identity identity = (Identity) obj;
            if (this.key.equals(identity.key)) {
                String str = identity.lang;
                if (str == null) {
                    str = "";
                }
                String str2 = this.lang;
                if (str2 == null) {
                    str2 = "";
                }
                if (str.equals(str2)) {
                    String str3 = identity.name;
                    if (str3 == null) {
                        str3 = "";
                    }
                    return (this.name != null ? identity.name : "").equals(str3);
                }
                return false;
            }
            return false;
        }

        public String getCategory() {
            return this.category;
        }

        public String getLanguage() {
            return this.lang;
        }

        public String getName() {
            return this.name;
        }

        public String getType() {
            return this.type;
        }

        public int hashCode() {
            int hashCode = (this.key.hashCode() + 37) * 37;
            String str = this.lang;
            int hashCode2 = (hashCode + (str == null ? 0 : str.hashCode())) * 37;
            String str2 = this.name;
            return hashCode2 + (str2 != null ? str2.hashCode() : 0);
        }

        public boolean isOfCategoryAndType(String str, String str2) {
            return this.category.equals(str) && this.type.equals(str2);
        }

        public String toString() {
            return toXML().toString();
        }

        public XmlStringBuilder toXML() {
            XmlStringBuilder xmlStringBuilder = new XmlStringBuilder();
            xmlStringBuilder.halfOpenElement("identity");
            xmlStringBuilder.xmllangAttribute(this.lang);
            xmlStringBuilder.attribute("category", this.category);
            xmlStringBuilder.optAttribute("name", this.name);
            xmlStringBuilder.optAttribute("type", this.type);
            xmlStringBuilder.closeEmptyElement();
            return xmlStringBuilder;
        }

        @Override
        public Identity clone() {
            return new Identity(this);
        }

        @Override
        public int compareTo(Identity identity) {
            String str = identity.lang;
            if (str == null) {
                str = "";
            }
            String str2 = this.lang;
            if (str2 == null) {
                str2 = "";
            }
            String str3 = identity.type;
            if (str3 == null) {
                str3 = "";
            }
            String str4 = this.type;
            String str5 = str4 != null ? str4 : "";
            if (this.category.equals(identity.category)) {
                if (str5.equals(str3)) {
                    if (str2.equals(str)) {
                        return 0;
                    }
                    return str2.compareTo(str);
                }
                return str5.compareTo(str3);
            }
            return this.category.compareTo(identity.category);
        }

        public Identity(String str, String str2) {
            this(str, str2, null, null);
        }

        public Identity(String str, String str2, String str3) {
            this(str, str3, str2, null);
        }

        public Identity(String str, String str2, String str3, String str4) {
            this.category = (String) StringUtils.requireNotNullOrEmpty(str, "category cannot be null");
            this.type = (String) StringUtils.requireNotNullOrEmpty(str2, "type cannot be null");
            this.key = qx3.b(str, str2);
            this.name = str3;
            this.lang = str4;
        }
    }

    public DiscoverInfo() {
        super("query", NAMESPACE);
        this.features = new LinkedList();
        this.featuresSet = new HashSet();
        this.identities = new LinkedList();
        this.identitiesSet = new HashSet();
    }

    public boolean addFeature(String str) {
        return addFeature(new Feature(str));
    }

    public void addFeatures(Collection<String> collection) {
        if (collection == null) {
            return;
        }
        for (String str : collection) {
            addFeature(str);
        }
    }

    public void addIdentities(Collection<Identity> collection) {
        if (collection == null) {
            return;
        }
        for (Identity identity : collection) {
            addIdentity(identity);
        }
    }

    public void addIdentity(Identity identity) {
        this.identities.add(identity);
        this.identitiesSet.add(identity.getKey());
    }

    public boolean containsDuplicateFeatures() {
        return this.containsDuplicateFeatures;
    }

    public boolean containsDuplicateIdentities() {
        LinkedList<Identity> linkedList = new LinkedList();
        for (Identity identity : this.identities) {
            for (Identity identity2 : linkedList) {
                if (identity.equals(identity2)) {
                    return true;
                }
            }
            linkedList.add(identity);
        }
        return false;
    }

    public boolean containsFeature(CharSequence charSequence) {
        return this.features.contains(new Feature(charSequence));
    }

    public List<Feature> getFeatures() {
        return Collections.unmodifiableList(this.features);
    }

    @Override
    public IQ.IQChildElementXmlStringBuilder getIQChildElementBuilder(IQ.IQChildElementXmlStringBuilder iQChildElementXmlStringBuilder) {
        iQChildElementXmlStringBuilder.optAttribute("node", getNode());
        iQChildElementXmlStringBuilder.rightAngleBracket();
        for (Identity identity : this.identities) {
            iQChildElementXmlStringBuilder.append(identity.toXML());
        }
        for (Feature feature : this.features) {
            iQChildElementXmlStringBuilder.append(feature.toXML());
        }
        return iQChildElementXmlStringBuilder;
    }

    public List<Identity> getIdentities() {
        return Collections.unmodifiableList(this.identities);
    }

    public String getNode() {
        return this.node;
    }

    public boolean hasIdentity(String str, String str2) {
        return this.identitiesSet.contains(qx3.b(str, str2));
    }

    public void setNode(String str) {
        this.node = str;
    }

    public boolean addFeature(Feature feature) {
        this.features.add(feature);
        boolean add = this.featuresSet.add(feature);
        if (!add) {
            this.containsDuplicateFeatures = true;
        }
        return add;
    }

    @Override
    public DiscoverInfo clone() {
        return new DiscoverInfo(this);
    }

    public List<Identity> getIdentities(String str, String str2) {
        ArrayList arrayList = new ArrayList(this.identities.size());
        for (Identity identity : this.identities) {
            if (identity.getCategory().equals(str) && identity.getType().equals(str2)) {
                arrayList.add(identity);
            }
        }
        return arrayList;
    }

    public DiscoverInfo(DiscoverInfo discoverInfo) {
        super(discoverInfo);
        this.features = new LinkedList();
        this.featuresSet = new HashSet();
        this.identities = new LinkedList();
        this.identitiesSet = new HashSet();
        setNode(discoverInfo.getNode());
        for (Feature feature : discoverInfo.features) {
            addFeature(feature.clone());
        }
        for (Identity identity : discoverInfo.identities) {
            addIdentity(identity.clone());
        }
    }
}