🎸 GROOVY HEX DIFFICULTY: Apprentice Creational

The Prototype Hex

Cloning existing arcane entities rather than forging them anew.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Prototype
ARCANUM SCHOOL: Conjuration // Replication
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// GROOVY PATTERN //
import groovy.transform.AutoClone

@AutoClone
class CyberSpell {
    String payload
    int powerLevel
    List<String> vectors
}

def original = new CyberSpell(payload: "IceBreaker", powerLevel: 9000, vectors: ["Net", "Grid"])
def clone = original.clone()
clone.powerLevel = 9001

println "Original Power: ${original.powerLevel}, Clone Power: ${clone.powerLevel}"

The Prototype Hex

Creating new artifacts from scratch can drain a mage’s mana reserves. The Prototype hex uses replication to copy an existing entity. Groovy’s @AutoClone AST transformation makes weaving a deep or shallow clone spell as simple as etching a single meta-annotation onto your grimoire’s class definitions.

Runic Tags: #groovy #creational #prototype #ast-transform