mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
fix CombinationAnnotationElement bug
This commit is contained in:
parent
010f0554ae
commit
0aeb4d2512
@ -10,11 +10,13 @@
|
||||
* 【http】 body方法传null跳过而非报错(issue#I12AP2@Gitee)
|
||||
* 【core】 TimeInterval增加intervalPretty方法(issue#I12A6T@Gitee)
|
||||
* 【core】 改进ArrayUtil.toString,提高性能
|
||||
|
||||
### Bug修复
|
||||
* 【core】 修复DateUtil.offset导致的时区错误问题(issue#I1294O@Gitee)
|
||||
* 【core】 修复RuntimeUtil.exec重载导致的问题(issue#544@Github)
|
||||
* 【db】 修复StatementUtil.getGeneratedKeys返回主键数量不足问题
|
||||
* 【db】 修复锁的问题(issue#546@Github)
|
||||
* 【db】 修复CombinationAnnotationElement问题(issue#547@Github)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -13,6 +13,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
|
||||
/**
|
||||
* 组合注解 对JDK的原生注解机制做一个增强,支持类似Spring的组合注解。<br>
|
||||
@ -79,12 +80,12 @@ public class CombinationAnnotationElement implements AnnotatedElement, Serializa
|
||||
* @param element 元素
|
||||
*/
|
||||
private void init(AnnotatedElement element) {
|
||||
Annotation[] declaredAnnotations = element.getDeclaredAnnotations();
|
||||
final Annotation[] declaredAnnotations = element.getDeclaredAnnotations();
|
||||
this.declaredAnnotationMap = new HashMap<>();
|
||||
parseDeclared(declaredAnnotations);
|
||||
|
||||
Annotation[] annotations = element.getAnnotations();
|
||||
if(declaredAnnotations == annotations) {
|
||||
final Annotation[] annotations = element.getAnnotations();
|
||||
if(ObjectUtil.equal(declaredAnnotations, annotations)) {
|
||||
this.annotationMap = this.declaredAnnotationMap;
|
||||
}else {
|
||||
this.annotationMap = new HashMap<>();
|
||||
@ -112,7 +113,7 @@ public class CombinationAnnotationElement implements AnnotatedElement, Serializa
|
||||
/**
|
||||
* 进行递归解析注解,直到全部都是元注解为止
|
||||
*
|
||||
* @param element Class, Method, Field等
|
||||
* @param annotations Class, Method, Field等
|
||||
*/
|
||||
private void parse(Annotation[] annotations) {
|
||||
Class<? extends Annotation> annotationType;
|
||||
|
@ -1195,13 +1195,11 @@ public class NumberUtil {
|
||||
public static boolean isDouble(String s) {
|
||||
try {
|
||||
Double.parseDouble(s);
|
||||
if (s.contains(".")) {
|
||||
return true;
|
||||
return s.contains(".");
|
||||
} catch (NumberFormatException ignore) {
|
||||
// ignore
|
||||
}
|
||||
return false;
|
||||
} catch (NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1281,13 +1279,12 @@ public class NumberUtil {
|
||||
}
|
||||
|
||||
Random ran = new Random();
|
||||
Set<Integer> set = new HashSet<Integer>();
|
||||
Set<Integer> set = new HashSet<>();
|
||||
while (set.size() < size) {
|
||||
set.add(begin + ran.nextInt(end - begin));
|
||||
}
|
||||
|
||||
Integer[] ranArr = set.toArray(new Integer[size]);
|
||||
return ranArr;
|
||||
return set.toArray(new Integer[size]);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------- range
|
||||
@ -1553,14 +1550,7 @@ public class NumberUtil {
|
||||
* @since 3.0.1
|
||||
*/
|
||||
public static int compare(int x, int y) {
|
||||
if (x == y) {
|
||||
return 0;
|
||||
}
|
||||
if (x < y) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
return Integer.compare(x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1574,14 +1564,7 @@ public class NumberUtil {
|
||||
* @since 3.0.1
|
||||
*/
|
||||
public static int compare(long x, long y) {
|
||||
if (x == y) {
|
||||
return 0;
|
||||
}
|
||||
if (x < y) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
return Long.compare(x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1595,14 +1578,7 @@ public class NumberUtil {
|
||||
* @since 3.0.1
|
||||
*/
|
||||
public static int compare(short x, short y) {
|
||||
if (x == y) {
|
||||
return 0;
|
||||
}
|
||||
if (x < y) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
return Short.compare(x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1616,7 +1592,7 @@ public class NumberUtil {
|
||||
* @since 3.0.1
|
||||
*/
|
||||
public static int compare(byte x, byte y) {
|
||||
return x - y;
|
||||
return Byte.compare(x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2078,7 +2054,7 @@ public class NumberUtil {
|
||||
* @since 4.0.7
|
||||
*/
|
||||
public static int partValue(int total, int partCount, boolean isPlusOneWhenHasRem) {
|
||||
int partValue = 0;
|
||||
int partValue;
|
||||
if (total % partCount == 0) {
|
||||
partValue = total / partCount;
|
||||
} else {
|
||||
@ -2222,7 +2198,7 @@ public class NumberUtil {
|
||||
* byte数组转int,使用大端字节序(高位字节在前,低位字节在后)<br>
|
||||
* 见:http://www.ruanyifeng.com/blog/2016/11/byte-order.html
|
||||
*
|
||||
* @param bytes
|
||||
* @param bytes byte数组
|
||||
* @return int
|
||||
* @since 4.4.5
|
||||
*/
|
||||
@ -2307,6 +2283,24 @@ public class NumberUtil {
|
||||
return new BigInteger(1, mag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查是否为有效的数字<br>
|
||||
* 检查Double和Float是否为无限大,或者Not a Number<br>
|
||||
* 非数字类型和Null将返回true
|
||||
*
|
||||
* @param number 被检查类型
|
||||
* @return 检查结果,非数字类型和Null将返回true
|
||||
* @since 4.6.7
|
||||
*/
|
||||
public static boolean isValidNumber(Number number) {
|
||||
if (number instanceof Double) {
|
||||
return (false == ((Double) number).isInfinite()) && (false == ((Double) number).isNaN());
|
||||
} else if (number instanceof Float) {
|
||||
return (false == ((Float) number).isInfinite()) && (false == ((Float) number).isNaN());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------- Private method start
|
||||
private static int mathSubnode(int selectNum, int minNum) {
|
||||
if (selectNum == minNum) {
|
||||
|
@ -13,10 +13,7 @@ import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.Collection;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 对象工具类,包括判空、克隆、序列化等操作
|
||||
@ -37,10 +34,11 @@ public class ObjectUtil {
|
||||
* @param obj1 对象1
|
||||
* @param obj2 对象2
|
||||
* @return 是否相等
|
||||
* @see Objects#equals(Object, Object)
|
||||
*/
|
||||
public static boolean equal(Object obj1, Object obj2) {
|
||||
// return (obj1 != null) ? (obj1.equals(obj2)) : (obj2 == null);
|
||||
return (obj1 == obj2) || (obj1 != null && obj1.equals(obj2));
|
||||
return Objects.equals(obj1, obj2);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -138,7 +136,7 @@ public class ObjectUtil {
|
||||
return ((Collection<?>) obj).contains(element);
|
||||
}
|
||||
if (obj instanceof Map) {
|
||||
return ((Map<?, ?>) obj).values().contains(element);
|
||||
return ((Map<?, ?>) obj).containsValue(element);
|
||||
}
|
||||
|
||||
if (obj instanceof Iterator) {
|
||||
@ -325,7 +323,7 @@ public class ObjectUtil {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T cloneByStream(T obj) {
|
||||
if (null == obj || false == (obj instanceof Serializable)) {
|
||||
if (false == (obj instanceof Serializable)) {
|
||||
return null;
|
||||
}
|
||||
final FastByteArrayOutputStream byteOut = new FastByteArrayOutputStream();
|
||||
@ -352,7 +350,7 @@ public class ObjectUtil {
|
||||
* @return 序列化后的字节码
|
||||
*/
|
||||
public static <T> byte[] serialize(T obj) {
|
||||
if (null == obj || false == (obj instanceof Serializable)) {
|
||||
if (false == (obj instanceof Serializable)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -393,7 +391,7 @@ public class ObjectUtil {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T unserialize(byte[] bytes) {
|
||||
ObjectInputStream ois = null;
|
||||
ObjectInputStream ois;
|
||||
try {
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
|
||||
ois = new ObjectInputStream(bais);
|
||||
@ -423,16 +421,8 @@ public class ObjectUtil {
|
||||
* @return 检查结果,非数字类型和Null将返回true
|
||||
*/
|
||||
public static boolean isValidIfNumber(Object obj) {
|
||||
if (obj != null && obj instanceof Number) {
|
||||
if (obj instanceof Double) {
|
||||
if (((Double) obj).isInfinite() || ((Double) obj).isNaN()) {
|
||||
return false;
|
||||
}
|
||||
} else if (obj instanceof Float) {
|
||||
if (((Float) obj).isInfinite() || ((Float) obj).isNaN()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (obj instanceof Number) {
|
||||
return NumberUtil.isValidNumber((Number) obj);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -490,7 +480,12 @@ public class ObjectUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 将Object转为String
|
||||
* 将Object转为String<br>
|
||||
* 策略为:
|
||||
* <pre>
|
||||
* 1、null转为"null"
|
||||
* 2、调用Convert.toStr(Object)转换
|
||||
* </pre>
|
||||
*
|
||||
* @param obj Bean对象
|
||||
* @return Bean所有字段转为Map后的字符串
|
||||
@ -498,10 +493,10 @@ public class ObjectUtil {
|
||||
*/
|
||||
public static String toString(Object obj) {
|
||||
if (null == obj) {
|
||||
return "null";
|
||||
return StrUtil.NULL;
|
||||
}
|
||||
if (obj instanceof Map) {
|
||||
return ((Map<?, ?>) obj).toString();
|
||||
return obj.toString();
|
||||
}
|
||||
|
||||
return Convert.toStr(obj);
|
||||
|
@ -9,17 +9,17 @@ package cn.hutool.crypto;
|
||||
public enum Mode{
|
||||
/** 无模式 */
|
||||
NONE,
|
||||
/** Cipher Block Chaining */
|
||||
/** 密码分组连接模式(Cipher Block Chaining) */
|
||||
CBC,
|
||||
/** Cipher Feedback */
|
||||
/** 密文反馈模式(Cipher Feedback) */
|
||||
CFB,
|
||||
/** A simplification of OFB */
|
||||
/** 计数器模式(A simplification of OFB) */
|
||||
CTR,
|
||||
/** Cipher Text Stealing */
|
||||
CTS,
|
||||
/** Electronic Codebook */
|
||||
/** 电子密码本模式(Electronic CodeBook) */
|
||||
ECB,
|
||||
/** Output Feedback */
|
||||
/** 输出反馈模式(Output Feedback) */
|
||||
OFB,
|
||||
/** Propagating Cipher Block */
|
||||
PCBC;
|
||||
|
Loading…
x
Reference in New Issue
Block a user