From a4a8aab0663f26806e3e0fffd761b5f03420754a Mon Sep 17 00:00:00 2001 From: Mohamed Ezzat Date: Tue, 21 Jun 2016 05:27:25 +0200 Subject: [PATCH] squid:S1155 - Collection.isEmpty() should be used to test for emptiness --- .../gui/dock/common/intern/CListenerCollection.java | 2 +- .../gui/dock/common/perspective/CPerspective.java | 2 +- .../gui/dock/facile/mode/LocationModeManager.java | 2 +- .../gui/dock/preference/AbstractPreference.java | 2 +- .../gui/dock/preference/PreferenceTreeModel.java | 2 +- .../preference/preferences/choice/DefaultChoice.java | 2 +- .../src/bibliothek/gui/dock/SplitDockStation.java | 6 +++--- .../gui/dock/action/AbstractDockActionSource.java | 2 +- .../dock/dockable/DockableStateListenerManager.java | 4 ++-- .../bibliothek/gui/dock/frontend/VetoManager.java | 12 ++++++------ .../bibliothek/gui/dock/layout/DockSituation.java | 2 +- .../bibliothek/gui/dock/themes/DefaultThemeMeta.java | 10 +++++----- .../themes/basic/action/buttons/ButtonPanel.java | 2 +- .../gui/dock/themes/color/AbstractColorScheme.java | 4 ++-- .../gui/dock/util/AbstractWindowProvider.java | 8 ++++---- .../gui/dock/util/FocusedWindowProvider.java | 2 +- .../gui/dock/util/WindowProviderWrapper.java | 6 +++--- .../bibliothek/gui/dock/ToolbarGroupDockStation.java | 2 +- .../bibliothek/gui/dock/wizard/WizardNodeMap.java | 2 +- 19 files changed, 37 insertions(+), 37 deletions(-) diff --git a/docking-frames-common/src/bibliothek/gui/dock/common/intern/CListenerCollection.java b/docking-frames-common/src/bibliothek/gui/dock/common/intern/CListenerCollection.java index d78aaaf8..d254198e 100644 --- a/docking-frames-common/src/bibliothek/gui/dock/common/intern/CListenerCollection.java +++ b/docking-frames-common/src/bibliothek/gui/dock/common/intern/CListenerCollection.java @@ -280,7 +280,7 @@ public CDockableLocationListener getCDockableLocationListener(){ * @return true if there is at least one listener */ public boolean hasCDockableLocationListeners(){ - return locationListeners.size() > 0; + return !locationListeners.isEmpty(); } /** diff --git a/docking-frames-common/src/bibliothek/gui/dock/common/perspective/CPerspective.java b/docking-frames-common/src/bibliothek/gui/dock/common/perspective/CPerspective.java index c12718dd..0fe382a4 100644 --- a/docking-frames-common/src/bibliothek/gui/dock/common/perspective/CPerspective.java +++ b/docking-frames-common/src/bibliothek/gui/dock/common/perspective/CPerspective.java @@ -352,7 +352,7 @@ public boolean hasNext(){ } public PerspectiveElement next(){ - while( stack.size() > 0 ){ + while( !stack.isEmpty() ){ ElementFrame top = stack.peek(); if( top.offset < top.items.length ){ PerspectiveElement result = top.items[top.offset++]; diff --git a/docking-frames-common/src/bibliothek/gui/dock/facile/mode/LocationModeManager.java b/docking-frames-common/src/bibliothek/gui/dock/facile/mode/LocationModeManager.java index 87c4e834..66e87003 100644 --- a/docking-frames-common/src/bibliothek/gui/dock/facile/mode/LocationModeManager.java +++ b/docking-frames-common/src/bibliothek/gui/dock/facile/mode/LocationModeManager.java @@ -696,7 +696,7 @@ public void dockableUnregistered( DockController controller, Dockable dockable ) @Override public void registerUnstalled( DockController controller ){ - while( pendingRefreshs.size() > 0 && !controller.getRegister().isStalled() ){ + while( !pendingRefreshs.isEmpty() && !controller.getRegister().isStalled() ){ Iterator iter = pendingRefreshs.iterator(); Dockable next = iter.next(); iter.remove(); diff --git a/docking-frames-core/src/bibliothek/extension/gui/dock/preference/AbstractPreference.java b/docking-frames-core/src/bibliothek/extension/gui/dock/preference/AbstractPreference.java index 88bf00b4..4a05a199 100644 --- a/docking-frames-core/src/bibliothek/extension/gui/dock/preference/AbstractPreference.java +++ b/docking-frames-core/src/bibliothek/extension/gui/dock/preference/AbstractPreference.java @@ -55,7 +55,7 @@ public void removePreferenceListener( PreferenceListener listener ) { * @return true if there are any listeners */ protected boolean hasListeners(){ - return listeners.size() > 0; + return !listeners.isEmpty(); } /** diff --git a/docking-frames-core/src/bibliothek/extension/gui/dock/preference/PreferenceTreeModel.java b/docking-frames-core/src/bibliothek/extension/gui/dock/preference/PreferenceTreeModel.java index 597463c4..48d1901f 100644 --- a/docking-frames-core/src/bibliothek/extension/gui/dock/preference/PreferenceTreeModel.java +++ b/docking-frames-core/src/bibliothek/extension/gui/dock/preference/PreferenceTreeModel.java @@ -89,7 +89,7 @@ public PreferenceTreeModel( PathCombiner combiner, DockController controller ){ @Override protected boolean hasListeners(){ - return super.hasListeners() || treeListeners.size() > 0; + return super.hasListeners() || !treeListeners.isEmpty(); } public void addTreeModelListener( TreeModelListener l ) { diff --git a/docking-frames-core/src/bibliothek/extension/gui/dock/preference/preferences/choice/DefaultChoice.java b/docking-frames-core/src/bibliothek/extension/gui/dock/preference/preferences/choice/DefaultChoice.java index bb647682..34210fc4 100644 --- a/docking-frames-core/src/bibliothek/extension/gui/dock/preference/preferences/choice/DefaultChoice.java +++ b/docking-frames-core/src/bibliothek/extension/gui/dock/preference/preferences/choice/DefaultChoice.java @@ -336,7 +336,7 @@ public String getDefaultChoice() { if( isNullEntryAllowed() ) return null; - if( list.size() > 0 ) + if( !list.isEmpty() ) return list.get( 0 ).getEntryId(); return null; diff --git a/docking-frames-core/src/bibliothek/gui/dock/SplitDockStation.java b/docking-frames-core/src/bibliothek/gui/dock/SplitDockStation.java index 82e3950e..65c15bea 100644 --- a/docking-frames-core/src/bibliothek/gui/dock/SplitDockStation.java +++ b/docking-frames-core/src/bibliothek/gui/dock/SplitDockStation.java @@ -1495,7 +1495,7 @@ public Dockable getFrontDockable(){ if( isFullScreen() ) return getFullScreen(); - if( frontDockable == null && dockables.size() > 0 ) + if( frontDockable == null && !dockables.isEmpty() ) frontDockable = dockables.get(0).getDockable(); return frontDockable; @@ -1610,7 +1610,7 @@ protected void updateVisibility(){ * fullscreen (if it is not already fullscreen). */ public void setNextFullScreen(){ - if( dockables.size() > 0 ) { + if( !dockables.isEmpty() ) { if( fullScreenDockable == null ) setFullScreen(getDockable(0)); else { @@ -3465,7 +3465,7 @@ public void fire(){ } repositioned.clear(); - if( dockables.size() > 0 ){ + if( !dockables.isEmpty() ){ dockStationListeners.fireDockablesRepositioned( dockables.toArray( new Dockable[ dockables.size() ] ) ); } diff --git a/docking-frames-core/src/bibliothek/gui/dock/action/AbstractDockActionSource.java b/docking-frames-core/src/bibliothek/gui/dock/action/AbstractDockActionSource.java index a01b6173..9a9e05c6 100644 --- a/docking-frames-core/src/bibliothek/gui/dock/action/AbstractDockActionSource.java +++ b/docking-frames-core/src/bibliothek/gui/dock/action/AbstractDockActionSource.java @@ -55,7 +55,7 @@ public void removeDockActionSourceListener( DockActionSourceListener listener ) * @return whether at least one listener is registered */ public boolean hasListeners(){ - return listeners.size() > 0; + return !listeners.isEmpty(); } /** diff --git a/docking-frames-core/src/bibliothek/gui/dock/dockable/DockableStateListenerManager.java b/docking-frames-core/src/bibliothek/gui/dock/dockable/DockableStateListenerManager.java index 910478d9..684d7713 100644 --- a/docking-frames-core/src/bibliothek/gui/dock/dockable/DockableStateListenerManager.java +++ b/docking-frames-core/src/bibliothek/gui/dock/dockable/DockableStateListenerManager.java @@ -198,7 +198,7 @@ public void removeListener( DockableStateListener listener ){ * @return whether there is at least one listener */ protected boolean hasListeners(){ - return listeners.size() > 0; + return !listeners.isEmpty(); } /** @@ -224,7 +224,7 @@ public void run(){ */ private void fireNow(){ if( current != 0 ) { - if( listeners.size() > 0 ) { + if( !listeners.isEmpty() ) { DockableStateEvent event = new DockableStateEvent( dockable, current ); current = 0; for( DockableStateListener listener : listeners.toArray( new DockableStateListener[listeners.size()] ) ) { diff --git a/docking-frames-core/src/bibliothek/gui/dock/frontend/VetoManager.java b/docking-frames-core/src/bibliothek/gui/dock/frontend/VetoManager.java index e6cfe0b0..39e5385d 100644 --- a/docking-frames-core/src/bibliothek/gui/dock/frontend/VetoManager.java +++ b/docking-frames-core/src/bibliothek/gui/dock/frontend/VetoManager.java @@ -180,7 +180,7 @@ protected VetoableDockFrontendListener[] vetoableListeners(){ * if not. */ protected boolean fireAllHiding( Dockable dockable, final boolean cancelable ){ - if( vetoableListeners.size() == 0 ) + if( vetoableListeners.isEmpty() ) return false; List list = DockUtilities.listDockables( dockable, true ); @@ -197,7 +197,7 @@ protected boolean fireAllHiding( Dockable dockable, final boolean cancelable ){ * if not. */ protected boolean fireAllHiding( Collection dockables, final boolean cancelable ){ - if( vetoableListeners.size() == 0 ) + if( vetoableListeners.isEmpty() ) return false; if( dockables.isEmpty() ) @@ -261,7 +261,7 @@ protected void fireAllHidden( Dockable dockable, final boolean expected ){ * if the operation can continue */ protected boolean fireAllShowing( Dockable dockable, final boolean cancelable ){ - if( vetoableListeners.size() == 0 ) + if( vetoableListeners.isEmpty() ) return false; return fireAllShowing( DockUtilities.listDockables( dockable, true ), cancelable ); @@ -277,7 +277,7 @@ protected boolean fireAllShowing( Dockable dockable, final boolean cancelable ){ * if the operation can continue */ protected boolean fireAllShowing( Collection dockables, final boolean cancelable ){ - if( vetoableListeners.size() == 0 ) + if( vetoableListeners.isEmpty() ) return false; if( dockables.isEmpty() ) @@ -299,7 +299,7 @@ protected boolean fireAllShowing( Collection dockables, final boolean * @param expected whether the event is expected or not */ protected void fireAllShown( Dockable dockable, final boolean expected ){ - if( vetoableListeners.size() == 0 ) + if( vetoableListeners.isEmpty() ) return; List list = DockUtilities.listDockables( dockable, true ); @@ -313,7 +313,7 @@ protected void fireAllShown( Dockable dockable, final boolean expected ){ * @param expected whether the event is expected or not */ protected void fireAllShown( Collection dockables, final boolean expected ){ - if( vetoableListeners.size() == 0 ) + if( vetoableListeners.isEmpty() ) return; if( !dockables.isEmpty() ){ diff --git a/docking-frames-core/src/bibliothek/gui/dock/layout/DockSituation.java b/docking-frames-core/src/bibliothek/gui/dock/layout/DockSituation.java index b43b0bd8..99569c37 100644 --- a/docking-frames-core/src/bibliothek/gui/dock/layout/DockSituation.java +++ b/docking-frames-core/src/bibliothek/gui/dock/layout/DockSituation.java @@ -1188,7 +1188,7 @@ protected void estimateLocations( DefaultLocationEstimationMap map ){ DockLayoutComposition composition = map.getRoot(); List children = composition.getChildren(); - if( children == null || children.size() == 0 ){ + if( children == null || children.isEmpty() ){ return; } diff --git a/docking-frames-core/src/bibliothek/gui/dock/themes/DefaultThemeMeta.java b/docking-frames-core/src/bibliothek/gui/dock/themes/DefaultThemeMeta.java index 837bf01f..260ab246 100644 --- a/docking-frames-core/src/bibliothek/gui/dock/themes/DefaultThemeMeta.java +++ b/docking-frames-core/src/bibliothek/gui/dock/themes/DefaultThemeMeta.java @@ -88,7 +88,7 @@ protected void changed( String oldValue, String newValue ){ * @return true if there is at least one listener */ protected boolean hasListeners(){ - return listeners.size() > 0; + return !listeners.isEmpty(); } /** @@ -141,7 +141,7 @@ public void addListener( ThemeMetaListener listener ){ if( listener == null ){ throw new IllegalArgumentException( "listener must not be null" ); } - if( listeners.size() == 0 ){ + if( listeners.isEmpty() ){ name.setController( controller ); description.setController( controller ); } @@ -150,7 +150,7 @@ public void addListener( ThemeMetaListener listener ){ public void removeListener( ThemeMetaListener listener ){ listeners.remove( listener ); - if( listeners.size() == 0 ){ + if( listeners.isEmpty() ){ name.setController( null ); description.setController( null ); } @@ -166,14 +166,14 @@ public String[] getAuthors(){ } public String getDescription(){ - if( listeners.size() == 0 ){ + if( listeners.isEmpty() ){ description.update( controller.getTexts() ); } return description.value(); } public String getName(){ - if( listeners.size() == 0 ){ + if( listeners.isEmpty() ){ name.update( controller.getTexts() ); } return name.value(); diff --git a/docking-frames-core/src/bibliothek/gui/dock/themes/basic/action/buttons/ButtonPanel.java b/docking-frames-core/src/bibliothek/gui/dock/themes/basic/action/buttons/ButtonPanel.java index f06c592a..3a4ca37e 100755 --- a/docking-frames-core/src/bibliothek/gui/dock/themes/basic/action/buttons/ButtonPanel.java +++ b/docking-frames-core/src/bibliothek/gui/dock/themes/basic/action/buttons/ButtonPanel.java @@ -206,7 +206,7 @@ public DockActionSource getSource(){ * @return whether at least one action is present */ public boolean hasActions(){ - return actions.size() > 0; + return !actions.isEmpty(); } /** diff --git a/docking-frames-core/src/bibliothek/gui/dock/themes/color/AbstractColorScheme.java b/docking-frames-core/src/bibliothek/gui/dock/themes/color/AbstractColorScheme.java index 04618df1..54357941 100644 --- a/docking-frames-core/src/bibliothek/gui/dock/themes/color/AbstractColorScheme.java +++ b/docking-frames-core/src/bibliothek/gui/dock/themes/color/AbstractColorScheme.java @@ -106,7 +106,7 @@ protected UISchemeListener[] listeners(){ * @return true if there is at least one listener attached */ protected boolean hasListeners(){ - return listeners.size() > 0; + return !listeners.isEmpty(); } /** @@ -145,7 +145,7 @@ public void uninstall( UIProperties properties ){ } private boolean shouldListenUI(){ - return managers.size() > 0 || listeners.size() > 0; + return !managers.isEmpty() || !listeners.isEmpty(); } /** diff --git a/docking-frames-core/src/bibliothek/gui/dock/util/AbstractWindowProvider.java b/docking-frames-core/src/bibliothek/gui/dock/util/AbstractWindowProvider.java index ac13959f..9a02ec9b 100644 --- a/docking-frames-core/src/bibliothek/gui/dock/util/AbstractWindowProvider.java +++ b/docking-frames-core/src/bibliothek/gui/dock/util/AbstractWindowProvider.java @@ -70,7 +70,7 @@ public void componentHidden( ComponentEvent e ) { protected void updateVisibility(){ Window current = searchWindow(); if( window != current ){ - if( listeners.size() > 0 ){ + if( !listeners.isEmpty() ){ if( window != null ) window.removeComponentListener( windowListener ); if( current != null ) @@ -121,14 +121,14 @@ protected WindowProviderListener[] listeners(){ * @return whether this provider is monitored */ protected boolean hasListeners(){ - return listeners.size() > 0; + return !listeners.isEmpty(); } public void addWindowProviderListener( WindowProviderListener listener ) { if( listener == null ) throw new IllegalArgumentException( "null is not allowed as listener" ); - if( listeners.size() == 0 ){ + if( listeners.isEmpty() ){ updateVisibility(); if( window != null ){ window.addComponentListener( windowListener ); @@ -142,7 +142,7 @@ public void addWindowProviderListener( WindowProviderListener listener ) { public void removeWindowProviderListener( WindowProviderListener listener ) { listeners.remove( listener ); - if( listeners.size() == 0 ){ + if( listeners.isEmpty() ){ if( window != null ){ window.removeComponentListener( windowListener ); } diff --git a/docking-frames-core/src/bibliothek/gui/dock/util/FocusedWindowProvider.java b/docking-frames-core/src/bibliothek/gui/dock/util/FocusedWindowProvider.java index 81dabbb9..159a0ced 100644 --- a/docking-frames-core/src/bibliothek/gui/dock/util/FocusedWindowProvider.java +++ b/docking-frames-core/src/bibliothek/gui/dock/util/FocusedWindowProvider.java @@ -80,7 +80,7 @@ public void remove( Window window ){ window.removeWindowFocusListener( listener ); if( current == window ){ current = null; - if( history.size() > 0 ){ + if( !history.isEmpty() ){ current = history.get( history.size()-1 ); } fireWindowChanged( current ); diff --git a/docking-frames-core/src/bibliothek/gui/dock/util/WindowProviderWrapper.java b/docking-frames-core/src/bibliothek/gui/dock/util/WindowProviderWrapper.java index 9c59a300..9d22a516 100644 --- a/docking-frames-core/src/bibliothek/gui/dock/util/WindowProviderWrapper.java +++ b/docking-frames-core/src/bibliothek/gui/dock/util/WindowProviderWrapper.java @@ -55,14 +55,14 @@ public void visibilityChanged( WindowProvider provider, boolean showing ){ public void addWindowProviderListener( WindowProviderListener listener ) { int previous = listeners.size(); listeners.add( listener ); - if( previous == 0 && listeners.size() > 0 && delegate != null ) + if( previous == 0 && !listeners.isEmpty() && delegate != null ) delegate.addWindowProviderListener( this.listener ); } public void removeWindowProviderListener( WindowProviderListener listener ) { int previous = listeners.size(); listeners.remove( listener ); - if( previous > 0 && listeners.size() == 0 && delegate != null ) + if( previous > 0 && listeners.isEmpty() && delegate != null ) delegate.removeWindowProviderListener( this.listener ); } @@ -99,7 +99,7 @@ protected void fireVisibilityChanged( boolean showing ){ * @param delegate the new provider, can be null */ public void setDelegate( WindowProvider delegate ) { - if( listeners.size() == 0 ){ + if( listeners.isEmpty() ){ this.delegate = delegate; } else{ diff --git a/docking-frames-ext-toolbar/src/bibliothek/gui/dock/ToolbarGroupDockStation.java b/docking-frames-ext-toolbar/src/bibliothek/gui/dock/ToolbarGroupDockStation.java index 0175a579..a2e4c4b5 100644 --- a/docking-frames-ext-toolbar/src/bibliothek/gui/dock/ToolbarGroupDockStation.java +++ b/docking-frames-ext-toolbar/src/bibliothek/gui/dock/ToolbarGroupDockStation.java @@ -1066,7 +1066,7 @@ protected void fireColumnRepositioned( int column, boolean all ){ } } - if( list.size() > 0 ) { + if( !list.isEmpty() ) { listeners.fireDockablesRepositioned( list.toArray( new Dockable[list.size()] ) ); } } diff --git a/docking-frames-ext-toolbar/src/bibliothek/gui/dock/wizard/WizardNodeMap.java b/docking-frames-ext-toolbar/src/bibliothek/gui/dock/wizard/WizardNodeMap.java index 6c815c18..0e477742 100644 --- a/docking-frames-ext-toolbar/src/bibliothek/gui/dock/wizard/WizardNodeMap.java +++ b/docking-frames-ext-toolbar/src/bibliothek/gui/dock/wizard/WizardNodeMap.java @@ -506,7 +506,7 @@ private PersistentColumn[] adapt( PersistentColumn[] oldColumns, PersistentColum column.setSize( Math.max( source.getSize(), column.getPreferredSize() )); } } - else if( sources.size() > 0 ){ + else if( !sources.isEmpty() ){ int max = 0; for( PersistentColumn source : sources ){ max = Math.max( max, source.getSize() );