<commit_before>/*
 * Copyright 2015 - 2016 Xyanid
 *
 * 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
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * 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 de.saxsys.bindablefx;

import com.sun.istack.internal.Nullable;
import javafx.beans.WeakListener;
import javafx.beans.property.ObjectProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import org.jetbrains.annotations.NotNull;

import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import java.util.Optional;

/**
 * This class represents the basic binding class, it simply hold the {@link ObjectProperty} and a {@link ChangeListener}, which will be invoked each time the
 * observedProperty is changed. Every time the {@link #observedProperty} is changed the class extending from this class will be informed and can react to the
 * new state of the observedProperty according to its own needs.
 *
 * @author xyanid on 30.03.2016.
 */
//TODO maybe caching of events that happened during creation of the instance in a sub class need to be cached so they are not lost and
//TODO invoked when the sub class activates the listener ?
public abstract class BaseBinding<TPropertyValue> extends ReferenceQueue implements ChangeListener<TPropertyValue>, WeakListener {

    //region Fields

    /**
     * Determines the {@link ObjectProperty} which is watched by this binding.
     */
    @Nullable
    private WeakReference<ObjectProperty<TPropertyValue>> observedProperty;

    //endregion

    // region Getter

    /**<commit_msg>- removed wrong package in base binding<commit_after>/*
 * Copyright 2015 - 2016 Xyanid
 *
 * 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
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * 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 de.saxsys.bindablefx;

import javafx.beans.WeakListener;
import javafx.beans.property.ObjectProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import java.util.Optional;

/**
 * This class represents the basic binding class, it simply hold the {@link ObjectProperty} and a {@link ChangeListener}, which will be invoked each time the
 * observedProperty is changed. Every time the {@link #observedProperty} is changed the class extending from this class will be informed and can react to the
 * new state of the observedProperty according to its own needs.
 *
 * @author xyanid on 30.03.2016.
 */
//TODO maybe caching of events that happened during creation of the instance in a sub class need to be cached so they are not lost and
//TODO invoked when the sub class activates the listener ?
public abstract class BaseBinding<TPropertyValue> extends ReferenceQueue implements ChangeListener<TPropertyValue>, WeakListener {

    //region Fields

    /**
     * Determines the {@link ObjectProperty} which is watched by this binding.
     */
    @Nullable
    private WeakReference<ObjectProperty<TPropertyValue>> observedProperty;

    //endregion

    // region Getter

    /**
{'fraction_non_alphanumeric': 0.07160616608652412, 'fraction_numerical': 0.009945300845350571, 'mean_word_length': 4.217898832684825, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '5995218', 'n_tokens_mistral': 1046, 'n_tokens_neox': 985, 'n_words': 462}