I have a class with the Violation "Missing Static Method In Non Instantiatable Class" - This is a false-positive because this class has public access over a factory method. This method creates instances from the class.
public class AccountSelectionSubForm extends Form implements WidgetEventListener
{
@SuppressWarnings("PMD.UselessOverridingMethod") // the method is protected in the base class
public static class AccountSelectionSubFormObservable extends Observable
{
@Override
public void setChanged()
{
super.setChanged();
}
}
private BaseConfig baseConfig;
private AccountManager accountManager;
private WorkingAccountStore workingAccountStore;
private AccountSelectionSubFormObservable observable;
private AccountSelectionDetailsSubForm details;
private Combobox<Account> accountSelection;
private boolean supportAllAccountsSelection;
private boolean supportAccountless;
private boolean localSelect;
private Button refreshButton;
public static class Factory
{
private BaseConfig baseConfig;
private AccountManager accountManager;
private WorkingAccountStore workingAccountStore;
@Inject
public Factory( BaseConfig baseConfig, AccountManager accountManager, WorkingAccountStore workingAccountStore )
{
this.baseConfig = baseConfig;
this.accountManager = accountManager;
this.workingAccountStore = workingAccountStore;
}
public AccountSelectionSubForm create( Form parent, boolean supportAllAccountsSelection )
{
return create( parent, supportAllAccountsSelection, false );
}
public AccountSelectionSubForm create( Form parent, boolean supportAllAccountsSelection, boolean supportAccountless )
{
return new AccountSelectionSubForm( parent, baseConfig, accountManager, workingAccountStore, supportAllAccountsSelection, supportAccountless );
}
public AccountSelectionSubForm create( Form parent, RequestTypeIdentifier requestTypeIdentifier, boolean signAvailable, boolean supportAllAccountsSelection )
{
return create( parent, new RequestTypeIdentifier[]{requestTypeIdentifier}, signAvailable, supportAllAccountsSelection );
}
public AccountSelectionSubForm create( Form parent, RequestTypeIdentifier[] requestTypeIdentifiers, boolean signAvailable, boolean supportAllAccountsSelection )
{
return new AccountSelectionSubForm( parent, baseConfig, accountManager, workingAccountStore, requestTypeIdentifiers, signAvailable, supportAllAccountsSelection, false );
}
}
private AccountSelectionSubForm( Form parent, BaseConfig baseConfig, AccountManager accountManager, WorkingAccountStore workingAccountStore, boolean supportAllAccountsSelection, boolean supportAccountless )
{
super( parent, null );
this.baseConfig = baseConfig;
this.accountManager = accountManager;
this.workingAccountStore = workingAccountStore;
this.supportAllAccountsSelection = supportAllAccountsSelection;
this.supportAccountless = supportAccountless;
init();
}
private AccountSelectionSubForm( Form parent, BaseConfig baseConfig, AccountManager accountManager, WorkingAccountStore workingAccountStore, RequestTypeIdentifier[] requestTypeIdentifiers, boolean signAvailable, boolean supportAllAccountsSelection, boolean supportAccountLess )
{
this( parent, baseConfig, accountManager, workingAccountStore, supportAllAccountsSelection, supportAccountLess );
// now get the requested DataProvider (with or without all accounts option)
changeRequestIds( requestTypeIdentifiers, signAvailable );
refresh();
}
private void init()
{
// create combobox
accountSelection = new Combobox<Account>( this );
accountSelection.setSortComparator( new AccountComparator( baseConfig.getAccountSorting() ).getComboboxItemComparator() );
// create details sub form
details = new AccountSelectionDetailsSubForm( this );
details.changeSelected( getSelectedAccount() );
// create refresh Button
refreshButton = new Button( this );
refreshButton.setImageKey( "accountSelectionForm.image.refreshButton" );
refreshButton.addEventListener( this );
// create a observable proxy
observable = new AccountSelectionSubFormObservable();
}
...