Pojomatic

Automatically provides configurable implementations of the equals(Object), hashCode() and toString() methods inherited from java.lang.Object

License

License

GroupId

GroupId

org.pojomatic
ArtifactId

ArtifactId

pojomatic
Last Version

Last Version

2.2.1
Release Date

Release Date

Type

Type

jar
Description

Description

Pojomatic
Automatically provides configurable implementations of the equals(Object), hashCode() and toString() methods inherited from java.lang.Object
Project URL

Project URL

http://www.pojomatic.org/pojomatic
Source Code Management

Source Code Management

https://github.com/irobertson/pojomatic

Download pojomatic

How to add to project

<!-- https://jarcasting.com/artifacts/org.pojomatic/pojomatic/ -->
<dependency>
    <groupId>org.pojomatic</groupId>
    <artifactId>pojomatic</artifactId>
    <version>2.2.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.pojomatic/pojomatic/
implementation 'org.pojomatic:pojomatic:2.2.1'
// https://jarcasting.com/artifacts/org.pojomatic/pojomatic/
implementation ("org.pojomatic:pojomatic:2.2.1")
'org.pojomatic:pojomatic:jar:2.2.1'
<dependency org="org.pojomatic" name="pojomatic" rev="2.2.1">
  <artifact name="pojomatic" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.pojomatic', module='pojomatic', version='2.2.1')
)
libraryDependencies += "org.pojomatic" % "pojomatic" % "2.2.1"
[org.pojomatic/pojomatic "2.2.1"]

Dependencies

compile (1)

Group / Artifact Type Version
org.ow2.asm : asm jar 7.0

test (4)

Group / Artifact Type Version
org.testng : testng jar 6.9.10
com.google.guava : guava jar 16.0.1
org.mockito : mockito-core jar 2.19.0
org.hamcrest : hamcrest-core jar 1.3

Project Modules

There are no modules declared in this project.

Pojomatic

Pojomatic provides configurable implementations of the equals(Object), hashCode() and toString() methods inherited from java.lang.Object.

For example, the following bean has been "pojomated":

import org.pojomatic.Pojomatic;
import org.pojomatic.annotations.AutoProperty;

@AutoProperty
public class Person {
  private final String firstName;
  private final String lastName;
  private final int age;

  public Person(String firstName, String lastName, int age) {
    this.firstName = firstName;
    this.lastName = lastName;
    this.age = age;
  }

  public String getFirstName() { return this.firstName; }
  public String getLastName() { return this.lastName; }
  public int getAge() { return this.age; }

  @Override public boolean equals(Object o) {
    return Pojomatic.equals(this, o);
  }

  @Override public int hashCode() {
    return Pojomatic.hashCode(this);
  }

  @Override public String toString() {
    return Pojomatic.toString(this);
  }
}

The above class implements equals and hashCode methods following the best practices outlined in Josh Bloch's Efective Java. Moreover, running

System.out.println(new Person("John", "Doe", 32).toString());

will result in the following output:

Person{firstName: {John}, lastName: {Doe}, age: {32}}

For more information and examples, see the Pojomatic site

Versions

Version
2.2.1
2.2.0
2.1.0
2.0.1
2.0
1.0
1.0-RC3
1.0-RC2
1.0-RC1
0.1