Giter Site home page Giter Site logo

builderpojogenerator's Introduction

BuilderPojoGenerator

中文说明
a plugin for idea(android studio) to generate java code for builder mode

DOWNLOAD

search "BuilderPojoGenerator" in plugin repositories

HOW TO USE

int the code of POJO , right click , selected "Builder Generator", change options and click 'OK'

the ui is :

OPTIONS

force change field to final
generate overlay method (about overlay method can see in demo)
generate getter methods

DEMO

original source :

public class Test {
    private final int intA;
    private final Long longB;
    private final int[] testArr;
    private final Integer[] testArr1;
   }

generated source :

public class Test {

    private final int intA;
    private final Long longB;
    private final int[] testArr;
    private final Integer[] testArr1;


    private final List<Integer> list;

    private Test(Builder builder) {
        this.intA = builder.intA;
        this.longB = builder.longB;
        this.testArr = builder.testArr;
        this.testArr1 = builder.testArr1;
        this.list = builder.list;
    }

    public static Builder builder() {
        return new Builder();
    }

    public int getIntA() {
        return intA;
    }

    public Long getLongB() {
        return longB;
    }

    public int[] getTestArr() {
        return testArr;
    }

    public Integer[] getTestArr1() {
        return testArr1;
    }

    public List<Integer> getList() {
        return list;
    }

    public static class Builder {
        private int intA;
        private Long longB;
        private int[] testArr;
        private Integer[] testArr1;
        private List<Integer> list;

        public Builder() {
        }

        public Builder(Test test) {
            this.intA = test.intA;
            this.longB = test.longB;
            this.testArr = test.testArr;
            this.testArr1 = test.testArr1;
            this.list = test.list;
        }

        public Builder overlay(Test test) {
            if (test == null) {
                return this;
            }
            if (test.getIntA() != 0) {
                intA = test.getIntA();
            }
            if (test.getLongB() != null) {
                longB = test.getLongB();
            }
            if (test.getTestArr() != null) {
                testArr = test.getTestArr();
            }
            if (test.getTestArr1() != null) {
                testArr1 = test.getTestArr1();
            }
            if (test.getList() != null) {
                list = test.getList();
            }
            return this;
        }

        public Builder intA(int intA) {
            this.intA = intA;
            return this;
        }

        public Builder longB(Long longB) {
            this.longB = longB;
            return this;
        }

        public Builder testArr(int[] testArr) {
            this.testArr = testArr;
            return this;
        }

        public Builder testArr1(Integer[] testArr1) {
            this.testArr1 = testArr1;
            return this;
        }

        public Builder list(List<Integer> list) {
            this.list = list;
            return this;
        }

        public Test build() {
            return new Test(this);
        }
    }

builderpojogenerator's People

Contributors

fsilence avatar

Stargazers

 avatar Wei avatar Kamil Kucharski avatar Nathan Bu avatar liu avatar tim_taller avatar  avatar  avatar

Watchers

James Cloos avatar  avatar

builderpojogenerator's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.