Giter VIP home page Giter VIP logo

gsonformat-initialized's Introduction

GsonFormat-Initialized

在原有GsonFormat基础上修改了:带有初始化值的 GsonFormat。 可以规避一些空指针异常

使用Code中的 .zip Install Plugin from disk 替换原有的 GsonFormat

效果如下:

public class TestModel {

    /**
     * name : 小强
     * age : 16
     * msg : ["a","b"]
     * regex : ^http://.*
     */

    private String name;
    private int age;
    private String regex;
    private List<String> msg;

    public String getName() {
        return name == null ? "" : name;   //生成有空判断的 get方法
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getRegex() {
        return regex == null ? "" : regex;
    }

    public void setRegex(String regex) {
        this.regex = regex;
    }

    public List<String> getMsg() {
        if (msg == null) {
            msg = new ArrayList<>();    //默认初始化的 List 或 Map
        }
        return msg;
    }

    public void setMsg(List<String> msg) {
        this.msg = msg;
    }
}

gsonformat-initialized's People

Contributors

aos3618 avatar

Watchers

James Cloos 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.