java的list集合操作List转化List
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 implements Iterable {
。。。。。
}
如下
List departBooks = departBookManager.findByDepartId(sysDepart1.getDepartId());
List departSeeIds = FluentIterable.from(departBooks).transform(new Function() {
@Override
public Long apply(SysDepartBook p) {
return p.getDepartIdSee();
}
}).toList();
、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、
List 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 fileIdStrList = StringUtil.splitString(fileIds);
// List list = JSONArray.parseArray(fileIds, Long.class);
List list = FluentIterable.from(fileIdStrList).transform(new Function() {
@Override
public Long apply(String p) {
return Long.parseLong(p);
}
}).toList();
List fids = new ArrayList();
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);