<commit_before>package powerups;

import models.Activation;
import models.Club;
import models.PowerupModel;
import play.twirl.api.Html;

import java.io.Serializable;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public abstract class Powerup implements Serializable {

    Club club;
    public PowerupModel model;

    public Powerup(Club club, PowerupModel model) {
        this.club = club;
        this.model = model;
    }

    public abstract Html render();

    public static Powerup getPowerup(Activation activation) {
        PowerupModel powerupModel = PowerupModel.find.byId(activation.key.powerupId);
        Club club = Club.find.byId(activation.key.clubId);

        try {
            @SuppressWarnings("unchecked")
            Class<? extends Powerup> c = (Class<? extends Powerup>) Class.forName("powerups." + powerupModel.className);
            Constructor<? extends Powerup> constructor = c.getDeclaredConstructor(Club.class, PowerupModel.class);
            return constructor.newInstance(club, powerupModel);
        } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) {
            e.printStackTrace();
        }
        return null;
    }
}<commit_msg>Document and restrict the abstract class Powerup.<commit_after>package powerups;

import models.Activation;
import models.Club;
import models.PowerupModel;
import play.twirl.api.Html;

import java.io.Serializable;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public abstract class Powerup implements Serializable {

    /**
     * Private access as no Powerup should ever be able to change the name of a Club.
     */
    private final Club club;

    /**
     * Final, as no view should ever have access to modify its own model runtime.
     */
    public final PowerupModel model;

    /**
     * Boilerplate constructor used to set up a Powerup. This exposes some vital information for all Powerups.
     * @param club The club referenced by the {@link models.Activation} used to instantiate the Powerup. It is saved
     *             for reference.
     * @param model The model referenced by the {@link models.Activation} used to instantiate the Powerup. It is saved
     *              so that views may access the data held by the model.
     * @see play.db.ebean.Model
     */
    public Powerup(Club club, PowerupModel model) {
        this.club = club;
        this.model = model;
    }

    /**
     * Every powerup must implement a method to render its associated view. For now, only one view may be referenced,
     * though this is likely to change as the API matures.
     * @return The HTML to insert into the club's view.
     * @see views.html.club.show
     * @see play.twirl.api.Html
     */
    public abstract Html render();

    /**
     * Lazily loads the {@link powerups.Powerup} associated with the {@link models.Activation}
     * @param activation The activation used to instantiate the Powerup.
     * @return The instantiated Powerup.
     */
    public static Powerup getPowerup(Activation activation) {
        PowerupModel powerupModel = PowerupModel.find.byId(activation.key.powerupId);
        Club club = Club.find.byId(activation.key.clubId);

        try {
            @SuppressWarnings("unchecked")
            Class<? extends Powerup> c = (Class<? extends Powerup>) Class.forName("powerups." + powerupModel.className);
            Constructor<? extends Powerup> constructor = c.getDeclaredConstructor(Club.class, PowerupModel.class);
            return constructor.newInstance(club, powerupModel);
        } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) {
            e.printStackTrace();
        }
        return null;
    }

    protected Club getClub() {
        return club;
    }
}
{'fraction_non_alphanumeric': 0.08343836652382153, 'fraction_numerical': 0.0, 'mean_word_length': 2.9919517102615694, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '781130', 'n_tokens_mistral': 1063, 'n_tokens_neox': 1028, 'n_words': 336}