Spec-Zone .ru
спецификации, руководства, описания, API
|
001/* 002 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 004 * 005 * This code is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU General Public License version 2 only, as 007 * published by the Free Software Foundation. Oracle designates this 008 * particular file as subject to the "Classpath" exception as provided 009 * by Oracle in the LICENSE file that accompanied this code. 010 * 011 * This code is distributed in the hope that it will be useful, but WITHOUT 012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 014 * version 2 for more details (a copy is included in the LICENSE file that 015 * accompanied this code). 016 * 017 * You should have received a copy of the GNU General Public License version 018 * 2 along with this work; if not, write to the Free Software Foundation, 019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 020 * 021 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 022 * or visit www.oracle.com if you need additional information or have any 023 * questions. 024 */ 025 026package javafx.collections; 027 028/** 029 * Interface that receives notifications of changes to an ObservableSet. 030 * @param <E> the element type 031 */ 032public interface SetChangeListener<E> { 033 034 /** 035 * An elementary change done to an ObservableSet. 036 * Change contains information about an add or remove operation. 037 * Note that adding element that is already in the set does not 038 * modify the set and hence no change will be generated. 039 * 040 * @param <E> element type 041 */ 042 public static abstract class Change<E> { 043 044 private ObservableSet<E> set; 045 046 /** 047 * Constructs a change associated with a set. 048 * @param set the source of the change 049 */ 050 public Change(ObservableSet<E> set) { 051 this.set = set; 052 } 053 054 /** 055 * An observable set that is associated with the change. 056 * @return the source set 057 */ 058 public ObservableSet<E> getSet() { 059 return set; 060 } 061 062 /** 063 * If this change is a result of add operation. 064 * @return true if a new element was added to the set 065 */ 066 public abstract boolean wasAdded(); 067 068 /** 069 * If this change is a result of removal operation. 070 * @return true if an old element was removed from the set 071 */ 072 public abstract boolean wasRemoved(); 073 074 /** 075 * Get the new element. Return null if this is a removal. 076 * @return the element that was just added 077 */ 078 public abstract E getElementAdded(); 079 080 /** 081 * Get the old element. Return null if this is an addition. 082 * @return the element that was just removed 083 */ 084 public abstract E getElementRemoved(); 085 086 } 087 088 /** 089 * Called after a change has been made to an ObservableSet. 090 * This method is called on every elementary change (add/remove) once. 091 * This means, complex changes like removeAll(Collection) or clear() 092 * may result in more than one call of onChanged method. 093 * 094 * @param change the change that was made 095 */ 096 void onChanged(Change<? extends E> change); 097}