Specter

Additional

Language
Java
Version
1.2 (Jul 12, 2016)
Created
Jul 8, 2016
Updated
Jul 18, 2016 (Retired)
Owner
Bloder (bloderxd)
Contributor
Bloder (bloderxd)
1
Activity
Badge
Generate
Download
Source code
APK file

Show card

Specter

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>