Address should have Extensions

Issue #70 closed
Daniel Gultsch created an issue

Hi,

XEP-0033 in sections 4.7 allows for extensions (child elements) of the Address element unfortunately the class is final so I can not extend this myself. Making it non-final would be an easy solution but adding the addExension/hasExtension/getExtension methods from stanza might be a better one.

I'm pretty new to this library (looking good so far by the way. Thank you!) so I'm unsure if there is a better approach. Would you accept a patch that adds those three methods mentioned above?

Comments (3)

  1. Christian Schudt repo owner

    Oh, you are right. At the moment all extensions like Address are immutable and actually I would like to keep that pattern for the sake of consistency at least.

    What do you think about the following?

    • a new constructor taking a Collection<Object>, addAll to a private List<Object>
    • List<Object> getExtensions() returning an unmodifiable list.
    • <T> T getExtension(Class<T> clazz) (as in Stanza class)
    • optionally hasExtension() as well

    addExtension would make it mutable. Probably harmless, it's just that I prefer immutable classes.

    Sure, you can do a PR!

    Btw.: How did you recognize the lack of the extension? Afaik most servers don't even support XEP-0033 and surely not custom extensions. It's lacking in the XML schema, too, that's why I've overlooked it.

  2. Log in to comment