Affect.java

codebase/src/net/sourceforge/pain/logic/Affect.java · 1.3 KB

From the archive pain_0_44.tgz

Download the archive   « Back to the archive contents

package net.sourceforge.pain.logic;

import net.sourceforge.pain.data.*;

/**
 * Affect base class. (Controller for persistent AffectData)
 * <p/>
 * this class is linked statically to Core (could not be reloaded)
 * all it's subclasses in '..logic.affect.*'  package are loaded(linked) dynamycally
 *
 * Codebase require from all affect controllers (Affect subclasses) to have constructor with (AffectData d) param.
 * this constructor is used for automatically affect controller instantiation and initialization with
 * persistent image
 */

public abstract class Affect {

    protected AffectData ad;

    protected Affect(AffectData ad) {
        if (ad==null) {
            throw new NullPointerException("Affect data image is null!");
        }
        this.ad = ad;
    }


    /**
     * reflection is 10 times slower than 'new' method call (jdk1.4.2)
     * First time affect instance is created by codebase with reflection,
     * but all subsequent affect instance creations use this method call.
     * (It's required for all affects to have a public constructor like 'AffectAAA(AffectData ad)'
     * this constructor is used during first Affect instantiation by codebase)
     * @return new Affect object instance, inited with AffectData param
     */
    public abstract Affect newInstance(AffectData ad);

}

Site Stats

Snippets: 1791
Codebases: 571