Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

squid:S1155 - Collection.isEmpty() should be used to test for emptiness #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public CDockableLocationListener getCDockableLocationListener(){
* @return <code>true</code> if there is at least one listener
*/
public boolean hasCDockableLocationListeners(){
return locationListeners.size() > 0;
return !locationListeners.isEmpty();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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++];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Dockable> iter = pendingRefreshs.iterator();
Dockable next = iter.next();
iter.remove();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void removePreferenceListener( PreferenceListener<V> listener ) {
* @return <code>true</code> if there are any listeners
*/
protected boolean hasListeners(){
return listeners.size() > 0;
return !listeners.isEmpty();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -3465,7 +3465,7 @@ public void fire(){
}
repositioned.clear();

if( dockables.size() > 0 ){
if( !dockables.isEmpty() ){
dockStationListeners.fireDockablesRepositioned( dockables.toArray( new Dockable[ dockables.size() ] ) );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand All @@ -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()] ) ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Dockable> list = DockUtilities.listDockables( dockable, true );
Expand All @@ -197,7 +197,7 @@ protected boolean fireAllHiding( Dockable dockable, final boolean cancelable ){
* if not.
*/
protected boolean fireAllHiding( Collection<Dockable> dockables, final boolean cancelable ){
if( vetoableListeners.size() == 0 )
if( vetoableListeners.isEmpty() )
return false;

if( dockables.isEmpty() )
Expand Down Expand Up @@ -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 );
Expand All @@ -277,7 +277,7 @@ protected boolean fireAllShowing( Dockable dockable, final boolean cancelable ){
* if the operation can continue
*/
protected boolean fireAllShowing( Collection<Dockable> dockables, final boolean cancelable ){
if( vetoableListeners.size() == 0 )
if( vetoableListeners.isEmpty() )
return false;

if( dockables.isEmpty() )
Expand All @@ -299,7 +299,7 @@ protected boolean fireAllShowing( Collection<Dockable> 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<Dockable> list = DockUtilities.listDockables( dockable, true );
Expand All @@ -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<Dockable> dockables, final boolean expected ){
if( vetoableListeners.size() == 0 )
if( vetoableListeners.isEmpty() )
return;

if( !dockables.isEmpty() ){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,7 @@ protected void estimateLocations( DefaultLocationEstimationMap map ){
DockLayoutComposition composition = map.getRoot();

List<DockLayoutComposition> children = composition.getChildren();
if( children == null || children.size() == 0 ){
if( children == null || children.isEmpty() ){
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected void changed( String oldValue, String newValue ){
* @return <code>true</code> if there is at least one listener
*/
protected boolean hasListeners(){
return listeners.size() > 0;
return !listeners.isEmpty();
}

/**
Expand Down Expand Up @@ -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 );
}
Expand All @@ -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 );
}
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ protected UISchemeListener<Color, DockColor, ColorBridge>[] listeners(){
* @return <code>true</code> if there is at least one listener attached
*/
protected boolean hasListeners(){
return listeners.size() > 0;
return !listeners.isEmpty();
}

/**
Expand Down Expand Up @@ -145,7 +145,7 @@ public void uninstall( UIProperties<Color, DockColor, ColorBridge> properties ){
}

private boolean shouldListenUI(){
return managers.size() > 0 || listeners.size() > 0;
return !managers.isEmpty() || !listeners.isEmpty();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -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 );
Expand All @@ -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 );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

Expand Down Expand Up @@ -99,7 +99,7 @@ protected void fireVisibilityChanged( boolean showing ){
* @param delegate the new provider, can be <code>null</code>
*/
public void setDelegate( WindowProvider delegate ) {
if( listeners.size() == 0 ){
if( listeners.isEmpty() ){
this.delegate = delegate;
}
else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()] ) );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
Expand Down