com.vaadin.data.provider.DataChangeEvent Maven / Gradle / Ivy
/*
* 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();
}
}