/*
* Copyright 2014-2017 ZuoBian.com All right reserved. This software is the confidential and proprietary information of
* ZuoBian.com ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only
* in accordance with the terms of the license agreement you entered into with ZuoBian.com.
*/
package com.zb.app.common.core.lang;
import java.beans.BeanInfo;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.MethodUtils;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.poi.ss.formula.functions.T;
import org.apache.velocity.runtime.parser.node.MathUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author zxc Jun 16, 2014 12:12:52 AM
*/
@SuppressWarnings({ "unchecked", "hiding" })
public class CollectionUtils {
private static Logger logger = LoggerFactory.getLogger(CollectionUtils.class);
/**
* Collection c 其中包含了重复的元素,你想再创建一个 Collection 并清除重复元素
*
* @param c
* @return
*/
public static <E> Set<E> removeDups(Collection<E> c) {
return new LinkedHashSet<E>(c);
}
/**
* List<T> ---> List<Map<key,?>>
*/
public static <T extends Object> List<Map<String, ?>> toMapList(Collection<T> values, String... propertys) {
if (Argument.isEmptyArray(propertys) || values == null || values.isEmpty()) {
return Collections.<Map<String, ?>> emptyList();
}
List<Map<String, ?>> list = new ArrayList<Map<String, ?>>();
for (T value : values) {
Map<String, Object> valueMap = new HashMap<String, Object>(propertys.length);
for (String property : propertys) {
try {
Object propertyValue = PropertyUtils.getProperty(value, property);
if (propertyValue == null) {
valueMap.put(property, null);
}
Object wapper = valueMap.get(property);
if (wapper == null) {
valueMap.put(property, propertyValue);
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
continue;
}
}
list.add(valueMap);
}
return list;
}
/**
* 用来去掉List中空值和相同项的。
*
* @param list
* @return
*/
public static List<T> removeSameItem(List<T> list) {
List<T> difList = new ArrayList<T>();
for (T t : list) {
if (t != null && !difList.contains(t)) {
difList.add(t);
}
}
return difList;
}
public static List<String> getProperty(Collection<?> values, String property) {
if (values == null || values.isEmpty()) {
return Collections.<String> emptyList();
}
List<String> valueResult = new ArrayList<String>(values.size());
for (Object value : values) {
try {
String propertyValue = BeanUtils.getProperty(value, property);
valueResult.add(propertyValue);
} catch (Exception e) {
logger.error(e.getMessage(), e);
continue;
}
}
return valueResult;
}
// set ---> list
public static <T> List<T> convertSetToList(Set<T> set) {
List<T> list = new ArrayList<T>();
if (set != null && set.size() > 0) {
for (T t : set) {
list.add(t);
}
}
return list;
}
public static <T extends Object> List<T> removeAll(Collection<T> collection, Collection<T> remove) {
List<T> list = new ArrayList<T>();
for (Iterator<T> iter = collection.iterator(); iter.hasNext();) {
T obj = iter.next();
if (remove.contains(obj) == false) {
list.add(obj);
}
}
return list;
}
public static <T extends Object> void addAll(Collection<T> target, Collection<T> source) {
if (target != null && source != null && source.size() > 0) {
target.addAll(source);
}
}
private static <K extends Number, V extends Object> Map<K, V> toNumberMap(Collection<V> values, String property,
Number keyValue) {
if (values == null) {
return Collections.emptyMap();
}
Map<K, V> valueMap = new HashMap<K, V>(values.size());
for (V value : values) {
try {
String keyValueStr = BeanUtils.getProperty(value, property);
if (NumberUtils.isNumber(keyValueStr)) {
try {
// K valueTypeInstance = keyType.newInstance();
Object key = MethodUtils.invokeExactMethod(keyValue, "valueOf", keyValueStr);
valueMap.put((K) key, value);
} catch (Exception e) {
throw new IllegalArgumentException("Unsupport key Type:" + keyValue.getClass().getName(), e);
}
} else {
throw new IllegalArgumentException("Expect:" + keyValue.getClass().getName() + ",Value Actul is "
+ keyValueStr);
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new RuntimeException(e);
}
}
return valueMap;
}
public static <T extends Object> Map<Integer, T> toIntegerMap(Collection<T> values, String property) {
return CollectionUtils.<Integer, T> toNumberMap(values, property, new Integer(0));
}
public static <T extends Object> Map<Long, T> toLongMap(Collection<T> values, String property) {
return CollectionUtils.<Long, T> toNumberMap(values, property, new Long(0l));
}
public static <T extends Object> Map<Float, T> toFloatMap(Collection<T> values, String property) {
return CollectionUtils.<Float, T> toNumberMap(values, property, new Float(0f));
}
public static <T extends Object> Map<Double, T> toDoubleMap(Collection<T> values, String property) {
return CollectionUtils.<Double, T> toNumberMap(values, property, new Double(0f));
}
public static <T extends Object> Map<Object, Object> toMap(T[] beans, String keyProperty, String valueProperty) {
return toMap(Wrapper.collection(beans), keyProperty, valueProperty);
}
private static <T extends Object, K extends Object, V extends Object> Map<K, V> toMap(Collection<T> beans,
String keyProperty,
String valueProperty) {
Map<K, V> map = new HashMap<K, V>();
if (Argument.isEmpty(beans)) {
return map;
}
for (T bean : beans) {
try {
K key = (K) PropertyUtils.getProperty(bean, keyProperty);
V value = null;
if (valueProperty != null) {
value = (V) PropertyUtils.getProperty(bean, valueProperty);
} else {
value = (V) bean;
}
没有合适的资源?快使用搜索试试~ 我知道了~
《基于Java实现B2B在线旅游项目》+源代码+设计资料
共1486个文件
java:515个
gif:241个
vm:206个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 46 浏览量
2024-04-21
21:18:26
上传
评论
收藏 31.2MB ZIP 举报
温馨提示
<项目介绍> - 功能点 支持供应商,批发商,管理员登陆,注册,权限,访客多站点切换; 支持订单管理,旅游产品发布,线路发布,线路模板管理; 支持分城市专线发布,新增站点,管理站点; 支持实时用户消息推送,订单推送; 支持公司,商家,用户管理; 支持商家报表,财务对账管理,打印; 支持在线支付(支付宝,国付宝,邮储银行等支付); 支持实时搜索,全文产品线路搜索 等等 - 不懂运行,下载完可以私聊问,可远程教学 该资源内项目源码是个人的毕设,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到96分,放心下载使用! 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。 -------
资源推荐
资源详情
资源评论
收起资源包目录
《基于Java实现B2B在线旅游项目》+源代码+设计资料 (1486个子文件)
SWFUpload.as 61KB
ExternalCall.as 5KB
FileItem.as 4KB
SWFUpload v2.as3proj 2KB
bootstrap.min.css 103KB
bootstrap.min.3.css 98KB
style.css 28KB
main.css 25KB
default.css 21KB
bootstrap-ie7.css 20KB
style0925.css 18KB
bootstrap-theme.min.css 16KB
zuobian.css 15KB
style1422.css 13KB
bootstrap-theme.min.3.css 13KB
register.css 13KB
shop.css 12KB
common.css 11KB
line.css 11KB
idialog.css 9KB
mac.css 9KB
jqtransform.css 9KB
jquery.fancybox-1.3.4.css 8KB
jtop.css 8KB
discuz.css 8KB
blue.css 8KB
default.css 8KB
iblack.css 8KB
igreen.css 7KB
iblue.css 7KB
login.css 7KB
chrome.css 7KB
register.css 6KB
laydate.css 6KB
layer.css 6KB
index.css 4KB
thickbox.css 4KB
main.css 4KB
laydate.css 3KB
common.css 3KB
print.css 3KB
qq.css 3KB
demo.css 3KB
common.css 3KB
layer.ext.css 3KB
datePicker.css 3KB
core.css 3KB
photo.css 2KB
powerFloat.css 2KB
simple.css 2KB
datePicker-min.css 2KB
tip-yellowsimple.css 2KB
tip-darkgray.css 2KB
page.css 2KB
tip-yellow.css 2KB
tip-violet.css 2KB
tip-twitter.css 2KB
style.css 1KB
tip-skyblue.css 1KB
tip-green.css 1KB
prettify.css 973B
jquery.autocomplete.css 817B
login.css 795B
wp-syntax.css 761B
jquery.message.css 473B
style.css 349B
glyphicons-halflings-regular.eot 20KB
static.gif 35KB
search_submit.gif 13KB
35.gif 13KB
42.gif 13KB
line03.gif 13KB
line02.gif 13KB
icon02.gif 13KB
40.gif 10KB
18.gif 8KB
19.gif 8KB
11.gif 8KB
32.gif 7KB
discuz_bg.gif 7KB
loading.gif 7KB
49.gif 6KB
29.gif 6KB
xubox_loading0.gif 6KB
97.gif 5KB
65.gif 5KB
31.gif 5KB
46.gif 5KB
57.gif 5KB
45.gif 5KB
8.gif 5KB
43.gif 4KB
33.gif 4KB
68.gif 4KB
26.gif 4KB
14.gif 4KB
7.gif 4KB
51.gif 4KB
10.gif 4KB
47.gif 4KB
共 1486 条
- 1
- 2
- 3
- 4
- 5
- 6
- 15
资源评论
mldxxxxll5
- 粉丝: 3569
- 资源: 883
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功