Repository: assertj/assertj

Problem statement:
String .hasSameSizeAs(...) should accept other String
We should extends this api to Strings for code like this

```
Assertions.assertThat("sss").hasSameSizeAs("dd");
```

String .hasSameSizeAs(...) should accept other String
We should extends this api to Strings for code like this

```
Assertions.assertThat("sss").hasSameSizeAs("dd");
```



Hints:
I would like to contribute, can I?

Yes that would be great !
Follow the [contributing guide](https://github.com/joel-costigliola/assertj-core/blob/master/CONTRIBUTING.md) and don't hesitate if you have questions ... 

Thanks ! 

Probably this API should accept `CharSequence` interface to allow to pass not only strings but also `StringBuilder`, `StringBuffer` and other types.

Good point ! 

The assertion must be added to `AbstractCharSequenceAssert`

I would like to contribute, can I?

Yes that would be great !
Follow the [contributing guide](https://github.com/joel-costigliola/assertj-core/blob/master/CONTRIBUTING.md) and don't hesitate if you have questions ... 

Thanks ! 

Probably this API should accept `CharSequence` interface to allow to pass not only strings but also `StringBuilder`, `StringBuffer` and other types.

Good point ! 

The assertion must be added to `AbstractCharSequenceAssert`


Patch:
diff --git a/src/main/java/org/assertj/core/api/AbstractCharSequenceAssert.java b/src/main/java/org/assertj/core/api/AbstractCharSequenceAssert.java
--- a/src/main/java/org/assertj/core/api/AbstractCharSequenceAssert.java
+++ b/src/main/java/org/assertj/core/api/AbstractCharSequenceAssert.java
@@ -143,6 +143,31 @@ public S hasSize(int expected) {
     return myself;
   }
 
+  /**
+   * Verifies that the actual {@code CharSequence} has a length that's the same as the length of the given
+   * {@code CharSequence}.
+   * <p>
+   * Examples :
+   * 
+   * <pre>
+   * // assertion will pass
+   * assertThat(&quot;C-3PO&quot;).hasSameSizeAs(&quot;R2-D2&quot;);
+   * 
+   * // assertion will fail as actual and expected sizes differ
+   * assertThat(&quot;C-3PO&quot;).hasSameSizeAs(&quot;B1 battle droid&quot;);
+   * </pre>
+   * 
+   * @param other the given {@code CharSequence} to be used for size comparison.
+   * @return {@code this} assertion object.
+   * @throws AssertionError if the actual {@code CharSequence} has a length that's different from the length of the
+   *           given {@code CharSequence}.
+   * @throws NullPointerException if the given {@code CharSequence} is {@code null}.
+   */
+  public S hasSameSizeAs(CharSequence other) {
+    strings.assertHasSize(info, actual, other.length());
+    return myself;
+  }
+
   /**
    * Verifies that the actual {@code CharSequence} has a length that's the same as the number of elements in the given
    * array.
diff --git a/src/main/java/org/assertj/core/api/EnumerableAssert.java b/src/main/java/org/assertj/core/api/EnumerableAssert.java
--- a/src/main/java/org/assertj/core/api/EnumerableAssert.java
+++ b/src/main/java/org/assertj/core/api/EnumerableAssert.java
@@ -33,7 +33,7 @@ public interface EnumerableAssert<S extends EnumerableAssert<S, E>, E> {
    * Verifies that the actual group of values is {@code null} or empty.
    * @throws AssertionError if the actual group of values is not {@code null} or not empty.
    */
-  void isNullOrEmpty() throws AssertionError;
+  void isNullOrEmpty();
 
   /**
    * Verifies that the actual group of values is empty.
diff --git a/src/main/java/org/assertj/core/description/TextDescription.java b/src/main/java/org/assertj/core/description/TextDescription.java
--- a/src/main/java/org/assertj/core/description/TextDescription.java
+++ b/src/main/java/org/assertj/core/description/TextDescription.java
@@ -14,7 +14,6 @@
  */
 package org.assertj.core.description;
 
-import java.util.regex.Pattern;
 import org.assertj.core.util.Arrays;
 import static org.assertj.core.util.Objects.HASH_CODE_PRIME;
 import static org.assertj.core.util.Objects.areEqual;
@@ -57,7 +56,7 @@ public String value() {
 
   @Override
   public int hashCode() {
-    return HASH_CODE_PRIME * 1 + hashCodeFor(value) + hashCodeFor(args);
+    return HASH_CODE_PRIME + hashCodeFor(value) + hashCodeFor(args);
   }
 
   @Override
diff --git a/src/main/java/org/assertj/core/internal/Dates.java b/src/main/java/org/assertj/core/internal/Dates.java
--- a/src/main/java/org/assertj/core/internal/Dates.java
+++ b/src/main/java/org/assertj/core/internal/Dates.java
@@ -1,6 +1,5 @@
 package org.assertj.core.internal;
 
-import java.util.concurrent.TimeUnit;
 import static org.assertj.core.error.ShouldBeAfter.shouldBeAfter;
 import static org.assertj.core.error.ShouldBeAfterOrEqualsTo.shouldBeAfterOrEqualsTo;
 import static org.assertj.core.error.ShouldBeBefore.shouldBeBefore;
@@ -20,7 +19,6 @@
 import static org.assertj.core.error.ShouldBeInTheFuture.shouldBeInTheFuture;
 import static org.assertj.core.error.ShouldBeInThePast.shouldBeInThePast;
 import static org.assertj.core.error.ShouldBeToday.shouldBeToday;
-import static org.assertj.core.error.ShouldBeEqual.shouldBeEqual;
 import static org.assertj.core.error.ShouldBeWithin.shouldBeWithin;
 import static org.assertj.core.error.ShouldHaveTime.shouldHaveTime;
 import static org.assertj.core.error.ShouldNotBeBetween.shouldNotBeBetween;
@@ -214,8 +212,7 @@ private boolean actualIsBetweenGivenPeriod(AssertionInfo info, Date actual, Date
     boolean checkLowerBoundaryPeriod = inclusiveStart ? isAfterOrEqualTo(actual, start) : isAfter(actual, start);
     boolean checkUpperBoundaryPeriod = inclusiveEnd ? isBeforeOrEqualTo(actual, end) : isBefore(actual, end);
     boolean isBetweenGivenPeriod = checkLowerBoundaryPeriod && checkUpperBoundaryPeriod;
-    if (isBetweenGivenPeriod) return true;
-    return false;
+    return isBetweenGivenPeriod;
   }
 
   /**
diff --git a/src/main/java/org/assertj/core/internal/Iterables.java b/src/main/java/org/assertj/core/internal/Iterables.java
--- a/src/main/java/org/assertj/core/internal/Iterables.java
+++ b/src/main/java/org/assertj/core/internal/Iterables.java
@@ -773,10 +773,7 @@ public <E> void assertAreAtLeast(AssertionInfo info, Iterable<? extends E> actua
   private <E> boolean conditionIsSatisfiedAtLeastNTimes(Iterable<? extends E> actual, int n,
       Condition<? super E> condition) {
     List<E> satisfiesCondition = satisfiesCondition(actual, condition);
-    if (satisfiesCondition.size() >= n) {
-      return true;
-    }
-    return false;
+    return satisfiesCondition.size() >= n;
   }
 
   /**
@@ -837,10 +834,7 @@ public <E> void assertAreExactly(AssertionInfo info, Iterable<? extends E> actua
 
   private <E> boolean conditionIsSatisfiedNTimes(Iterable<? extends E> actual, Condition<? super E> condition, int times) {
     List<E> satisfiesCondition = satisfiesCondition(actual, condition);
-    if (satisfiesCondition.size() == times) {
-      return true;
-    }
-    return false;
+    return satisfiesCondition.size() == times;
   }
 
   /**


Test patch:
diff --git a/src/test/java/org/assertj/core/api/charsequence/CharSequenceAssert_hasSameSizeAs_with_CharSequence_Test.java b/src/test/java/org/assertj/core/api/charsequence/CharSequenceAssert_hasSameSizeAs_with_CharSequence_Test.java
new file mode 100644
--- /dev/null
+++ b/src/test/java/org/assertj/core/api/charsequence/CharSequenceAssert_hasSameSizeAs_with_CharSequence_Test.java
@@ -0,0 +1,43 @@
+/*
+ * Created on Feb 2, 2014
+ * 
+ * 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.
+ * 
+ * Copyright @2010-2014 the original author or authors.
+ */
+package org.assertj.core.api.charsequence;
+
+import static org.mockito.Mockito.verify;
+
+import org.assertj.core.api.CharSequenceAssert;
+import org.assertj.core.api.CharSequenceAssertBaseTest;
+import org.junit.BeforeClass;
+
+/**
+ * Tests for <code>{@link org.assertj.core.api.CharSequenceAssert#hasSameSizeAs(CharSequence)}</code>.
+ */
+public class CharSequenceAssert_hasSameSizeAs_with_CharSequence_Test extends CharSequenceAssertBaseTest {
+  private static CharSequence other;
+
+  @BeforeClass
+  public static void setUpOnce() {
+    other = "Luke";
+  }
+
+  @Override
+  protected CharSequenceAssert invoke_api_method() {
+    return assertions.hasSameSizeAs(other);
+  }
+
+  @Override
+  protected void verify_internal_effects() {
+    verify(strings).assertHasSize(getInfo(assertions), getActual(assertions), other.length());
+  }
+}