Code Monkey home page Code Monkey logo

builgen-plugin's Introduction

Builgen-plugin

Builgen plugin for eclipse and idea.Generate code for Java bean builder design pattern.

[TOC]

How to use

eclipse

Test environment:JDK 1.8 + Eclipse Oxygen Release (4.7.0)

  1. Copy Builgen_1.0.0.201708310007.jar to eclipse plugins directory.
  2. Delete eclipse\configuration\org.eclipse.update directory.
  3. Rerun eclipse with -clean option(Windows:cmd->cd $dir_eclipse.exe->run cmd 'eclipse -clean').
  4. Create a Java bean like this.
    public class TestBean {
        private String mes;
        private int[] inteters;
        private List<String> strings;
        private List<Map<String, Object>> ddd;
        private boolean klk;
        private double dst;
    }
  5. Right click on file,click Builgen at the end.

   eclipse-rk

  1. Content will be replaced by generated code.
    public class TestBean {
        private String mes;
        private int[] inteters;
        private List<String> strings;
        private List<Map<String, Object>> ddd;
        private boolean klk;
        private double dst;
    
        public TestBean(TestBean testBean) {
            this.mes = testBean.getMes();
            this.inteters = testBean.getInteters();
            this.strings = testBean.getStrings();
            this.ddd = testBean.getDdd();
            this.klk = testBean.getKlk();
            this.dst = testBean.getDst();
        }
    
        public TestBean() {
        }
    
        public static class TestBeanBuilder {
            TestBean testBean;
    
            public TestBeanBuilder() {
                testBean = new TestBean();
            }
    
            public TestBeanBuilder mes(String mes) {
                testBean.setMes(mes);
                return this;
            }
    
            public TestBeanBuilder inteters(int[] inteters) {
                testBean.setInteters(inteters);
                return this;
            }
    
            public TestBeanBuilder strings(List<String> strings) {
                testBean.setStrings(strings);
                return this;
            }
    
            public TestBeanBuilder ddd(List<Map<String, Object>> ddd) {
                testBean.setDdd(ddd);
                return this;
            }
    
            public TestBeanBuilder klk(boolean klk) {
                testBean.setKlk(klk);
                return this;
            }
    
            public TestBeanBuilder dst(double dst) {
                testBean.setDst(dst);
                return this;
            }
    
            public TestBean build() {
                return new TestBean(this.testBean);
            }
        }
    
        public void setDst(double dst) {
            this.dst = dst;
        }
    
        public double getDst() {
            return this.dst;
        }
    
        public void setKlk(boolean klk) {
            this.klk = klk;
        }
    
        public boolean getKlk() {
            return this.klk;
        }
    
        public void setDdd(List<Map<String, Object>> ddd) {
            this.ddd = ddd;
        }
    
        public List<Map<String, Object>> getDdd() {
            return this.ddd;
        }
    
        public void setStrings(List<String> strings) {
            this.strings = strings;
        }
    
        public List<String> getStrings() {
            return this.strings;
        }
    
        public void setInteters(int[] inteters) {
            this.inteters = inteters;
        }
    
        public int[] getInteters() {
            return this.inteters;
        }
    
        public void setMes(String mes) {
            this.mes = mes;
        }
    
        public String getMes() {
            return this.mes;
        }
    }

idea

Test environment:JDK 1.8 + INTELLIJ IDEA COMMUNITY 2017.2.1

  1. Download Builgen.jar

  2. File -> Settings -> plugins -> Install Plugins From Disk,choose the jar downloaded,then restart idea.

  3. New class and right click inside editor for context menu,then Generate -> Builgen.

    idea-rk

  4. Builder class lost modifier static,add if necessary.

builgen-plugin's People

Contributors

clyoudu avatar junjianw avatar

Watchers

 avatar

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.