From 95534da53f39fcf29042e98c7ab8bf27be6e6278 Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Sat, 28 Apr 2018 13:24:46 +0200 Subject: [PATCH] Make receipts id optional (SMACK-815) Remove @author and change javadoc --- .../smackx/receipts/DeliveryReceipt.java | 12 ++++++++---- .../smackx/receipts/ReceiptReceivedListener.java | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceipt.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceipt.java index 9f936771d..6ee618c8a 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceipt.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceipt.java @@ -1,6 +1,6 @@ /** * - * Copyright 2013-2015 the original author or authors + * Copyright 2013-2018 the original author or authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,6 @@ import java.util.Map; import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.provider.EmbeddedExtensionProvider; -import org.jivesoftware.smack.util.StringUtils; import org.jivesoftware.smack.util.XmlStringBuilder; /** @@ -41,9 +40,14 @@ public class DeliveryReceipt implements ExtensionElement { private final String id; public DeliveryReceipt(String id) { - this.id = StringUtils.requireNotNullOrEmpty(id, "id must not be null"); + this.id = id; } + /** + * Get the id of the message that has been delivered. + * + * @return id of the delivered message or {@code null}. + */ public String getId() { return id; } @@ -61,7 +65,7 @@ public class DeliveryReceipt implements ExtensionElement { @Override public XmlStringBuilder toXML() { XmlStringBuilder xml = new XmlStringBuilder(this); - xml.attribute("id", id); + xml.optAttribute("id", id); xml.closeEmptyElement(); return xml; } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/ReceiptReceivedListener.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/ReceiptReceivedListener.java index f0f7cf55a..1f48910d7 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/ReceiptReceivedListener.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/ReceiptReceivedListener.java @@ -35,7 +35,8 @@ public interface ReceiptReceivedListener { * * @param fromJid the jid that send this receipt * @param toJid the jid which received this receipt - * @param receiptId the message ID of the stanza which has been received and this receipt is for + * @param receiptId the message ID of the stanza which has been received and this receipt is for. + * This might be {@code null}. * @param receipt the receipt */ void onReceiptReceived(Jid fromJid, Jid toJid, String receiptId, Stanza receipt);