7 kyu

Guava against Million dollar error

130 of 131Javatlacati

Description:

Let's use Google Guava Library to fight against the million dollar error.

As start point we have a simple sum function and we need it to validate the following, in order:

  • that parameters are not null
  • if first parameter is null throw NPE with message "Illegal Argument passed: First parameter is Null."
  • if second parameter is null throw NPE with message "Illegal Argument passed: Second parameter is Null."
  • that parameters are positive ( > 0 )
  • if this is not the case then throw IllegalArgumentException with message "Illegal Argument passed: Non-positive value d." where d is the non-positive value (no need to format the value, just turn it into a string). If both values are non-positive, use the first parameter.

Hint: you could use a reading to class com.google.common.base.Preconditions

Fundamentals

Similar Kata:

Stats:

CreatedNov 8, 2017
PublishedFeb 24, 2018
Warriors Trained278
Total Skips1
Total Code Submissions560
Total Times Completed131
Java Completions130
Total Stars4
% of votes with a positive feedback rating70% of 40
Total "Very Satisfied" Votes22
Total "Somewhat Satisfied" Votes12
Total "Not Satisfied" Votes6
Total Rank Assessments8
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • Javatlacati Avatar
  • Voile Avatar
Ad