AutoValue: Ignore Hash Equals Extension

AutoValue extension for ignoring a field in hashcodes and equals

License

License

Categories

Categories

Auto Application Layer Libs Code Generators
GroupId

GroupId

com.github.reggar
ArtifactId

ArtifactId

auto-value-ignore-hash-equals
Last Version

Last Version

1.1.4
Release Date

Release Date

Type

Type

jar
Description

Description

AutoValue: Ignore Hash Equals Extension
AutoValue extension for ignoring a field in hashcodes and equals
Project URL

Project URL

https://github.com/REggar/auto-value-ignore-hash-equals/
Source Code Management

Source Code Management

https://github.com/REggar/auto-value-ignore-hash-equals/

Download auto-value-ignore-hash-equals

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.reggar/auto-value-ignore-hash-equals/ -->
<dependency>
    <groupId>com.github.reggar</groupId>
    <artifactId>auto-value-ignore-hash-equals</artifactId>
    <version>1.1.4</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.reggar/auto-value-ignore-hash-equals/
implementation 'com.github.reggar:auto-value-ignore-hash-equals:1.1.4'
// https://jarcasting.com/artifacts/com.github.reggar/auto-value-ignore-hash-equals/
implementation ("com.github.reggar:auto-value-ignore-hash-equals:1.1.4")
'com.github.reggar:auto-value-ignore-hash-equals:jar:1.1.4'
<dependency org="com.github.reggar" name="auto-value-ignore-hash-equals" rev="1.1.4">
  <artifact name="auto-value-ignore-hash-equals" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.reggar', module='auto-value-ignore-hash-equals', version='1.1.4')
)
libraryDependencies += "com.github.reggar" % "auto-value-ignore-hash-equals" % "1.1.4"
[com.github.reggar/auto-value-ignore-hash-equals "1.1.4"]

Dependencies

compile (2)

Group / Artifact Type Version
com.google.auto.value : auto-value jar 1.2
com.squareup : javapoet jar 1.7.0

test (3)

Group / Artifact Type Version
junit : junit jar 4.12
com.google.truth : truth jar 0.28
com.google.testing.compile : compile-testing jar 0.9

Project Modules

There are no modules declared in this project.

AutoValue: Ignore Hash Equals Extension Build Status

An extension for Google's AutoValue that omits @IgnoreHashEquals field values from hashCode() and equals().

Basic Usage

Include the extension in your project, define an @IgnoreHashEquals annotation, and apply it to any fields that you wish to be ignored from the generated hashCode and equals implementation.

@Retention(SOURCE)
@Target({METHOD, PARAMETER, FIELD})
public @interface IgnoreHashEquals {
}
@AutoValue
public abstract class User {
  public abstract String id();
  @IgnoreHashEquals public abstract String name();
}

When you call hashCode() or equals() any properties with @IgnoreHashEquals will be ignored from the calculation.

@IncludeHashEquals Usage

Include the extension in your project, define an @IncludeHashEquals annotation, and apply it to any fields that you wish to be included from the generated hashCode and equals implementation.

@Retention(SOURCE)
@Target({METHOD, PARAMETER, FIELD})
public @interface IncludeHashEquals {
}
@AutoValue
public abstract class User {
  @IncludeHashEquals public abstract String id();
  public abstract String name();
}

When you call hashCode() or equals() any properties without @IncludeHashEquals will be ignored from the calculation.

Download

Add a Gradle dependency:

apt 'com.github.reggar:auto-value-ignore-hash-equals:1.1.4'

(Using the android-apt plugin)

or Maven:

<dependency>
  <groupId>com.github.reggar</groupId>
  <artifactId>auto-value-ignore-hash-equals</artifactId>
  <version>1.1.4</version>
  <scope>provided</scope>
</dependency>

Snapshots of the development version are available in Sonatype's snapshots repository.

Notes

This library is heavily inspired by Square's AutoValue: Redacted Extension.

License

Copyright 2017 Robert Eggar.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Versions

Version
1.1.4
1.1.3
1.1.2
1.1.1
1.1.0
1.0.0