Skip to content

IDEA Plugin that generates equals, hashCode and toString using Guava Libraries

Notifications You must be signed in to change notification settings

seanlandsman/guavagenerators

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

#IDEA Plugin Guava

Guava Generators

This is an IDEA(IntelliJ) plugins to generate equals, hashCode and toString using Guava utilities.

Based on the "Live Coding a Plugin From Scratch" webinar, which can be found here:Jet Brains Blog


Example of generated code:

Equals:

 @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        
        User that = (User) o;
        
        return com.google.common.base.Objects.equal(this.name, that.name) &&
                com.google.common.base.Objects.equal(this.email, that.email) &&
    }

Hash Code:

@Override
    public int hashCode() {
        return com.google.common.base.Objects.hashCode(name, email);
    }

ToString:

@Override
    public String toString() {
        return com.google.common.base.MoreObjects.toStringHelper(this)
                .add("name", name)
                .add("email", email)
                .toString();
    }

###Dependences

To use this plugin it will be needed to be add into your pom or grandle file the guava jar, as the examples shows:

Maven:

<dependency>
	<groupId>com.google.guava</groupId>
	<artifactId>guava</artifactId>
	<version>19.0</version>
</dependency>

Gradle:

com.google.guava:guava:19.0'

OBS: The guava version may change when the guava team release it a new one.

About

IDEA Plugin that generates equals, hashCode and toString using Guava Libraries

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages