通过位运算求数字的和,判断选中的选项

判断一个元素是否存在:(要判断的那个数若是包含在Status(通过或运算得出来的值)中通过与运算只能得到自己的值)

/**
* 获取产品
*
* @param
* @return
*/
@Override
public List<Product> getProduct(Long appUserId) {
List<Product> list = productMapper.getProduct(appUserId);
if (list != null && list.size() > 0) {
for (Product product : list) {
if (!StringUtils.isEmpty(product.getIouProductLogoUrl())) {
product.setIouProductLogoUrl(OSSUtil.imgUrl + product.getIouProductLogoUrl());
}
//拼接年化率
BigDecimal rate = product.getInterestRateAnnual().multiply(BigDecimal.valueOf(100));
product.setAnnualRate(rate.intValue() + "%");
//解析所需材料项数
Integer item = product.getMaterialItems();
String[] arrT = new String[4];
for (int i = 0; i < 4; i++) {
if ((item & 1) == 1) {
arrT[0] = "身份证";
}
if ((item & 2) == 2) {
arrT[1] = "银行卡";
}
if ((item & 4) == 4) {
arrT[2] = "运营商";
}
if ((item & 8) == 8) {
arrT[8] = "芝麻信用";
}
}
StringBuffer sb = new StringBuffer();
for (int i = 0; i < arrT.length; i++) {
if (arrT[i] == null)
continue;
sb.append(arrT[i] + " ");
}
String s = sb.toString();
product.setMaterialItemsStr(s);
}
}

logger.debug("获取产品:{}", list);
return list;
}

关于位运算相关知识

 

你是技术宅么?那就加入我们吧!点击下方链接 或 扫描二维码 即可。

欢迎加入 优快云技术交流群2:(点击即可加群)QQ群:456543087

               优快云技术交流群(已满员):(点击即可加群)QQ群:681223095。  

商务合作@群主,谢谢!

因经常有人留言,未能及时查看到和回复,所以特建此群,以方便交流。方便问题讨论,有问题和没有问题的小伙伴均可加入,用作自我学习和共同进步。本博主不一定长期在线,但是qq群里会有很多热心的小伙伴,大家一起讨论解决问题。
右边的二维码是公众号。关注公众号,更多学习内容给予推送,争取每日更新

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值