mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 14:22:05 +01:00
Immutable objects must not implemented TypedCloneable
also add a note about that to the developers documentation.
This commit is contained in:
parent
0b322419ce
commit
41b74ec13c
2 changed files with 20 additions and 6 deletions
|
@ -1,10 +1,25 @@
|
||||||
PacketExtension
|
General Rules
|
||||||
===============
|
=============
|
||||||
|
|
||||||
|
All classes which subclass `TopLevelStreamElement` and `ExtensionElement` must either
|
||||||
|
|
||||||
|
1. be immutable (and ideally provide a Builder)
|
||||||
|
2. implemented `TypedCloneable`
|
||||||
|
|
||||||
|
and must be `Serializable`.
|
||||||
|
The reason that it must be either 1. or 2. is that it makes no sense to clone an inmutable instance.
|
||||||
|
|
||||||
|
Note that there is legacy code in Smack which does not follow these rules. Patches welcome.
|
||||||
|
|
||||||
|
ExtensionElement
|
||||||
|
================
|
||||||
|
|
||||||
|
Extension elements are XML elements that are used in various parts and levels of stanzas.
|
||||||
|
|
||||||
The static `from(Stanza)` Method
|
The static `from(Stanza)` Method
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
Every PacketExtension class must have a static `from()` method that retrieves that extension for a given Stanza (if any).
|
Every ExtensionElement class must have a static `from()` method that retrieves that extension for a given Stanza (if any).
|
||||||
|
|
||||||
Sample Code
|
Sample Code
|
||||||
|
|
||||||
|
@ -14,4 +29,4 @@ public static RSMSet from(Stanza) {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Sometimes certain PacketExtension's are only found in one stanza type, in that case, specify the parameter type. For example `public static CarbonExtension getFrom(Message)`.
|
Sometimes certain ExtensionElement's are only found in one stanza type, in that case, specify the parameter type. For example `public static CarbonExtension getFrom(Message)`.
|
||||||
|
|
|
@ -19,7 +19,6 @@ package org.jivesoftware.smackx.muc.packet;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.NamedElement;
|
import org.jivesoftware.smack.packet.NamedElement;
|
||||||
import org.jivesoftware.smack.util.TypedCloneable;
|
|
||||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
import org.jxmpp.jid.BareJid;
|
import org.jxmpp.jid.BareJid;
|
||||||
|
|
||||||
|
@ -30,7 +29,7 @@ import org.jxmpp.jid.BareJid;
|
||||||
*
|
*
|
||||||
* @author Gaston Dombiak
|
* @author Gaston Dombiak
|
||||||
*/
|
*/
|
||||||
public class Destroy implements NamedElement, TypedCloneable<Destroy>, Serializable {
|
public class Destroy implements NamedElement, Serializable {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue