001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.data.osm; 003 004import java.util.Set; 005 006import org.openstreetmap.josm.data.DataSource; 007 008/** 009 * The event that is fired when the data source list is changed. 010 * 011 * @author Taylor Smock 012 * @since 15609 013 */ 014public interface DataSourceChangeEvent { 015 /** 016 * Gets the previous data source list 017 * <p> 018 * This collection cannot be modified and will not change. 019 * 020 * @return The old data source list 021 */ 022 Set<DataSource> getOldDataSources(); 023 024 /** 025 * Gets the new data sources. New data sources are added to the end of the 026 * collection. 027 * <p> 028 * This collection cannot be modified and will not change. 029 * 030 * @return The new data sources 031 */ 032 Set<DataSource> getDataSources(); 033 034 /** 035 * Gets the Data Sources that have been removed from the selection. 036 * <p> 037 * Those are the primitives contained in {@link #getOldDataSources()} but not in 038 * {@link #getDataSources()} 039 * <p> 040 * This collection cannot be modified and will not change. 041 * 042 * @return The DataSources that were removed 043 */ 044 Set<DataSource> getRemoved(); 045 046 /** 047 * Gets the data sources that have been added to the selection. 048 * <p> 049 * Those are the data sources contained in {@link #getDataSources()} but not in 050 * {@link #getOldDataSources()} 051 * <p> 052 * This collection cannot be modified and will not change. 053 * 054 * @return The data sources that were added 055 */ 056 Set<DataSource> getAdded(); 057 058 /** 059 * Gets the data set that triggered this selection event. 060 * 061 * @return The data set. 062 */ 063 DataSet getSource(); 064 065 /** 066 * Test if this event did not change anything. 067 * <p> 068 * This will return <code>false</code> for all events that are sent to 069 * listeners, so you don't need to test it. 070 * 071 * @return <code>true</code> if this did not change the selection. 072 */ 073 default boolean isNop() { 074 return getAdded().isEmpty() && getRemoved().isEmpty(); 075 } 076} 077