Equalizer

Java Helper class to create nice equals methods

Лицензия

Лицензия

Группа

Группа

com.github.tonivade
Идентификатор

Идентификатор

equalizer
Последняя версия

Последняя версия

0.3.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

Equalizer
Java Helper class to create nice equals methods
Ссылка на сайт

Ссылка на сайт

https://github.com/tonivade/equalizer
Система контроля версий

Система контроля версий

https://github.com/tonivade/equalizer

Скачать equalizer

Как подключить последнюю версию

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

Зависимости

test (2)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.12
nl.jqno.equalsverifier : equalsverifier jar 1.7.5

Модули Проекта

Данный проект не имеет модулей.

Equalizer

Equalizer is a helper class in order to create nice equals method for your java classes.

There are some alternatives like commons-lang, guava or Object.equals, but all have the same problem:

@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }
    if (obj == null) {
        return false;
    }
    if (getClass() != obj.getClass()) {
        return false;
    }
    Data other = (Data) obj;
    return Objects.equals(this.id, other.id) && Objects.equals(this.value, other.value);
}

There are some boilerplate code you have to include previously to the fields comparison.

Equalizer tries to solve this problem:

@Override
public boolean equals(Object obj) {
    return equalizer(this)
        .append((one, other) -> Objects.equals(one.id, other.id))
        .append((one, other) -> Objects.equals(one.value, other.value))
        .applyTo(obj);
}

Build Status

Версии библиотеки

Версия
0.3.0
0.2.0