/*
 * Decompiled with CFR 0.152.
 */
package org.jxmpp.jid.impl;

import org.jxmpp.jid.BareJid;
import org.jxmpp.jid.DomainBareJid;
import org.jxmpp.jid.DomainFullJid;
import org.jxmpp.jid.FullJid;
import org.jxmpp.jid.Jid;
import org.jxmpp.jid.JidWithLocalpart;
import org.jxmpp.jid.JidWithResource;
import org.jxmpp.jid.impl.AbstractJid;
import org.jxmpp.jid.impl.DomainpartJid;
import org.jxmpp.jid.parts.Domainpart;
import org.jxmpp.jid.parts.Localpart;
import org.jxmpp.jid.parts.Resourcepart;
import org.jxmpp.stringprep.XmppStringprepException;

public class DomainAndResourcepartJid
extends AbstractJid
implements DomainFullJid {
    private final DomainBareJid domainBareJid;
    private final Resourcepart resource;
    private String cache;

    DomainAndResourcepartJid(String domain, String resource) throws XmppStringprepException {
        this.domainBareJid = new DomainpartJid(domain);
        this.resource = Resourcepart.from(resource);
    }

    @Override
    public String toString() {
        if (this.cache != null) {
            return this.cache;
        }
        this.cache = this.domainBareJid.toString() + '/' + this.resource;
        return this.cache;
    }

    @Override
    public DomainBareJid asDomainBareJid() {
        return this.domainBareJid;
    }

    @Override
    public final boolean hasNoResource() {
        return false;
    }

    @Override
    public BareJid asBareJidIfPossible() {
        return null;
    }

    @Override
    public FullJid asFullJidIfPossible() {
        return null;
    }

    @Override
    public DomainBareJid asDomainBareJidIfPossible() {
        return this.asDomainBareJid();
    }

    @Override
    public DomainFullJid asDomainFullJidIfPossible() {
        return this;
    }

    @Override
    public Resourcepart getResourceOrNull() {
        return this.getResourcepart();
    }

    @Override
    public boolean isParentOf(BareJid bareJid) {
        return false;
    }

    @Override
    public boolean isParentOf(FullJid fullJid) {
        return false;
    }

    @Override
    public boolean isParentOf(DomainBareJid domainBareJid) {
        return false;
    }

    @Override
    public boolean isParentOf(DomainFullJid domainFullJid) {
        return this.domainBareJid.equals(domainFullJid.getDomain()) && this.resource.equals(domainFullJid.getResourcepart());
    }

    @Override
    public Resourcepart getResourcepart() {
        return this.resource;
    }

    @Override
    public Jid withoutResource() {
        return this.asDomainBareJid();
    }

    @Override
    public Domainpart getDomain() {
        return this.domainBareJid.getDomain();
    }

    @Override
    public String asUnescapedString() {
        return this.toString();
    }

    @Override
    public Localpart maybeGetLocalpart() {
        return null;
    }

    @Override
    public Resourcepart maybeGetResourcepart() {
        return this.getResourcepart();
    }

    @Override
    public JidWithLocalpart asJidWithLocalpartIfPossible() {
        return null;
    }

    @Override
    public JidWithResource asJidWithResourcepartIfPossible() {
        return this;
    }
}
