From e85c1881d7370414b89c32ecd181208a94d0022f Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Tue, 10 Mar 2015 22:46:40 +0100 Subject: [PATCH] Add TypedCloneable --- .../jivesoftware/smack/packet/Message.java | 3 +- .../jivesoftware/smack/packet/Presence.java | 3 +- .../smack/util/TypedCloneable.java | 34 +++++++++++++++++++ .../smackx/disco/packet/DiscoverInfo.java | 7 ++-- 4 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 smack-core/src/main/java/org/jivesoftware/smack/util/TypedCloneable.java diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/Message.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/Message.java index f08c3c653..eae77c265 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/packet/Message.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/Message.java @@ -24,6 +24,7 @@ import java.util.List; import java.util.Locale; import java.util.Set; +import org.jivesoftware.smack.util.TypedCloneable; import org.jivesoftware.smack.util.XmlStringBuilder; /** @@ -50,7 +51,7 @@ import org.jivesoftware.smack.util.XmlStringBuilder; * * @author Matt Tucker */ -public final class Message extends Stanza implements Cloneable { +public final class Message extends Stanza implements TypedCloneable { public static final String ELEMENT = "message"; public static final String BODY = "body"; diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/Presence.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/Presence.java index 7f347dd51..c50e35f74 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/packet/Presence.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/Presence.java @@ -20,6 +20,7 @@ package org.jivesoftware.smack.packet; import java.util.Locale; import org.jivesoftware.smack.util.Objects; +import org.jivesoftware.smack.util.TypedCloneable; import org.jivesoftware.smack.util.XmlStringBuilder; /** @@ -55,7 +56,7 @@ import org.jivesoftware.smack.util.XmlStringBuilder; * * @author Matt Tucker */ -public final class Presence extends Stanza implements Cloneable { +public final class Presence extends Stanza implements TypedCloneable { public static final String ELEMENT = "presence"; diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/TypedCloneable.java b/smack-core/src/main/java/org/jivesoftware/smack/util/TypedCloneable.java new file mode 100644 index 000000000..226b5e3d8 --- /dev/null +++ b/smack-core/src/main/java/org/jivesoftware/smack/util/TypedCloneable.java @@ -0,0 +1,34 @@ +/** + * + * 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 the type returned by {@link #clone()}. + */ +public interface TypedCloneable extends Cloneable { + + /** + * Clone this instance. + * + * @return a cloned version of this instance. + */ + public T clone(); + +} diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/packet/DiscoverInfo.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/packet/DiscoverInfo.java index e4f5ca0f6..774259868 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/packet/DiscoverInfo.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/packet/DiscoverInfo.java @@ -18,6 +18,7 @@ package org.jivesoftware.smackx.disco.packet; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.util.StringUtils; +import org.jivesoftware.smack.util.TypedCloneable; import org.jivesoftware.smack.util.XmlStringBuilder; import org.jxmpp.util.XmppStringUtils; @@ -38,7 +39,7 @@ import java.util.Set; * * @author Gaston Dombiak */ -public class DiscoverInfo extends IQ implements Cloneable { +public class DiscoverInfo extends IQ implements TypedCloneable { public static final String ELEMENT = QUERY_ELEMENT; public static final String NAMESPACE = "http://jabber.org/protocol/disco#info"; @@ -266,7 +267,7 @@ public class DiscoverInfo extends IQ implements Cloneable { * attributes. * */ - public static class Identity implements Comparable, Cloneable { + public static class Identity implements Comparable, TypedCloneable { private final String category; private final String type; @@ -473,7 +474,7 @@ public class DiscoverInfo extends IQ implements Cloneable { * as well as specific feature types of interest, if any (e.g., for the purpose of feature * negotiation). */ - public static class Feature implements Cloneable { + public static class Feature implements TypedCloneable { private final String variable;