mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-12-22 20:47:57 +01:00
Rename AbstractIqBuilder subclasses to their designated names
This commit is contained in:
parent
6e32305987
commit
69767e9538
16 changed files with 58 additions and 64 deletions
|
@ -36,21 +36,21 @@ public abstract class AbstractIqBuilder<IB extends AbstractIqBuilder<IB>> extend
|
|||
super(stanzaId);
|
||||
}
|
||||
|
||||
public static IqBuilder createResponse(IqView request) {
|
||||
public static IqData createResponse(IqView request) {
|
||||
return createResponse(request, IQ.ResponseType.result);
|
||||
}
|
||||
|
||||
public static IqBuilder createErrorResponse(IqView request) {
|
||||
public static IqData createErrorResponse(IqView request) {
|
||||
return createResponse(request, IQ.ResponseType.error);
|
||||
}
|
||||
|
||||
protected static IqBuilder createResponse(IqView request, IQ.ResponseType responseType) {
|
||||
protected static IqData createResponse(IqView request, IQ.ResponseType responseType) {
|
||||
if (!(request.getType() == IQ.Type.get || request.getType() == IQ.Type.set)) {
|
||||
throw new IllegalArgumentException("IQ request must be of type 'set' or 'get'. Original IQ: " + request);
|
||||
}
|
||||
|
||||
IqBuilder commonResponseIqData = buildResponse(request, s -> {
|
||||
return StanzaBuilder.buildIq(s);
|
||||
IqData commonResponseIqData = buildResponse(request, s -> {
|
||||
return StanzaBuilder.buildIqData(s);
|
||||
});
|
||||
commonResponseIqData.ofType(responseType.getType());
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ package org.jivesoftware.smack.packet;
|
|||
|
||||
public class EmptyResultIQ extends IQ {
|
||||
|
||||
EmptyResultIQ(IqBuilder iqBuilder) {
|
||||
EmptyResultIQ(IqData iqBuilder) {
|
||||
super(iqBuilder, null, null);
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ public abstract class IQ extends Stanza implements IqView {
|
|||
|
||||
// TODO: Deprecate when stanza builder is ready.
|
||||
protected IQ(String childElementName, String childElementNamespace) {
|
||||
this(IqBuilder.EMPTY, childElementName, childElementNamespace);
|
||||
this(IqData.EMPTY, childElementName, childElementNamespace);
|
||||
}
|
||||
|
||||
protected IQ(AbstractIqBuilder<?> iqBuilder, String childElementName, String childElementNamespace) {
|
||||
|
|
|
@ -16,34 +16,29 @@
|
|||
*/
|
||||
package org.jivesoftware.smack.packet;
|
||||
|
||||
import org.jivesoftware.smack.packet.id.StandardStanzaIdSource;
|
||||
import org.jivesoftware.smack.packet.id.StanzaIdSource;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.util.Objects;
|
||||
|
||||
// TODO: Rename to IqData.
|
||||
public final class IqBuilder extends AbstractIqBuilder<IqBuilder> {
|
||||
public abstract class IqBuilder<IB extends IqBuilder<IB, I>, I extends IQ>
|
||||
extends AbstractIqBuilder<IB> {
|
||||
|
||||
static final IqBuilder EMPTY = new IqBuilder(StandardStanzaIdSource.DEFAULT);
|
||||
|
||||
IqBuilder(IqBuilder other) {
|
||||
protected IqBuilder(AbstractIqBuilder<?> other) {
|
||||
super(other);
|
||||
}
|
||||
|
||||
IqBuilder(StanzaIdSource stanzaIdSource) {
|
||||
super(stanzaIdSource);
|
||||
protected IqBuilder(XMPPConnection connection) {
|
||||
super(connection.getStanzaFactory().getStanzaIdSource());
|
||||
}
|
||||
|
||||
IqBuilder(String stanzaId) {
|
||||
protected IqBuilder(String stanzaId) {
|
||||
super(stanzaId);
|
||||
}
|
||||
|
||||
public IqBuilder ofType(IQ.Type type) {
|
||||
public IB ofType(IQ.Type type) {
|
||||
this.type = Objects.requireNonNull(type);
|
||||
return getThis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IqBuilder getThis() {
|
||||
return this;
|
||||
}
|
||||
public abstract I build();
|
||||
|
||||
}
|
||||
|
|
|
@ -16,30 +16,29 @@
|
|||
*/
|
||||
package org.jivesoftware.smack.packet;
|
||||
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.packet.id.StandardStanzaIdSource;
|
||||
import org.jivesoftware.smack.packet.id.StanzaIdSource;
|
||||
import org.jivesoftware.smack.util.Objects;
|
||||
|
||||
// TODO: Rename to IqBuilder.
|
||||
public abstract class IqBuilderWithBuild<IB extends IqBuilderWithBuild<IB, I>, I extends IQ>
|
||||
extends AbstractIqBuilder<IB> {
|
||||
public final class IqData extends AbstractIqBuilder<IqData> {
|
||||
|
||||
protected IqBuilderWithBuild(AbstractIqBuilder<?> other) {
|
||||
super(other);
|
||||
static final IqData EMPTY = new IqData(StandardStanzaIdSource.DEFAULT);
|
||||
|
||||
IqData(StanzaIdSource stanzaIdSource) {
|
||||
super(stanzaIdSource);
|
||||
}
|
||||
|
||||
protected IqBuilderWithBuild(XMPPConnection connection) {
|
||||
super(connection.getStanzaFactory().getStanzaIdSource());
|
||||
}
|
||||
|
||||
protected IqBuilderWithBuild(String stanzaId) {
|
||||
IqData(String stanzaId) {
|
||||
super(stanzaId);
|
||||
}
|
||||
|
||||
public IB ofType(IQ.Type type) {
|
||||
public IqData ofType(IQ.Type type) {
|
||||
this.type = Objects.requireNonNull(type);
|
||||
return getThis();
|
||||
}
|
||||
|
||||
public abstract I build();
|
||||
|
||||
@Override
|
||||
public IqData getThis() {
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -29,7 +29,7 @@ public abstract class SimpleIQ extends IQ {
|
|||
super(childElementName, childElementNamespace);
|
||||
}
|
||||
|
||||
protected SimpleIQ(IqBuilder iqBuilder, String childElementName, String childElementNamespace) {
|
||||
protected SimpleIQ(IqData iqBuilder, String childElementName, String childElementNamespace) {
|
||||
super(iqBuilder, childElementName, childElementNamespace);
|
||||
}
|
||||
|
||||
|
|
|
@ -289,8 +289,8 @@ public abstract class StanzaBuilder<B extends StanzaBuilder<B>> implements Stanz
|
|||
return new PresenceBuilder(presence, stanzaIdSource);
|
||||
}
|
||||
|
||||
public static IqBuilder buildIq(String stanzaId) {
|
||||
return new IqBuilder(stanzaId);
|
||||
public static IqData buildIqData(String stanzaId) {
|
||||
return new IqData(stanzaId);
|
||||
}
|
||||
|
||||
public static <SB extends StanzaBuilder<?>> SB buildResponse(StanzaView request, Function<SB, String> builderFromStanzaId) {
|
||||
|
|
|
@ -46,8 +46,8 @@ public final class StanzaFactory {
|
|||
return new PresenceBuilder(presence, stanzaIdSource);
|
||||
}
|
||||
|
||||
public IqBuilder buildIqStanza() {
|
||||
return new IqBuilder(stanzaIdSource);
|
||||
public IqData buildIqData() {
|
||||
return new IqData(stanzaIdSource);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.jivesoftware.smack.provider;
|
|||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.IqBuilder;
|
||||
import org.jivesoftware.smack.packet.IqData;
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException;
|
||||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
|
@ -58,7 +58,7 @@ public abstract class IQProvider<I extends IQ> extends IqProvider<I> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public final I parse(XmlPullParser parser, int initialDepth, IqBuilder iqData, XmlEnvironment xmlEnvironment)
|
||||
public final I parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment)
|
||||
throws XmlPullParserException, IOException, SmackParsingException {
|
||||
// Old-style IQ parsers do not need IqData.
|
||||
return parse(parser, initialDepth, xmlEnvironment);
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smack.provider;
|
|||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.IqBuilder;
|
||||
import org.jivesoftware.smack.packet.IqData;
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
@ -27,12 +27,12 @@ import org.jivesoftware.smack.xml.XmlPullParserException;
|
|||
|
||||
public abstract class IqProvider<I extends IQ> extends AbstractProvider<I> {
|
||||
|
||||
public final I parse(XmlPullParser parser, IqBuilder iqCommon)
|
||||
public final I parse(XmlPullParser parser, IqData iqCommon)
|
||||
throws XmlPullParserException, IOException, SmackParsingException {
|
||||
return parse(parser, iqCommon, null);
|
||||
}
|
||||
|
||||
public final I parse(XmlPullParser parser, IqBuilder iqData, XmlEnvironment outerXmlEnvironment)
|
||||
public final I parse(XmlPullParser parser, IqData iqData, XmlEnvironment outerXmlEnvironment)
|
||||
throws XmlPullParserException, IOException, SmackParsingException {
|
||||
final int initialDepth = parser.getDepth();
|
||||
final XmlEnvironment xmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment);
|
||||
|
@ -40,7 +40,7 @@ public abstract class IqProvider<I extends IQ> extends AbstractProvider<I> {
|
|||
return parse(parser, initialDepth, iqData, xmlEnvironment);
|
||||
}
|
||||
|
||||
public abstract I parse(XmlPullParser parser, int initialDepth, IqBuilder iqData, XmlEnvironment xmlEnvironment)
|
||||
public abstract I parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment)
|
||||
throws XmlPullParserException, IOException, SmackParsingException;
|
||||
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ import org.jivesoftware.smack.packet.EmptyResultIQ;
|
|||
import org.jivesoftware.smack.packet.ErrorIQ;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.IqBuilder;
|
||||
import org.jivesoftware.smack.packet.IqData;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.MessageBuilder;
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
|
@ -543,7 +543,7 @@ public class PacketParserUtils {
|
|||
StanzaError error = null;
|
||||
|
||||
final String id = parser.getAttributeValue("", "id");
|
||||
IqBuilder iqData = StanzaBuilder.buildIq(id);
|
||||
IqData iqData = StanzaBuilder.buildIqData(id);
|
||||
|
||||
final Jid to = ParserUtils.getJidAttribute(parser, "to");
|
||||
iqData.to(to);
|
||||
|
|
|
@ -18,14 +18,14 @@ package org.jivesoftware.smackx.iot.control.element;
|
|||
|
||||
import org.jivesoftware.smack.packet.AbstractIqBuilder;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.IqBuilder;
|
||||
import org.jivesoftware.smack.packet.IqData;
|
||||
|
||||
public class IoTSetResponse extends IQ {
|
||||
|
||||
public static final String ELEMENT = "setResponse";
|
||||
public static final String NAMESPACE = Constants.IOT_CONTROL_NAMESPACE;
|
||||
|
||||
public IoTSetResponse(IqBuilder iqBuilder) {
|
||||
public IoTSetResponse(IqData iqBuilder) {
|
||||
super(iqBuilder, ELEMENT, NAMESPACE);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ import java.util.Set;
|
|||
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.IqBuilder;
|
||||
import org.jivesoftware.smack.packet.IqData;
|
||||
import org.jivesoftware.smack.util.EqualsUtil;
|
||||
import org.jivesoftware.smack.util.HashCode;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
@ -148,7 +148,7 @@ public class DiscoverInfo extends IQ implements DiscoverInfoView, TypedCloneable
|
|||
*
|
||||
* @param feature the future.
|
||||
* @return true if the feature is new.
|
||||
* @deprecated use {@link DiscoverInfoBuilder#addFeature(Feature)} instead.
|
||||
* @deprecated use {@link DiscoverInfoBuilder#addFeature(DiscoverInfo.Feature)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
// TODO: Remove in Smack 4.5.
|
||||
|
@ -170,7 +170,7 @@ public class DiscoverInfo extends IQ implements DiscoverInfoView, TypedCloneable
|
|||
* Adds a new identity of the requested entity to the discovered information.
|
||||
*
|
||||
* @param identity the discovered entity's identity
|
||||
* @deprecated use {@link DiscoverInfoBuilder#addIdentity(Identity)} instead.
|
||||
* @deprecated use {@link DiscoverInfoBuilder#addIdentity(DiscoverInfo.Identity)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
// TODO: Remove in Smack 4.5.
|
||||
|
@ -313,7 +313,7 @@ public class DiscoverInfo extends IQ implements DiscoverInfoView, TypedCloneable
|
|||
return new DiscoverInfoBuilder(connection);
|
||||
}
|
||||
|
||||
public static DiscoverInfoBuilder builder(IqBuilder iqData) {
|
||||
public static DiscoverInfoBuilder builder(IqData iqData) {
|
||||
return new DiscoverInfoBuilder(iqData);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,12 +23,12 @@ import java.util.List;
|
|||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.IqBuilder;
|
||||
import org.jivesoftware.smack.packet.IqBuilderWithBuild;
|
||||
import org.jivesoftware.smack.packet.IqData;
|
||||
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo.Feature;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo.Identity;
|
||||
|
||||
public class DiscoverInfoBuilder extends IqBuilderWithBuild<DiscoverInfoBuilder, DiscoverInfo>
|
||||
public class DiscoverInfoBuilder extends IqBuilder<DiscoverInfoBuilder, DiscoverInfo>
|
||||
implements DiscoverInfoView {
|
||||
|
||||
private final List<Feature> features = new ArrayList<>();
|
||||
|
@ -36,7 +36,7 @@ public class DiscoverInfoBuilder extends IqBuilderWithBuild<DiscoverInfoBuilder,
|
|||
|
||||
private String node;
|
||||
|
||||
DiscoverInfoBuilder(IqBuilder iqCommon) {
|
||||
DiscoverInfoBuilder(IqData iqCommon) {
|
||||
super(iqCommon);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.disco.provider;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.packet.IqBuilder;
|
||||
import org.jivesoftware.smack.packet.IqData;
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException;
|
||||
import org.jivesoftware.smack.provider.IqProvider;
|
||||
|
@ -39,7 +39,7 @@ import org.jivesoftware.smackx.disco.packet.DiscoverInfoBuilder;
|
|||
public class DiscoverInfoProvider extends IqProvider<DiscoverInfo> {
|
||||
|
||||
@Override
|
||||
public DiscoverInfo parse(XmlPullParser parser, int initialDepth, IqBuilder iqData, XmlEnvironment xmlEnvironment)
|
||||
public DiscoverInfo parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment)
|
||||
throws XmlPullParserException, IOException, SmackParsingException {
|
||||
DiscoverInfoBuilder discoverInfoBuilder = DiscoverInfo.builder(iqData);
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ package org.jivesoftware.smackx.ping.packet;
|
|||
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.IqBuilder;
|
||||
import org.jivesoftware.smack.packet.IqData;
|
||||
import org.jivesoftware.smack.packet.SimpleIQ;
|
||||
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
@ -39,14 +39,14 @@ public class Ping extends SimpleIQ {
|
|||
}
|
||||
|
||||
public Ping(XMPPConnection connection, Jid to) {
|
||||
this(connection.getStanzaFactory().buildIqStanza(), to);
|
||||
this(connection.getStanzaFactory().buildIqData(), to);
|
||||
}
|
||||
|
||||
public Ping(IqBuilder iqBuilder, Jid to) {
|
||||
public Ping(IqData iqBuilder, Jid to) {
|
||||
super(iqBuilder.to(to).ofType(IQ.Type.get), ELEMENT, NAMESPACE);
|
||||
}
|
||||
|
||||
public Ping(IqBuilder iqBuilder) {
|
||||
public Ping(IqData iqBuilder) {
|
||||
super(iqBuilder, ELEMENT, NAMESPACE);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue