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

com.vaadin.data.provider.DataChangeEvent Maven / Gradle / Ivy

There is a newer version: 8.27.3
Show newest version
/*
 * Copyright (C) 2000-2024 Vaadin Ltd
 *
 * This program is available under Vaadin Commercial License and Service Terms.
 *
 * See  for the full
 * license.
 */
package com.vaadin.data.provider;

import java.util.EventObject;
import java.util.Objects;

/**
 * An event fired when the data of a {@code DataProvider} changes.
 *
 * @see DataProviderListener
 *
 * @author Vaadin Ltd
 * @since 8.0
 *
 *
 * @param 
 *            the data type
 */
public class DataChangeEvent extends EventObject {

    /**
     * An event fired when a single item of a {@code DataProvider} has been
     * updated.
     *
     * @param 
     *            the data type
     */
    public static class DataRefreshEvent extends DataChangeEvent {

        private final T item;

        /**
         * Creates a new data refresh event originating from the given data
         * provider.
         *
         * @param source
         *            the data provider, not null
         * @param item
         *            the updated item, not null
         */
        public DataRefreshEvent(DataProvider source, T item) {
            super(source);
            Objects.requireNonNull(item, "Refreshed item can't be null");
            this.item = item;
        }

        /**
         * Gets the refreshed item.
         *
         * @return the refreshed item
         */
        public T getItem() {
            return item;
        }
    }

    /**
     * Creates a new {@code DataChangeEvent} event originating from the given
     * data provider.
     *
     * @param source
     *            the data provider, not null
     */
    public DataChangeEvent(DataProvider source) {
        super(source);
    }

    @Override
    public DataProvider getSource() {
        return (DataProvider) super.getSource();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy