/*
 * 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.LocalAndDomainpartJid;
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 LocalDomainAndResourcepartJid
extends AbstractJid
implements FullJid {
    private final BareJid bareJid;
    private final Resourcepart resource;
    private String cache;
    private String unescapedCache;

    LocalDomainAndResourcepartJid(String localpart, String domain, String resource) throws XmppStringprepException {
        this(new LocalAndDomainpartJid(localpart, domain), Resourcepart.from(resource));
    }

    LocalDomainAndResourcepartJid(BareJid bareJid, Resourcepart resource) {
        this.bareJid = bareJid;
        this.resource = resource;
    }

    public final Resourcepart getResource() {
        return this.resource;
    }

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

    @Override
    public String asUnescapedString() {
        if (this.unescapedCache != null) {
            return this.unescapedCache;
        }
        this.unescapedCache = this.bareJid.asUnescapedString() + '/' + this.resource;
        return this.unescapedCache;
    }

    @Override
    public BareJid asBareJid() {
        return this.bareJid;
    }

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

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

    @Override
    public BareJid asBareJidIfPossible() {
        return this.asBareJid();
    }

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

    @Override
    public DomainBareJid asDomainBareJidIfPossible() {
        return null;
    }

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

    @Override
    public Localpart getLocalpartOrNull() {
        return this.bareJid.getLocalpart();
    }

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

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

    @Override
    public boolean isParentOf(FullJid fullJid) {
        return this.equals(fullJid);
    }

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

    @Override
    public boolean isParentOf(DomainFullJid domainFullJid) {
        return false;
    }

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

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

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

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

    @Override
    public Localpart maybeGetLocalpart() {
        return this.bareJid.getLocalpart();
    }

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

    @Override
    public Localpart getLocalpart() {
        return this.bareJid.getLocalpart();
    }

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

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