From 7bb6bf6a5447efe5215b70e340739d44e9797295 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Tue, 21 Jan 2014 00:09:10 -0800 Subject: [PATCH] Polish --- .../grape/RepositoryConfiguration.java | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/RepositoryConfiguration.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/RepositoryConfiguration.java index bd047e3796..485f19a355 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/RepositoryConfiguration.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/RepositoryConfiguration.java @@ -18,6 +18,8 @@ package org.springframework.boot.cli.compiler.grape; import java.net.URI; +import org.springframework.util.ObjectUtils; + /** * The configuration of a repository * @@ -75,28 +77,22 @@ public final class RepositoryConfiguration { @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((this.name == null) ? 0 : this.name.hashCode()); - return result; + return ObjectUtils.nullSafeHashCode(this.name); } @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) + } + if (obj == null) { return false; - RepositoryConfiguration other = (RepositoryConfiguration) obj; - if (this.name == null) { - if (other.name != null) - return false; } - else if (!this.name.equals(other.name)) + if (getClass() != obj.getClass()) { return false; - return true; + } + RepositoryConfiguration other = (RepositoryConfiguration) obj; + return ObjectUtils.nullSafeEquals(this.name, other.name); } -} \ No newline at end of file +}