All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.softsmithy.lib.beans.PropertyChangeUtils Maven / Gradle / Ivy

There is a newer version: 2.1.1
Show newest version
/*
 *         COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Notice
 *
 * The contents of this file are subject to the COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL)
 * Version 1.0 (the "License"); you may not use this file except in
 * compliance with the License. A copy of the License is available at
 * http://www.opensource.org/licenses/cddl1.txt
 *
 * The Original Code is SoftSmithy Utility Library. The Initial Developer of the
 * Original Code is Florian Brunner (Sourceforge.net user: puce). All Rights Reserved.
 *
 * Contributor(s): .
 */
package org.softsmithy.lib.beans;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeSupport;

/**
 * A utility class for {@link PropertyChangeEvent}s.
 *
 * @author puce
 */
public final class PropertyChangeUtils {

    private PropertyChangeUtils() {
    }

    /**
     * Notifies all listeners registered in the provided {@link PropertyChangeSupport} that the provided double property
     * changed (only if the newValue is not equal to the oldValue).
     *
     * @param propertyChangeSupport a PropertyChangeSupport
     * @param propertyName the name of the property
     * @param oldValue the old value of the property
     * @param newValue the new value of the property
     * @see PropertyChangeSupport#firePropertyChange(java.lang.String, java.lang.Object, java.lang.Object)
     */
    public static void firePropertyChange(PropertyChangeSupport propertyChangeSupport,
            String propertyName, double oldValue, double newValue) {
        if (oldValue != newValue) {
            propertyChangeSupport.firePropertyChange(propertyName, oldValue, newValue);
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy