zoukankan      html  css  js  c++  java
  • 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);






  • 相关阅读:
    如何在一个页面后面随机跳转到多个链接地址Math.floor()和Math.random()
    thinkphp中volist标签
    PHP中删除数组空值的方法
    PHP实现四种基本排序算法
    如何解决自动加载与模板中(如Smarty)的自动加载冲突的问题
    GD库常用函数
    内网最小化安装CentOS后,想安装ISO文件中的包怎么办呢?
    Elasticsearch插件安装
    python类的反射使用方法
    python类的继承
  • 原文地址:https://www.cnblogs.com/YuyuanNo1/p/7927948.html
Copyright © 2011-2022 走看看