1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-09 00:59:39 +02:00

Delete TypedCloneable

This commit is contained in:
Florian Schmaus 2020-06-14 17:38:51 +02:00
parent 18c2c37ad0
commit 3f9ca68134
9 changed files with 67 additions and 61 deletions

View file

@ -22,11 +22,11 @@ import java.util.Locale;
import javax.xml.namespace.QName;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.util.EqualsUtil;
import org.jivesoftware.smack.util.HashCode;
import org.jivesoftware.smack.util.Objects;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smack.util.TypedCloneable;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jxmpp.jid.Jid;
@ -58,7 +58,7 @@ import org.jxmpp.stringprep.XmppStringprepException;
* @author Matt Tucker
*/
public final class Message extends MessageOrPresence<MessageBuilder>
implements MessageView, TypedCloneable<Message> {
implements MessageView {
public static final String ELEMENT = "message";
public static final String BODY = "body";
@ -371,6 +371,16 @@ public final class Message extends MessageOrPresence<MessageBuilder>
return StanzaBuilder.buildMessageFrom(this, getStanzaId());
}
@Override
public MessageBuilder asBuilder(String id) {
return StanzaBuilder.buildMessageFrom(this, id);
}
@Override
public MessageBuilder asBuilder(XMPPConnection connection) {
return connection.getStanzaFactory().buildMessageStanzaFrom(this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
@ -409,7 +419,10 @@ public final class Message extends MessageOrPresence<MessageBuilder>
* instance.
* </p>
* @return a clone of this message.
* @deprecated use {@link #asBuilder()} instead.
*/
// TODO: Remove in Smack 4.5.
@Deprecated
@Override
public Message clone() {
return new Message(this);

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2019 Florian Schmaus
* Copyright 2019-2020 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,6 +16,8 @@
*/
package org.jivesoftware.smack.packet;
import org.jivesoftware.smack.XMPPConnection;
public abstract class MessageOrPresence<MPB extends MessageOrPresenceBuilder<?, ?>> extends Stanza {
@Deprecated
@ -33,4 +35,8 @@ public abstract class MessageOrPresence<MPB extends MessageOrPresenceBuilder<?,
public abstract MPB asBuilder();
public abstract MPB asBuilder(String id);
public abstract MPB asBuilder(XMPPConnection connection);
}

View file

@ -20,9 +20,9 @@ package org.jivesoftware.smack.packet;
import java.util.List;
import java.util.Locale;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.util.Objects;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smack.util.TypedCloneable;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jxmpp.jid.Jid;
@ -61,7 +61,7 @@ import org.jxmpp.jid.Jid;
* @author Matt Tucker
*/
public final class Presence extends MessageOrPresence<PresenceBuilder>
implements PresenceView, TypedCloneable<Presence> {
implements PresenceView {
public static final String ELEMENT = "presence";
@ -282,6 +282,16 @@ public final class Presence extends MessageOrPresence<PresenceBuilder>
return StanzaBuilder.buildPresenceFrom(this, getStanzaId());
}
@Override
public PresenceBuilder asBuilder(String id) {
return StanzaBuilder.buildPresenceFrom(this, id);
}
@Override
public PresenceBuilder asBuilder(XMPPConnection connection) {
return connection.getStanzaFactory().buildPresenceStanzaFrom(this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
@ -343,7 +353,10 @@ public final class Presence extends MessageOrPresence<PresenceBuilder>
* instance.
* </p>
* @return a clone of this presence.
* @deprecated use {@link #asBuilder()} instead.
*/
// TODO: Remove in Smack 4.5.
@Deprecated
@Override
public Presence clone() {
return new Presence(this);
@ -354,7 +367,10 @@ public final class Presence extends MessageOrPresence<PresenceBuilder>
*
* @return a "clone" of this presence with a different stanza ID.
* @since 4.1.2
* @deprecated use {@link #asBuilder(XMPPConnection)} or {@link #asBuilder(String)}instead.
*/
// TODO: Remove in Smack 4.5.
@Deprecated
public Presence cloneWithNewId() {
Presence clone = clone();
clone.setNewStanzaId();

View file

@ -1,6 +1,6 @@
/**
*
* Copyright © 2015-2019 Florian Schmaus
* Copyright © 2015-2020 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -34,7 +34,7 @@ import java.util.Set;
* @param <K> the type of the keys the map uses.
* @param <V> the type of the values the map uses.
*/
public class MultiMap<K, V> implements TypedCloneable<MultiMap<K, V>> {
public class MultiMap<K, V> {
/**
* The constant value {@value}.

View file

@ -1,34 +0,0 @@
/**
*
* Copyright 2015 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smack.util;
/**
* An extended version of {@link java.lang.Cloneable}, which defines a generic {@link #clone()}
* method.
*
* @param <T> the type returned by {@link #clone()}.
*/
public interface TypedCloneable<T> extends Cloneable {
/**
* Clone this instance.
*
* @return a cloned version of this instance.
*/
T clone();
}