Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zhouhailin/common-bean
common bean : beanCopier
https://github.com/zhouhailin/common-bean
beancopier beanmaper beanutils copyproperties propertyutils
Last synced: 18 days ago
JSON representation
common bean : beanCopier
- Host: GitHub
- URL: https://github.com/zhouhailin/common-bean
- Owner: zhouhailin
- License: apache-2.0
- Created: 2019-04-19T07:45:45.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-05-07T14:23:50.000Z (over 5 years ago)
- Last Synced: 2024-11-13T00:30:34.627Z (3 months ago)
- Topics: beancopier, beanmaper, beanutils, copyproperties, propertyutils
- Language: Java
- Homepage: http://www.thingscloud.link/common-bean
- Size: 68.4 KB
- Stars: 1
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# common-bean
[![Gitter](https://badges.gitter.im/zhouhailin/common-bean.svg)](https://gitter.im/zhouhailin/common-bean?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[![Jdk Version](https://img.shields.io/badge/JDK-1.8-green.svg)](https://img.shields.io/badge/JDK-1.8-green.svg)
[![Build Status](https://travis-ci.org/zhouhailin/common-bean.svg?branch=master)](https://travis-ci.org/zhouhailin/common-bean)
[![Coverage Status](https://img.shields.io/codecov/c/github/zhouhailin/common-bean/master.svg)](https://codecov.io/github/zhouhailin/common-bean?branch=master&view=all#sort=coverage&dir=asc)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/link.thingscloud/common-bean/badge.svg)](https://maven-badges.herokuapp.com/maven-central/link.thingscloud/common-bean)
[![GitHub release](https://img.shields.io/github/release/zhouhailin/common-bean.svg)](https://github.com/zhouhailin/common-bean/releases)
[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)## 版本迭代
- [x] fastjson实现 - 0.1.x
- [ ] 注解实现 - 0.2.x
- [ ] 反射实现 - 0.3.x
- [ ] 动态代理实现 0.4.x## 快速使用
- java version
```
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
```- ### maven
```
link.thingscloud
common-bean
${common-bean.version}```
- example
```
BeanCopier beanCopier = BeanCopier.create(BeanObject1.class, BeanObject2.class,
BeanCopierOptions.defaultOptions()
.ignoreFields("short2"));BeanObject1 beanObject1 = new BeanObject1()
.setStr1("str1").setStr2("str2")
.setShort1((short) 1).setShort2((short) 2)
.setLong1(1L).setLong2(2L)
.setDouble1(1D).setDouble2(2D)
.setDate1(new Date(System.currentTimeMillis())).setDate2(new Date(System.currentTimeMillis()));@Test
public void copy() {
BeanObject1 copy = beanCopier.copy(beanObject1);
System.out.println(copy);
}@Test
public void copy1() {
BeanObject2 copy1 = beanCopier.copy(beanObject1, new BeanObject2());
System.out.println(copy1);
}
```- source & target object
```
@Data
@Accessors(chain = true)
public class BeanObject1 {
private String str1;
private String str2;
private Short short1;
private Short short2;
private Long long1;
private Long long2;
private Date date1;
private Date date2;
private Double double1;
private Double double2;
}@Data
@Accessors(chain = true)
public class BeanObject1 {
private String str1;
private String str2;
private Short short1;
private Short short2;
private Long long1;
private Long long2;
private Date date1;
private Date date2;
private Double double1;
private Double double2;
}
```## License
[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) Copyright (C) Apache Software Foundation