org.swiftboot.util.BitUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of swiftboot-utils Show documentation
Show all versions of swiftboot-utils Show documentation
Utils library for enterprise applications
The newest version!
package org.swiftboot.util;
import java.util.Collection;
/**
* @author swiftech
**/
public class BitUtils {
/**
* 判断一个数字的二进制位是否和另外一个数字的二进制位重叠
*
* @param target
* @param body
* @param
* @return
*/
public static boolean contains(T target, T body) {
return (target.longValue() & body.longValue()) > 0;
}
/**
* 对集合中的所有长整数做逻辑或操作,相当于合并所有二进制位
*
* @param longs
* @return 返回操作结果
*/
public static long bitwiseOr(Collection longs) {
long result = 0;
if (longs == null)
return result;
for (Long lon : longs) {
if (lon != null) {
result = result | lon;
}
}
return result;
}
}