This decorator permits moving method preconditions into a designated spot, i.e., transforming
class Magician {
doMagic(cardDeck) {
if (cardDeck == null || cardDeck == undefined) {
// Must have a card deck for trick
return null;
}
if (cardDeck.isShuffled()) {
// Can not perform this trick if someone else shuffled the cards
return null;
}
// Do magic
}
}
into
class Magician {
@Pre(cardDeck => !!cardDeck && !cardDeck.isShuffled())
doMagic(cardDeck) {
// Do magic
}
}
This decorator permits moving method preconditions into a designated spot, i.e., transforming
into