Skip to content

Commit

Permalink
Split PropertyWithModificationCondition.set() into multiple lines and…
Browse files Browse the repository at this point in the history
… added doco.
  • Loading branch information
japgolly authored and fmpwizard committed Jul 6, 2013
1 parent 75a4a1d commit fb725ca
Showing 1 changed file with 17 additions and 1 deletion.
Expand Up @@ -5,8 +5,24 @@ package net.liftweb.util
*/
abstract class PropertyWithModificationCondition[T](initialValue: T) {
@volatile private var value = initialValue

def get = value
def set(newValue: T): Boolean = if (allowModification) {value = newValue; true} else {onModificationProhibited; false}

/**
* Attemps to set the property to a new value.
*
* @return Whether the new property was installed. `false` means modification is no longer allowed.
*/
def set(newValue: T): Boolean =
if (allowModification) {
value = newValue
true
} else {
onModificationProhibited()
false
}

def allowModification: Boolean

def onModificationProhibited() {}
}

0 comments on commit fb725ca

Please sign in to comment.