<commit_before>package no.ntnu.capgeminitest.data;

import java.util.List;
import java.util.ArrayList;

import no.ntnu.capgeminitest.event.PropertyChangeListener;

/**
 * Hold a property for a class.
 * 
 * A sophisticated wrapper for a property, supporting {@code PropertyChangeListener}s.
 * 
 * Used with the data binding framework.
 * 
 * @param <T>
 *            The type of this property.
 */
public class Property<T> {
    
    /**
     * A listener that is used to update this property.
     * 
     * When this property is bound to another property, it will listen to
     * changes to the other property and update itself on change.
     */
    private class OnPropertyChangeUpdater implements PropertyChangeListener<T> {
        @Override public void propertyChanged(Property<T> property) {
            set(property.get());
        }      
    }
    
    private T data;
    private List<PropertyChangeListener<T>> listeners = new ArrayList<PropertyChangeListener<T>>();
    private OnPropertyChangeUpdater updateListener = new OnPropertyChangeUpdater();
    
    public Property(T data) {
        this.data = data;
    }

    /**
     * @return The data contained in this property.
     */
    public T get() {
        return data;
    }

    /**
     * Override this method to receive property changes.
     * 
     * Called before other bindings are notified.
     * 
     * Note: Changing the property inside {@code onChange} triggers a recursive call.
     */
    protected void onChange(T newValue) {
        // Empty.
    }
    
    /**
     * Set the data for this property.
     * 
     * Notifies listeners that the data was changed.
     */
    public void set(T data) {
        this.data = data;
        onChange(data);
        notifyListeners();
    }

    protected void notifyListeners() {
        for (PropertyChangeListener<T> listener : listeners) {
            listener.propertyChanged(this);
        }
    }

    public void addListener(PropertyChangeListener<T> listener) {
        listeners.add(listener);
    }

    public void removeListener(PropertyChangeListener<T> listener) {
        listeners.remove(listener);
    }
    
    PropertyChangeListener<T> getOnPropertyChangeUpdater() {
        return updateListener;
    }
}<commit_msg>Make listener interface package private.<commit_after>package no.ntnu.capgeminitest.data;

import java.util.List;
import java.util.ArrayList;

import no.ntnu.capgeminitest.event.PropertyChangeListener;

/**
 * Hold a property for a class.
 * 
 * A sophisticated wrapper for a property, supporting {@code PropertyChangeListener}s.
 * 
 * Used with the data binding framework.
 * 
 * @param <T>
 *            The type of this property.
 */
public class Property<T> {
    
    /**
     * A listener that is used to update this property.
     * 
     * When this property is bound to another property, it will listen to
     * changes to the other property and update itself on change.
     */
    private class OnPropertyChangeUpdater implements PropertyChangeListener<T> {
        @Override public void propertyChanged(Property<T> property) {
            set(property.get());
        }      
    }
    
    private T data;
    private List<PropertyChangeListener<T>> listeners = new ArrayList<PropertyChangeListener<T>>();
    private OnPropertyChangeUpdater updateListener = new OnPropertyChangeUpdater();
    
    public Property(T data) {
        this.data = data;
    }

    /**
     * @return The data contained in this property.
     */
    public T get() {
        return data;
    }

    /**
     * Override this method to receive property changes.
     * 
     * Called before other bindings are notified.
     * 
     * Note: Changing the property inside {@code onChange} triggers a recursive call.
     */
    protected void onChange(T newValue) {
        // Empty.
    }
    
    /**
     * Set the data for this property.
     * 
     * Notifies listeners that the data was changed.
     */
    public void set(T data) {
        this.data = data;
        onChange(data);
        notifyListeners();
    }

    protected void notifyListeners() {
        for (PropertyChangeListener<T> listener : listeners) {
            listener.propertyChanged(this);
        }
    }

    void addListener(PropertyChangeListener<T> listener) {
        listeners.add(listener);
    }

    void removeListener(PropertyChangeListener<T> listener) {
        listeners.remove(listener);
    }
    
    PropertyChangeListener<T> getOnPropertyChangeUpdater() {
        return updateListener;
    }
}
{'fraction_non_alphanumeric': 0.08839657819697302, 'fraction_numerical': 0.0, 'mean_word_length': 2.4234234234234235, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, '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': '5523610', 'n_tokens_mistral': 1223, 'n_tokens_neox': 1205, 'n_words': 368}