Skip to content

Commit

Permalink
Enhanced the opionation of Box -- fixed typos
Browse files Browse the repository at this point in the history
  • Loading branch information
dpp committed Jul 31, 2012
1 parent 0e1e2a3 commit 8779c8f
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions core/common/src/main/scala/net/liftweb/common/Box.scala
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,12 @@ sealed abstract class Box[+A] extends Product with Serializable{
*
* @param nameOfPersonThatThoughtThisWasAGoodIdea -- yes... your name will be included in every exception
* thrown by calling this method
* @param lameButSemiPlausableReasonWhyYouThinkThisIsAGoodIdea -- Okay, Mr. Smartypants, you think it's a good idea
* @param lameButSemiPlausibleReasonWhyYouThinkThisIsAGoodIdea -- Okay, Mr. Smartypants, you think it's a good idea
* calling this method. Tell us why.
* @return The contents of the Box if it has one or an exception if not
*/
def openTheBoxButThisMightResultInAnExceptionSoDontUseThisMethod(nameOfPersonThatThoughtThisWasAGoodIdea: String,
lameButSemiPlausableReasonWhyYouThinkThisIsAGoodIdea: String): A
lameButSemiPlausibleReasonWhyYouThinkThisIsAGoodIdea: String): A

/**
* Return the value contained in this Box if it is Full;
Expand Down Expand Up @@ -529,12 +529,12 @@ final case class Full[+A](value: A) extends Box[A]{
*
* @param nameOfPersonThatThoughtThisWasAGoodIdea -- yes... your name will be included in every exception
* thrown by calling this method
* @param lameButPlausableReasonWhyYouThinkThisIsAGoodIdea -- Okay, Mr. Smartypants, you think it's a good idea
* @param lameButSemiPlausibleReasonWhyYouThinkThisIsAGoodIdea -- Okay, Mr. Smartypants, you think it's a good idea
* calling this method. Tell us why.
* @return The contents of the Box if it has one or an exception if not
*/
def openTheBoxButThisMightResultInAnExceptionSoDontUseThisMethod(nameOfPersonThatThoughtThisWasAGoodIdea: String,
lameButPlausableReasonWhyYouThinkThisIsAGoodIdea: String): A = value
lameButSemiPlausibleReasonWhyYouThinkThisIsAGoodIdea: String): A = value


override def openOr[B >: A](default: => B): B = value
Expand Down Expand Up @@ -626,13 +626,15 @@ sealed abstract class EmptyBox extends Box[Nothing] with Serializable {
*
* @param nameOfPersonThatThoughtThisWasAGoodIdea -- yes... your name will be included in every exception
* thrown by calling this method
* @param lameButPlausableReasonWhyYouThinkThisIsAGoodIdea -- Okay, Mr. Smartypants, you think it's a good idea
* @param lameButSemiPlausibleReasonWhyYouThinkThisIsAGoodIdea -- Okay, Mr. Smartypants, you think it's a good idea
* calling this method. Tell us why.
* @return The contents of the Box if it has one or an exception if not
*/
def openTheBoxButThisMightResultInAnExceptionSoDontUseThisMethod(nameOfPersonThatThoughtThisWasAGoodIdea: String,
lameButPlausableReasonWhyYouThinkThisIsAGoodIdea: String) =
throw new NullPointerException("So, "+nameOfPersonThatThoughtThisWasAGoodIdea+" thought it might be a good idea to open a Box even though it could be empty. The justification was '"+lameButPlausableReasonWhyYouThinkThisIsAGoodIdea+"'. Turns out it was a bad idea")
lameButSemiPlausibleReasonWhyYouThinkThisIsAGoodIdea: String) =
throw new NullPointerException("So, "+nameOfPersonThatThoughtThisWasAGoodIdea+
" thought it might be a good idea to open a Box even though it could be empty. The justification was '"+
lameButSemiPlausibleReasonWhyYouThinkThisIsAGoodIdea+"'. Turns out it was a bad idea")



Expand Down Expand Up @@ -685,15 +687,17 @@ sealed case class Failure(msg: String, exception: Box[Throwable], chain: Box[Fai
*
* @param nameOfPersonThatThoughtThisWasAGoodIdea -- yes... your name will be included in every exception
* thrown by calling this method
* @param lameButPlausableReasonWhyYouThinkThisIsAGoodIdea -- Okay, Mr. Smartypants, you think it's a good idea
* @param lameButSemiPlausibleReasonWhyYouThinkThisIsAGoodIdea -- Okay, Mr. Smartypants, you think it's a good idea
* calling this method. Tell us why.
* @return The contents of the Box if it has one or an exception if not
*/
override def openTheBoxButThisMightResultInAnExceptionSoDontUseThisMethod(nameOfPersonThatThoughtThisWasAGoodIdea: String,
lameButPlausableReasonWhyYouThinkThisIsAGoodIdea: String) =
lameButSemiPlausibleReasonWhyYouThinkThisIsAGoodIdea: String) =
throw new NullPointerException("So, "+nameOfPersonThatThoughtThisWasAGoodIdea+
" thought it might be a good idea to open a Box even though it could be empty. The justification was '"+
lameButPlausableReasonWhyYouThinkThisIsAGoodIdea+"'. Turns out it was a bad idea. By the way, the Failure that was opened contained the error message: '"+msg+"'.") {
lameButSemiPlausibleReasonWhyYouThinkThisIsAGoodIdea+
"'. Turns out it was a bad idea. By the way, the Failure that was opened contained the error message: '"+
msg+"'.") {
override def getCause() = exception openOr null
}

Expand Down

0 comments on commit 8779c8f

Please sign in to comment.