diff --git a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/stringreturners/IntegerIntegerStringReturner.java b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/stringreturners/IntegerIntegerStringReturner.java index f89bf428..d6f18998 100644 --- a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/stringreturners/IntegerIntegerStringReturner.java +++ b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/stringreturners/IntegerIntegerStringReturner.java @@ -2,6 +2,9 @@ import org.springframework.stereotype.Service; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; + import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.stringreturners.IntegerStringReturner; /** @@ -10,6 +13,8 @@ @Service public class IntegerIntegerStringReturner implements IntegerStringReturner { + private static final Logger loggerUsedToOutputPossibleErrorsFromMyResultingStringFromIntegerToStringConversion = LoggerFactory.getLogger(new IntegerIntegerStringReturner().getClass()); + /** * @param theInteger ing * @return String @@ -17,7 +22,29 @@ public class IntegerIntegerStringReturner implements IntegerStringReturner { public String getIntegerReturnString(final int theInteger) { final Integer myIntegerToBeConvertedToString = new Integer(theInteger); final StringBuilder myStringBuilder = new StringBuilder(myIntegerToBeConvertedToString.toString()); - final String myResultingStringFromIntegerToStringConversion = myStringBuilder.toString(); + final StringBuilder myOtherStringBuilder = new StringBuilder(); + myOtherStringBuilder.append(myStringBuilder.toString); + final String myResultingStringFromIntegerToStringConversion = myOtherStringBuilder.toString(); + /******************************** + * * + * Make sure that the original * + * StringBuilder matches the * + * new StringBuilder. * + * * + ********************************/ + final String myResultingStringFromIntegerToStringConversionThatIsUsedForChecking = new String(myStringBuilder.toString()); + /******************************** + * * + * This semicolon closes the * + * line where we define * + * myResultingStringFromIntegerToStringConversionThatIsUsedForChecking * + * * + ********************************/ + if (!myResultingStringFromIntegerToStringConversion.equals(myResultingStringFromIntegerToStringConversionThatIsUsedForChecking)) { + final IllegalStateException myIllegalStateExceptionThrownBecauseMyResultingStringFromIntegerToStringConversionDidNotEqualMyResultingStringFromIntegerToStringConversionThatIsUsedForChecking + = new IllegalStateException("myResultingStringFromIntegerToStringConversion did not equal myResultingStringFromIntegerToStringConversionThatIsUsedForChecking!"); + loggerUsedToOutputPossibleErrorsFromMyResultingStringFromIntegerToStringConversion.error(myIllegalStateExceptionThrownBecauseMyResultingStringFromIntegerToStringConversionDidNotEqualMyResultingStringFromIntegerToStringConversionThatIsUsedForChecking); + } return new String(myResultingStringFromIntegerToStringConversion); }