pojo-helper

Java POJO helper to simplify POJO convert and mask

License

License

GroupId

GroupId

io.github.snowythinker
ArtifactId

ArtifactId

pojo-helper
Last Version

Last Version

0.0.5-RELEASE
Release Date

Release Date

Type

Type

jar
Description

Description

pojo-helper
Java POJO helper to simplify POJO convert and mask
Project URL

Project URL

https://github.com/snowyThinker/pojo-helper
Source Code Management

Source Code Management

https://github.com/snowyThinker/pojo-helper

Download pojo-helper

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.snowythinker/pojo-helper/ -->
<dependency>
    <groupId>io.github.snowythinker</groupId>
    <artifactId>pojo-helper</artifactId>
    <version>0.0.5-RELEASE</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.snowythinker/pojo-helper/
implementation 'io.github.snowythinker:pojo-helper:0.0.5-RELEASE'
// https://jarcasting.com/artifacts/io.github.snowythinker/pojo-helper/
implementation ("io.github.snowythinker:pojo-helper:0.0.5-RELEASE")
'io.github.snowythinker:pojo-helper:jar:0.0.5-RELEASE'
<dependency org="io.github.snowythinker" name="pojo-helper" rev="0.0.5-RELEASE">
  <artifact name="pojo-helper" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.snowythinker', module='pojo-helper', version='0.0.5-RELEASE')
)
libraryDependencies += "io.github.snowythinker" % "pojo-helper" % "0.0.5-RELEASE"
[io.github.snowythinker/pojo-helper "0.0.5-RELEASE"]

Dependencies

compile (2)

Group / Artifact Type Version
org.slf4j : slf4j-api jar 1.7.25
com.fasterxml.jackson.datatype : jackson-datatype-jsr310 jar 2.11.2

provided (1)

Group / Artifact Type Version
org.projectlombok : lombok jar 1.18.8

test (4)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter jar 5.6.2
org.junit.platform : junit-platform-launcher jar 1.6.2
ch.qos.logback : logback-core jar 1.2.3
ch.qos.logback : logback-classic jar 1.2.3

Project Modules

There are no modules declared in this project.

pojo-helper(https://github.com/snowThinker/pojo-helper)

Maven Central License

Main Functions

  • Java Bean Mask Support: Mask or encrypt bean with annotation
  • Java Bean Flexible Convert: Rich reflection tools, easily to convert between HashMap and Data Transfer Object

Usage:

1. Add maven dependency
<dependency>
	<groupId>io.github.snowthinker</groupId>
	<artifactId>pojo-helper</artifactId>
	<version>0.0.1-RELEASE</version>
</dependency>
2. Write mask or encryption bean and rewrite toString() method
class MaskBean {
	private String name;
	
	@Mask(type=MaskType.MOBILE, format="#")
	private String mobile;

	@Mask(type=MaskType.IDCARD)
	private String idcard;
	
	@Encryption(type=EncryptionType.AES)
	private String cardNumber;

	@Mask(type=MaskType.ADDRESS)
	private String address;
	
	private Date birthday;
	
	@Override
	public String toString() {
		return MaskUtils.toString(this);
	}
	//TODO getter and setters
}
3. Run the test case
public class MaskUtilsTest extends TestCase {
	@Test
	public void testMaskBean() {
		MaskBean maskBean = new MaskBean();
		maskBean.setName("Andrew");
		maskBean.setMobile("12318638123");
		maskBean.setIdcard("123212196309222123");
		maskBean.setCardNumber("1238390056241234");
		maskBean.setAddress("2915 Canyon Lake Dr, Rapid City, SD 57702");
		maskBean.setBirthday(new Date());
		maskBean.setAge(17);
		
		AESEncryptor.encryptObject(maskBean);
		
		System.out.printf("after mask and encrypt: %s\r\n", maskBean);
	}
}
4.Output:
after mask and encrypt: MaskBean[name=Andrew, mobile=123####8123, idcard=1232121963****2123, cardNumber=jzvCqL2QEMQliI2Pvdx7Chi7uEURzsK8I7iejfobS7Q=, address=2915 Canyon Lake Dr, Rapid City, ****7702, birthday=Sat Apr 29 11:36:35 CST 2017, age=17

Versions

Version
0.0.5-RELEASE