Specter

Transfer data from Payload to Pojo

License

License

GroupId

GroupId

com.github.bloder
ArtifactId

ArtifactId

specterlib
Last Version

Last Version

1.1
Release Date

Release Date

Type

Type

aar
Description

Description

Specter
Transfer data from Payload to Pojo
Project URL

Project URL

https://github.com/daniel-martins-IR/Specter
Source Code Management

Source Code Management

https://github.com/daniel-martins-IR/Specter

Download specterlib

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.bloder/specterlib/ -->
<dependency>
    <groupId>com.github.bloder</groupId>
    <artifactId>specterlib</artifactId>
    <version>1.1</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/com.github.bloder/specterlib/
implementation 'com.github.bloder:specterlib:1.1'
// https://jarcasting.com/artifacts/com.github.bloder/specterlib/
implementation ("com.github.bloder:specterlib:1.1")
'com.github.bloder:specterlib:aar:1.1'
<dependency org="com.github.bloder" name="specterlib" rev="1.1">
  <artifact name="specterlib" type="aar" />
</dependency>
@Grapes(
@Grab(group='com.github.bloder', module='specterlib', version='1.1')
)
libraryDependencies += "com.github.bloder" % "specterlib" % "1.1"
[com.github.bloder/specterlib "1.1"]

Dependencies

compile (1)

Group / Artifact Type Version
com.android.support » appcompat-v7 jar 23.1.1

Project Modules

There are no modules declared in this project.

Android Arsenal Maven Central

Specter

alt tag

Specter is an easy way to convert a payload data to pojo class.

How does it work?

Well, to tranfer any data to your pojo classes, you need to add some annotations in payload and pojo classes with the same name.

public class Payload {

  @Specter(name = "name")
  private final String name;
  
  public Payload(String name) {
    this.name = name;
  }
}

public class Pojo {

  @Specter(name = "name")
  public final String name;
  
  public Pojo(String name) {
    this.name = name;
  }
}

Then you just need to call specter functions to transfer all payload data to pojo.

Payload payload = new Payload("Daniel");
Pojo pojo = new TestPojo("");

pojo = (Pojo) new Specter()
            .transform(payload)
            .inPojoWithInstance(pojo);

That's it!

Import

Gradle

dependencies {
    compile 'com.github.bloder:specterlib:1.2'
}

Maven

<dependency>
  <groupId>com.github.bloder</groupId>
  <artifactId>specterlib</artifactId>
  <version>1.2</version>
  <type>pom</type>
</dependency>

Ivy

<dependency org='com.github.bloder' name='specterlib' rev='1.2'>
  <artifact name='$AID' ext='pom'></artifact>
</dependency>

Versions

Version
1.1
1.0