Skip to content

hroniko/Guyver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Guyver Object Modifier


Maven Central

How to use:


  • add dependency to pom
<dependency>
    <groupId>com.github.hroniko</groupId>
    <artifactId>guyver-object-modifier</artifactId>
    <version>1.0.0</version>
</dependency>
  • create new Guyver shell from your Object
  • modify it (change field values, add new fields)
  • extract modified object as guyver.getBody()

Example Usage:


// create new object of Test class
    Test test = new Test()
            .setName("MyName")
            .setPercent(true)
            .setCreateDate(new Date().getTime())
            .setCurrencyCode("$")
            .setOrderNumber(1L)
            .setShortName("OOPS")
            .setMinValue("0.0")
            .setMaxValue("INF+")
            .setValue("100.0");

// create new Guyver shell from exist object
    Guyver<Test> guyver = new Guyver<>(test);

// update values for fields of test object with Guyver shell
    guyver.set("name", "Test");
    guyver.set("isPercent", false);
    guyver.set("maxValue", "0.0");

// create new non-exist fields and insert it to test object with Guyver shell
    List<String> list = new ArrayList<>();
    list.add("1");
    list.add("2");
    guyver.addField("ZZZ", list);
    guyver.addField("proto", "Proto");

// get modifiered object from Guyver shell and printing it
    Test test2 = guyver.getBody();
    System.out.println(test2);
    System.out.println(test2.getClass());

Will be printed:


{"name":"Test","shortName":"OOPS","value":"100.0","currencyCode":"$","isPercent":false,"minValue":"0.0","maxValue":"0.0","createDate":1586257901722,"orderNumber":1,"proto":"Proto","ZZZ":[1, 2]}
class Testv2

About

Guyver Object Modifier

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published