From 921f4109a088389e08120f99c9aaf93e0db3bc8a Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sun, 14 Jul 2024 12:22:51 +0200 Subject: [PATCH] [jxmpp-jid] Add JidCreate.entity(Bare|Full)From with CharSequence --- .../java/org/jxmpp/jid/impl/JidCreate.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/jxmpp-jid/src/main/java/org/jxmpp/jid/impl/JidCreate.java b/jxmpp-jid/src/main/java/org/jxmpp/jid/impl/JidCreate.java index 0c9d205..50ddbdf 100644 --- a/jxmpp-jid/src/main/java/org/jxmpp/jid/impl/JidCreate.java +++ b/jxmpp-jid/src/main/java/org/jxmpp/jid/impl/JidCreate.java @@ -1117,6 +1117,18 @@ public static EntityBareJid entityBareFrom(Localpart localpart, Domainpart domai return new LocalAndDomainpartJid(localpart, domain); } + /** + * Get a {@link EntityBareJid} constructed from the given {@link Localpart} and {@link Domainpart}. + * + * @param localpart a localpart. + * @param domain a domainpart. + * @return a bare JID constructed from the given parts. + * @throws XmppStringprepException if an error occurs. + */ + public static EntityBareJid entityBareFrom(CharSequence localpart, Domainpart domain) throws XmppStringprepException { + return new LocalAndDomainpartJid(Localpart.fromUnescaped(localpart), domain); + } + /** * Get a {@link EntityBareJid} from a given {@link CharSequence} or {@code null} if the input does not represent a JID. * @@ -1377,6 +1389,19 @@ public static EntityFullJid entityFullFrom(Localpart localpart, Domainpart domai return entityFullFrom(entityBareFrom(localpart, domainpart), resource); } + /** + * Get a {@link EntityFullJid} constructed from the given parts. + * + * @param localpart the localpart. + * @param domainpart the domainpart. + * @param resource the resourcepart. + * @return a full JID. + * @throws XmppStringprepException if an error occurs. + */ + public static EntityFullJid entityFullFrom(CharSequence localpart, Domainpart domainpart, CharSequence resource) throws XmppStringprepException { + return entityFullFrom(entityBareFrom(Localpart.fromUnescaped(localpart), domainpart), Resourcepart.from(resource)); + } + /** * Get a {@link EntityFullJid} constructed from a {@link EntityBareJid} and a {@link Resourcepart}. *