Statement unnecessarily nested within else clause.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1606084 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary D. Gregory 2014-06-27 13:06:42 +00:00
parent 0ff8493544
commit 60b79a9082
1 changed files with 8 additions and 12 deletions

View File

@ -334,11 +334,10 @@ public final class Fraction extends Number implements Comparable<Fraction> {
pos = str.indexOf('/'); pos = str.indexOf('/');
if (pos < 0) { if (pos < 0) {
throw new NumberFormatException("The fraction could not be parsed as the format X Y/Z"); throw new NumberFormatException("The fraction could not be parsed as the format X Y/Z");
} else {
final int numer = Integer.parseInt(str.substring(0, pos));
final int denom = Integer.parseInt(str.substring(pos + 1));
return getFraction(whole, numer, denom);
} }
final int numer = Integer.parseInt(str.substring(0, pos));
final int denom = Integer.parseInt(str.substring(pos + 1));
return getFraction(whole, numer, denom);
} }
// parse Y/Z format // parse Y/Z format
@ -346,11 +345,10 @@ public final class Fraction extends Number implements Comparable<Fraction> {
if (pos < 0) { if (pos < 0) {
// simple whole number // simple whole number
return getFraction(Integer.parseInt(str), 1); return getFraction(Integer.parseInt(str), 1);
} else {
final int numer = Integer.parseInt(str.substring(0, pos));
final int denom = Integer.parseInt(str.substring(pos + 1));
return getFraction(numer, denom);
} }
final int numer = Integer.parseInt(str.substring(0, pos));
final int denom = Integer.parseInt(str.substring(pos + 1));
return getFraction(numer, denom);
} }
// Accessors // Accessors
@ -495,9 +493,8 @@ public final class Fraction extends Number implements Comparable<Fraction> {
} }
if (numerator<0) { if (numerator<0) {
return new Fraction(-denominator, -numerator); return new Fraction(-denominator, -numerator);
} else {
return new Fraction(denominator, numerator);
} }
return new Fraction(denominator, numerator);
} }
/** /**
@ -557,9 +554,8 @@ public final class Fraction extends Number implements Comparable<Fraction> {
final Fraction f = this.multiplyBy(this); final Fraction f = this.multiplyBy(this);
if (power % 2 == 0) { // if even... if (power % 2 == 0) { // if even...
return f.pow(power/2); return f.pow(power/2);
} else { // if odd...
return f.pow(power/2).multiplyBy(this);
} }
return f.pow(power/2).multiplyBy(this);
} }
} }