From 839e34767640e07834cd80137c2e36168816362a Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sun, 2 Jun 2019 10:46:53 +0200 Subject: [PATCH] Rename NumberUtil.checkIfInUInt32Range() to requireUInt32 --- .../org/jivesoftware/smack/util/NumberUtil.java | 14 +++++++++++++- .../smackx/privacy/packet/PrivacyItem.java | 2 +- .../xdatavalidation/packet/ValidateElement.java | 4 ++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/NumberUtil.java b/smack-core/src/main/java/org/jivesoftware/smack/util/NumberUtil.java index 8ca973370..4261ca097 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/util/NumberUtil.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/util/NumberUtil.java @@ -1,6 +1,6 @@ /** * - * Copyright © 2015 Florian Schmaus + * Copyright © 2015-2019 Florian Schmaus * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,8 +22,20 @@ public class NumberUtil { * Checks if the given long is within the range of an unsigned 32-bit integer, the XML type "xs:unsignedInt". * * @param value + * @deprecated use {@link #requireUInt32(long)} instead. */ + @Deprecated + // TODO: Remove in Smack 4.5. public static void checkIfInUInt32Range(long value) { + requireUInt32(value); + } + + /** + * Checks if the given long is within the range of an unsigned 32-bit integer, the XML type "xs:unsignedInt". + * + * @param value + */ + public static void requireUInt32(long value) { if (value < 0) { throw new IllegalArgumentException("unsigned 32-bit integers can't be negative"); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/packet/PrivacyItem.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/packet/PrivacyItem.java index 4189aefd5..0ad6c91a4 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/packet/PrivacyItem.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/packet/PrivacyItem.java @@ -99,7 +99,7 @@ public class PrivacyItem { * @param order the order of this privacy item */ public PrivacyItem(Type type, String value, boolean allow, long order) { - NumberUtil.checkIfInUInt32Range(order); + NumberUtil.requireUInt32(order); this.type = type; this.value = value; this.allow = allow; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/xdatavalidation/packet/ValidateElement.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdatavalidation/packet/ValidateElement.java index 4dc7fd62b..a44de76a1 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/xdatavalidation/packet/ValidateElement.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdatavalidation/packet/ValidateElement.java @@ -333,10 +333,10 @@ public abstract class ValidateElement implements ExtensionElement { */ public ListRange(Long min, Long max) { if (min != null) { - NumberUtil.checkIfInUInt32Range(min); + NumberUtil.requireUInt32(min); } if (max != null) { - NumberUtil.checkIfInUInt32Range(max); + NumberUtil.requireUInt32(max); } if (max == null && min == null) { throw new IllegalArgumentException("Either min or max must be given");