From bbc5e3e1094a78a75bc0b42c6a30fdf3d410b35d Mon Sep 17 00:00:00 2001 From: Ilya Kharlamov <502372+ilyakharlamov@users.noreply.github.com> Date: Thu, 24 Jan 2019 18:26:44 -0500 Subject: [PATCH] (#1030) ComparableText is not equal to the same text (equals) --- .../java/org/cactoos/text/ComparableText.java | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/cactoos/text/ComparableText.java b/src/main/java/org/cactoos/text/ComparableText.java index 88eba832b8..ad3500ea2b 100644 --- a/src/main/java/org/cactoos/text/ComparableText.java +++ b/src/main/java/org/cactoos/text/ComparableText.java @@ -23,8 +23,8 @@ */ package org.cactoos.text; -import java.util.Objects; import org.cactoos.Text; +import org.cactoos.scalar.Equals; import org.cactoos.scalar.HashCode; import org.cactoos.scalar.UncheckedScalar; @@ -73,18 +73,12 @@ public String asString() throws Exception { @Override public boolean equals(final Object other) { - final boolean result; - if (this == other) { - result = true; - } else if (other == null || this.getClass() != other.getClass()) { - result = false; - } else { - result = Objects.equals( - this.text, - ((ComparableText) other).text - ); - } - return result; + return new UncheckedScalar<>( + new Equals<>( + this.text::asString, + () -> ComparableText.class.cast(other).asString() + ) + ).value(); } @Override