Skip to content

Commit

Permalink
removed constants
Browse files Browse the repository at this point in the history
  • Loading branch information
Vedran authored and Vedran committed Mar 30, 2018
1 parent 80346f9 commit c1ccfb4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
16 changes: 3 additions & 13 deletions src/main/java/org/cactoos/scalar/InheritanceLevel.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
* 2 -> two inheritance levels. (ex. matching FileNotFoundException with
* Exception)
* ...
* 999 -> classes are not related.
* Integer.MAX_VALUE -> classes are not related.
* (ex. matching FileNotFoundException with RuntimeException)
* </p>
*
Expand All @@ -49,16 +49,6 @@
*/
public final class InheritanceLevel implements Scalar<Integer> {

/**
* Classes are identical.
*/
private static final int IDENTICAL = 0;

/**
* Classes are not related.
*/
private static final int NOT_RELATED = 999;

/**
* Base class.
*/
Expand All @@ -83,7 +73,7 @@ public InheritanceLevel(final Class<?> cderived, final Class<?> cbase) {
public Integer value() {
final int level;
if (this.base.equals(this.derived)) {
level = InheritanceLevel.IDENTICAL;
level = 0;
} else {
level = this.calculateLevel();
}
Expand All @@ -95,7 +85,7 @@ public Integer value() {
* @return Integer Level
*/
private int calculateLevel() {
int level = InheritanceLevel.NOT_RELATED;
int level = Integer.MAX_VALUE;
Class<?> sclass = this.derived.getSuperclass();
int idx = 0;
while (!sclass.equals(Object.class)) {
Expand Down
3 changes: 1 addition & 2 deletions src/test/java/org/cactoos/scalar/InheritanceLevelTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,11 @@ public void twoInheritanceLevelsBetweenClasses() {

@Test
public void classesAreNotRelated() {
final int expected = 999;
MatcherAssert.assertThat(
new InheritanceLevel(
FileNotFoundException.class, RuntimeException.class
).value(),
Matchers.equalTo(expected)
Matchers.equalTo(Integer.MAX_VALUE)
);
}

Expand Down

0 comments on commit c1ccfb4

Please sign in to comment.