<commit_before>/**
 * Copyright 2014 the original author or authors
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.wandrell.tabletop.punkapocalyptic.model.inventory;

import static com.google.common.base.Preconditions.checkNotNull;

import java.util.Collection;
import java.util.Collections;
import java.util.EventObject;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.Objects;

import javax.swing.event.EventListenerList;

import com.google.common.base.MoreObjects;
import com.wandrell.tabletop.punkapocalyptic.model.event.ValorationListener;
import com.wandrell.tabletop.punkapocalyptic.model.ruleset.SpecialRule;
import com.wandrell.tabletop.punkapocalyptic.model.ruleset.WeaponModifierSpecialRule;

public abstract class AbstractWeapon implements Weapon {

    private final Collection<WeaponEnhancement> enhancements = new LinkedList<WeaponEnhancement>();
    private final EventListenerList             listeners    = new EventListenerList();
    private final Collection<SpecialRule>       rules        = new LinkedHashSet<SpecialRule>();
    private final Boolean                       twoHanded;
    private final Integer                       weaponCost;
    private final String                        weaponName;

    public AbstractWeapon(final AbstractWeapon weapon) {
        super();

        checkNotNull(weapon, "Received a null pointer as weapon");
        checkNotNull(rules, "Received a null pointer as rules");

        weaponName = weapon.weaponName;

        weaponCost = weapon.weaponCost;
        twoHanded = weapon.twoHanded;

        rules.addAll(weapon.rules);
        for (final SpecialRule rule : rules) {
            if (rule instanceof WeaponModifierSpecialRule) {
                ((WeaponModifierSpecialRule) rule).applyToWeapon(this);
            }
        }

        enhancements.addAll(weapon.enhancements);
    }

    public AbstractWeapon(final String name, final Integer cost,
            final Boolean twoHanded, final Collection<SpecialRule> rules) {
        super();

        checkNotNull(name, "Received a null pointer as name");
        checkNotNull(cost, "Received a null pointer as cost");
        checkNotNull(twoHanded, "Received a null pointer as two handed flag");
        checkNotNull(rules, "Received a null pointer as rules");

        this.weaponName = name;

        this.twoHanded = twoHanded;

        this.weaponCost = cost;

        for (final SpecialRule rule : rules) {
            checkNotNull(rule, "Received a null pointer as rule");

            this.rules.add(rule);

            if (rule instanceof WeaponModifierSpecialRule) {
                ((WeaponModifierSpecialRule) rule).applyToWeapon(this);
            }
        }
    }

    @Override
    public final void addEnhancement(final WeaponEnhancement enhancement) {
        checkNotNull(enhancement,
                "Received a null pointer as weapon enhancement");

        getEnhancementsModifiable().add(enhancement);

        fireValorationChangedEvent(new EventObject(this));
    }

    @Override
    public final void addValorationListener(final ValorationListener listener) {<commit_msg>Removed the weapon modifier rules.<commit_after>/**
 * Copyright 2014 the original author or authors
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.wandrell.tabletop.punkapocalyptic.model.inventory;

import static com.google.common.base.Preconditions.checkNotNull;

import java.util.Collection;
import java.util.Collections;
import java.util.EventObject;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.Objects;

import javax.swing.event.EventListenerList;

import com.google.common.base.MoreObjects;
import com.wandrell.tabletop.punkapocalyptic.model.event.ValorationListener;
import com.wandrell.tabletop.punkapocalyptic.model.ruleset.SpecialRule;

public abstract class AbstractWeapon implements Weapon {

    private final Collection<WeaponEnhancement> enhancements = new LinkedList<WeaponEnhancement>();
    private final EventListenerList             listeners    = new EventListenerList();
    private final Collection<SpecialRule>       rules        = new LinkedHashSet<SpecialRule>();
    private final Boolean                       twoHanded;
    private final Integer                       weaponCost;
    private final String                        weaponName;

    public AbstractWeapon(final AbstractWeapon weapon) {
        super();

        checkNotNull(weapon, "Received a null pointer as weapon");
        checkNotNull(rules, "Received a null pointer as rules");

        weaponName = weapon.weaponName;

        weaponCost = weapon.weaponCost;
        twoHanded = weapon.twoHanded;

        rules.addAll(weapon.rules);

        enhancements.addAll(weapon.enhancements);
    }

    public AbstractWeapon(final String name, final Integer cost,
            final Boolean twoHanded, final Collection<SpecialRule> rules) {
        super();

        checkNotNull(name, "Received a null pointer as name");
        checkNotNull(cost, "Received a null pointer as cost");
        checkNotNull(twoHanded, "Received a null pointer as two handed flag");
        checkNotNull(rules, "Received a null pointer as rules");

        this.weaponName = name;

        this.twoHanded = twoHanded;

        this.weaponCost = cost;

        for (final SpecialRule rule : rules) {
            checkNotNull(rule, "Received a null pointer as rule");

            this.rules.add(rule);
        }
    }

    @Override
    public final void addEnhancement(final WeaponEnhancement enhancement) {
        checkNotNull(enhancement,
                "Received a null pointer as weapon enhancement");

        getEnhancementsModifiable().add(enhancement);

        fireValorationChangedEvent(new EventObject(this));
    }

    @Override
    public final void addValorationListener(final ValorationListener listener) {
{'fraction_non_alphanumeric': 0.07814073967477335, 'fraction_numerical': 0.00230248956684415, 'mean_word_length': 3.1051388068517425, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2658130', 'n_tokens_mistral': 1813, 'n_tokens_neox': 1757, 'n_words': 553}