• java开发神器Lombok初识


    一、前言

      在我们使用java语言定义实体对象的时候,以前经常需要写set和get方法,会觉得很繁琐。偶然接触到一款神器叫Lombok的,可以帮我们很好的解决这种琐事。

    二、步骤

      1、在idea上安装Lombok插件

      File-Settings-Plugins,搜索Lombok

      

       下载后,需要重启idea生效

      2、在pom文件添加相关依赖

            <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>1.18.20</version>
                <scope>provided</scope>
            </dependency>

    三、测试类

    import lombok.Data;
    
    @Data
    public class Text {
    
        private String content;
    }

    idea编译之后的:

    //
    // Source code recreated from a .class file by IntelliJ IDEA
    // (powered by Fernflower decompiler)
    //
    
    package restassureddemo.weixin;
    
    public class Text {
        private String content;
    
        public Text() {
        }
    
        public String getContent() {
            return this.content;
        }
    
        public void setContent(String content) {
            this.content = content;
        }
    
        public boolean equals(Object o) {
            if (o == this) {
                return true;
            } else if (!(o instanceof Text)) {
                return false;
            } else {
                Text other = (Text)o;
                if (!other.canEqual(this)) {
                    return false;
                } else {
                    Object this$content = this.getContent();
                    Object other$content = other.getContent();
                    if (this$content == null) {
                        if (other$content != null) {
                            return false;
                        }
                    } else if (!this$content.equals(other$content)) {
                        return false;
                    }
    
                    return true;
                }
            }
        }
    
        protected boolean canEqual(Object other) {
            return other instanceof Text;
        }
    
        public int hashCode() {
            int PRIME = true;
            int result = 1;
            Object $content = this.getContent();
            int result = result * 59 + ($content == null ? 43 : $content.hashCode());
            return result;
        }
    
        public String toString() {
            return "Text(content=" + this.getContent() + ")";
        }
    }

      说明生效

    知道、想到、做到、得到
  • 相关阅读:
    ASP.NET中JSON的序列化和反序列化
    Android:数据存储之SQLite
    转Android:简单联网获取网页代码
    Android:@id和@+id
    linux .run文件安装
    Mysql的Root密码忘记,查看或修改的解决方法(图文介绍)
    网页页面尺寸
    openstack
    br0
    virsh
  • 原文地址:https://www.cnblogs.com/Durant0420/p/14954565.html
Copyright © 2020-2023  润新知