// Meta - a "minimal" approach to adding meta-level to Java objects // // v2 - now much easier and more performant // OK you can read the rants here: #1031838 so right now I will stick to // describing the changes. sclass Meta_v2 implements IMeta_v2 { // So what's new in Meta v2? // We still have one field - but now it's definitely a map (a map // can hold anything, so...) // And we make this field, or rather, the object contained in it, // "speak" for itself. It's just a map that you can use like any // other one. It may shape-shift during its operation, meaning it // can even change its base class to accomodate for special cases. // This, however, necessitates that the object can exchange itself // for another one at any point. Thus the regular Map interface // will not cut it. volatile O meta; // The meta field is not transient, thus by default it will be // persisted like anything else unless you customize your object // to suppress or modulate this. // ...and the interface methods public void _setMeta(O meta) { this.meta = meta; } public O _getMeta() { ret meta; } // That was layer 1... // ...and here is the convenience stuff - just use the meta field like a regular map. void metaSet aka metaPut(O key, O value) { metaMapPut(this, key, value); } O metaGet(O key) { ret metaMapGet(this, key); } }