simter-util

Simter Util

License

License

MIT
GroupId

GroupId

tech.simter
ArtifactId

ArtifactId

simter-util
Last Version

Last Version

1.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

simter-util
Simter Util
Project URL

Project URL

https://github.com/simter/simter-util
Project Organization

Project Organization

simter
Source Code Management

Source Code Management

https://github.com/simter/simter-util.git

Download simter-util

How to add to project

<!-- https://jarcasting.com/artifacts/tech.simter/simter-util/ -->
<dependency>
    <groupId>tech.simter</groupId>
    <artifactId>simter-util</artifactId>
    <version>1.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/tech.simter/simter-util/
implementation 'tech.simter:simter-util:1.1.0'
// https://jarcasting.com/artifacts/tech.simter/simter-util/
implementation ("tech.simter:simter-util:1.1.0")
'tech.simter:simter-util:jar:1.1.0'
<dependency org="tech.simter" name="simter-util" rev="1.1.0">
  <artifact name="simter-util" type="jar" />
</dependency>
@Grapes(
@Grab(group='tech.simter', module='simter-util', version='1.1.0')
)
libraryDependencies += "tech.simter" % "simter-util" % "1.1.0"
[tech.simter/simter-util "1.1.0"]

Dependencies

compile (3)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-stdlib Optional jar 1.3.40
org.jetbrains.kotlin : kotlin-reflect Optional jar 1.3.40
org.modelmapper : modelmapper Optional jar 2.3.2

test (2)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter jar
org.assertj : assertj-core jar 3.12.2

Project Modules

There are no modules declared in this project.

simter-util [中文]

Some util tools. Includes:

  • BeanUtils.assign : similar to JavaScript Object.assign method
  • XPathUtils : find xml node by standard xpath
  • RandomUtils : generate random Int or String, get a nextId

Installation

<dependency>
  <groupId>tech.simter</groupId>
  <artifactId>simter-util</artifactId>
  <version>1.0.0</version>
</dependency>

Requirement

  • Java 8+
  • ModelMapper 1+

Usage - BeanUtils.assign

Convert PO to DTO or reverse

UserPo po = new UserPo();
// set po property value
...
// convert to DTO instance
UserDto dto = BeanUtils.assign(UserDto.class, po);

If the DTO has the same property from multiple po, code should be like this:

UserDto dto = BeanUtils.assign(UserDto.class, po1, po2, ...);

The latter po property value will override the previous po property value.

Copy property value to target instance object

UserPo po = new UserPo();
// set po property value
...
// instance target instance
UserDto dto = new UserDto();

// copy po property value to the dto property
BeanUtils.assign(dto, po);

If the DTO has the same property from multiple po, code should be like this:

BeanUtils.assign(dto, po1, po2, ...);

The latter po property value will override the previous po property value.

Usage - XPathUtils

TODO.

Build

mvn clean package

Deploy

First take a look at simter-parent deploy config.

Deploy to LAN Nexus Repository

mvn clean deploy -P lan

Deploy to Sonatype Repository

mvn clean deploy -P sonatype

After deployed, login into https://oss.sonatype.org. Through Staging Repositories, search this package, then close and release it. After couple hours, it will be synced to Maven Central Repository.

Deploy to Bintray Repository

mvn clean deploy -P bintray

Will deploy to https://api.bintray.com/maven/simter/maven/tech.simter:simter-util/;publish=1. So first create a package https://bintray.com/simter/maven/tech.simter:simter-util on Bintray. After deployed, check it from https://jcenter.bintray.com/tech/simter/simter-util.

tech.simter

Versions

Version
1.1.0
1.0.0
0.4.0
0.3.0