1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-26 14:02:06 +01:00

Rename NumberUtil.checkIfInUInt32Range() to requireUInt32

This commit is contained in:
Florian Schmaus 2019-06-02 10:46:53 +02:00
parent 726a2de273
commit 839e347676
3 changed files with 16 additions and 4 deletions

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright © 2015 Florian Schmaus * Copyright © 2015-2019 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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". * Checks if the given long is within the range of an unsigned 32-bit integer, the XML type "xs:unsignedInt".
* *
* @param value * @param value
* @deprecated use {@link #requireUInt32(long)} instead.
*/ */
@Deprecated
// TODO: Remove in Smack 4.5.
public static void checkIfInUInt32Range(long value) { 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) { if (value < 0) {
throw new IllegalArgumentException("unsigned 32-bit integers can't be negative"); throw new IllegalArgumentException("unsigned 32-bit integers can't be negative");
} }

View file

@ -99,7 +99,7 @@ public class PrivacyItem {
* @param order the order of this privacy item * @param order the order of this privacy item
*/ */
public PrivacyItem(Type type, String value, boolean allow, long order) { public PrivacyItem(Type type, String value, boolean allow, long order) {
NumberUtil.checkIfInUInt32Range(order); NumberUtil.requireUInt32(order);
this.type = type; this.type = type;
this.value = value; this.value = value;
this.allow = allow; this.allow = allow;

View file

@ -333,10 +333,10 @@ public abstract class ValidateElement implements ExtensionElement {
*/ */
public ListRange(Long min, Long max) { public ListRange(Long min, Long max) {
if (min != null) { if (min != null) {
NumberUtil.checkIfInUInt32Range(min); NumberUtil.requireUInt32(min);
} }
if (max != null) { if (max != null) {
NumberUtil.checkIfInUInt32Range(max); NumberUtil.requireUInt32(max);
} }
if (max == null && min == null) { if (max == null && min == null) {
throw new IllegalArgumentException("Either min or max must be given"); throw new IllegalArgumentException("Either min or max must be given");