Created
December 19, 2014 16:18
-
-
Save kdelfour/49e3b843f2025ce23dcd to your computer and use it in GitHub Desktop.
Lang provides a host of helper utilities for the java.lang API, notably String manipulation methods, basic numerical methods, object reflection, concurrency, creation and serialization and System properties. Additionally it contains basic enhancements to java.util.Date and a series of utilities dedicated to help with building methods, such as ha…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.kdstudio.snippets.tips.apache; | |
import org.apache.commons.lang3.builder.EqualsBuilder; | |
import org.apache.commons.lang3.builder.HashCodeBuilder; | |
import org.apache.commons.lang3.builder.ReflectionToStringBuilder; | |
import org.apache.commons.lang3.builder.ToStringStyle; | |
/** | |
* Example of using Commons-lang3 utilities. | |
* | |
* Lang provides a host of helper utilities for the java.lang API, notably | |
* String manipulation methods, basic numerical methods, object reflection, | |
* concurrency, creation and serialization and System properties. Additionally | |
* it contains basic enhancements to java.util.Date and a series of utilities | |
* dedicated to help with building methods, such as hashCode, toString and | |
* equals. | |
* | |
* @author kdelfour | |
*/ | |
public class HashCodeEqualsToStringExample { | |
/** | |
* Constructor | |
*/ | |
public HashCodeEqualsToStringExample() { | |
} | |
/* | |
* (non-Javadoc) | |
* | |
* @see java.lang.Object#toString() | |
*/ | |
@Override | |
public String toString() { | |
return ReflectionToStringBuilder.toString(this, | |
ToStringStyle.MULTI_LINE_STYLE); | |
} | |
/* | |
* (non-Javadoc) | |
* | |
* @see java.lang.Object#hashCode() | |
*/ | |
@Override | |
public int hashCode() { | |
return HashCodeBuilder.reflectionHashCode(this); | |
} | |
/* | |
* (non-Javadoc) | |
* | |
* @see java.lang.Object#equals(java.lang.Object) | |
*/ | |
@Override | |
public boolean equals(Object obj) { | |
return EqualsBuilder.reflectionEquals(this, obj); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.dkstudio</groupId> | |
<artifactId>snippets</artifactId> | |
<version>0.0.1-SNAPSHOT</version> | |
<name>HashCodeEqualsToStringSnippets</name> | |
<description>Lang provides a host of helper utilities for the java.lang API, | |
notably String manipulation methods, basic numerical methods, object reflection, | |
concurrency, creation and serialization and System properties. | |
Additionally it contains basic enhancements to java.util.Date and a series of | |
utilities dedicated to help with building methods, such as hashCode, toString | |
and equals.</description> | |
<developers> | |
<developer> | |
<id>delfour.k</id> | |
<name>Kevin DELFOUR</name> | |
<email>delfour.k@gmail.com</email> | |
<organization>DK</organization> | |
<organizationUrl>http://kevin.delfour.eu</organizationUrl> | |
</developer> | |
</developers> | |
<organization> | |
<name>DK</name> | |
<url>http://kevin.delfour.eu</url> | |
</organization> | |
<properties> | |
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
<project.build.sourceVersion>1.7</project.build.sourceVersion> | |
</properties> | |
<dependencies> | |
<dependency> | |
<groupId>org.apache.commons</groupId> | |
<artifactId>commons-lang3</artifactId> | |
<version>3.3.2</version> | |
</dependency> | |
</dependencies> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment