java的list集合操作List<T>转化List<Long>
java的list集合操作List<T>转化List<Long> package com.google.common.collect;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.SortedSet;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nullable; @GwtCompatible(
emulated = true
)
public abstract class FluentIterable<E> implements Iterable<E> {
。。。。。
}
如下
List<SysDepartBook> departBooks = departBookManager.findByDepartId(sysDepart1.getDepartId());
List<Long> departSeeIds = FluentIterable.from(departBooks).transform(new Function<SysDepartBook, Long>() {
@Override
public Long apply(SysDepartBook p) {
return p.getDepartIdSee();
}
}).toList(); 、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、
List<String> areaId = Splitter.on(",").omitEmptyStrings().trimResults().splitToList(employeeReportForm.getAreaId());
package com.google.common.base; import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.CheckReturnValue; @GwtCompatible(
emulated = true
)
public final class Splitter {
。。。。。
} ==========================================
String fileIds = innerEntity.getFileIds();
List<String> fileIdStrList = StringUtil.splitString(fileIds);
// List<Long> list = JSONArray.parseArray(fileIds, Long.class);
List<Long> list = FluentIterable.from(fileIdStrList).transform(new Function<String, Long>() {
@Override
public Long apply(String p) {
return Long.parseLong(p);
}
}).toList(); List<Long> fids = new ArrayList<Long>();
HashSet hs1 = new HashSet(list);
HashSet hs2 = new HashSet(idList);
hs1.removeAll(hs2);
fids.addAll(hs1); String ids = Joiner.on(",").join(fids);
innerEntity.setFileIds(ids);
archiveInnerMapper.updateByPrimaryKeySelective(innerEntity);
java的list集合操作List<T>转化List<Long>的更多相关文章
- java中的集合操作类(未完待续)
申明: 实习生的肤浅理解,如发现有错误之处.还望大牛们多多指点 废话 事实上我写java的后台操作,我每次都会遇到一条语句:List<XXXXX> list = new ArrayList ...
- Java中常用集合操作
一.Map 名值对存储的. 常用派生类HashMap类 添加: put(key,value)往集合里添加数据 删除: clear()删除所有 remove(key)清除单个,根据k来找 获取: siz ...
- java中对集合操作的易错点01
今天用for循环遍历集合,对集合中满足条件的元素进行remove操作报错:ConcurrentModificationException 所以,在遍历集合进行增.删操作时,要使用迭代器的方式 publ ...
- JAVASE02-Unit04: 集合框架 、 集合操作 —— 线性表
Unit04: 集合框架 . 集合操作 -- 线性表 操作集合元素相关方法 package day04; import java.util.ArrayList; import java.util.Co ...
- JAVA中的集合容器操作类
目录 JAVA中的集合容器操作类 List集合 ArrayList的操作方法说明 LinkedList Stack Set Map Queue 总结 JAVA中的集合容器操作类 Java容器类库总共分 ...
- JAVA集合操作的利器:CollectionUtils
使用 CollectionUtils 中四个方法之一执行集合操作.这四种分别是 union(),intersection();disjunction(); subtract(); 下列例子就是演示了如 ...
- Java基础系列--集合之ArrayList
原创作品,可以转载,但是请标注出处地址:http://www.cnblogs.com/V1haoge/p/8494618.html 一.概述 ArrayList是Java集合体系中最常使用,也是最简单 ...
- 大数据技术之_16_Scala学习_08_数据结构(下)-集合操作+模式匹配
第十一章 数据结构(下)-集合操作11.1 集合元素的映射-map11.1.1 map 映射函数的操作11.1.2 高阶函数基本使用案例1+案例211.1.3 使用 map 映射函数来解决11.1.4 ...
- 第6节:Java基础 - 三大集合(上)
第6节:Java基础 - 三大集合(上) 本小节是Java基础篇章的第四小节,主要介绍Java中的常用集合知识点,涉及到的内容包括Java中的三大集合的引出,以及HashMap,Hashtable和C ...
随机推荐
- div 边框
1.四个边框border-left 设置左边框,一般单独设置左边框样式使用border-right 设置右边框,一般单独设置右边框样式使用border-top 设置上边框,一般单独设置上边框样式使用b ...
- Windoows窗口程序五
程序执行机制 过程驱动-程序的执行过程是按照预订好的顺序执行. 事件驱动-程序的执行是无序,用户可以根据需要随机触发相应的事件. Win32窗口程序就是采用事件驱动方式执行,也就是消息机制. 当系统通 ...
- 【转】【C#】ZIP、RAR 压缩与解压缩
压缩文件夹 源码如下 using System; using System.Data; using System.Configuration; using System.Web; using Syst ...
- 将ORACLE数据库更改为归档模式;写出步骤
解答:具体步骤如下: 1),以exp方式在线备份数据库到指定位置: 2),观察当前数据库是以服务器参数文件(spfile)方式启动还是以参数文件(pfile)方式启动: SQL> show pa ...
- nodejs基础 -- NPM 使用介绍
npm:是nodejs的包管理工具,随NodeJS一起安装的,能解决NodeJS代码部署上的很多问题,如: 1.允许用户从NPM服务器下载别人编写的第三方包到本地使用. 2.允许用户从NPM服务器下载 ...
- vncserver的安装和使用 2
环境:RedHat Linux 6企业版.Xwindows:gnome (红帽默认安装的图形界面) 尽管我们可以使用SSH连接远程通过字符界面来操作Linux,但是对于更多熟悉图形人来说是很不方便的, ...
- endl的读法
endl是“end line”的缩写,所以它应该念作“endELL”而不是“endONE”.
- js 补零方法,如果不足位数
var pad = function() { var tbl = []; return function(num, n) { var len = n-num.toString().length; if ...
- [ATL/WTL]_[中级]_[保存CBitmap到文件-保存屏幕内容到文件]
场景: 1. 在做图片处理时,比方放大后或加特效后须要保存CBitmap(HBITMAP)到文件. 2.截取屏幕内容到文件时. 3.不须要增加第3方库时. 说明: 这段代码部分来自网上.第一次学atl ...
- Spark-Hadoop、Hive、Spark 之间是什么关系?(转)
大数据本身是个很宽泛的概念,Hadoop生态圈(或者泛生态圈)基本上都是为了处理超过单机尺度的数据处理而诞生的.你可以把它比作一个厨房所以需要的各种工具.锅碗瓢盆,各有各的用处,互相之间又有重合.你可 ...