11package software .xdev .saveactions .model ;
22
33import java .util .ArrayList ;
4- import java .util .EnumSet ;
54import java .util .HashSet ;
65import java .util .List ;
76import java .util .Objects ;
1817
1918@ State (name = "SaveActionSettings" , storages = {@ com .intellij .openapi .components .Storage ("saveactions_settings.xml" )})
2019@ Service (Service .Level .PROJECT )
20+ @ SuppressWarnings ("PMD.UseEnumCollections" ) // Set must be nullable!
2121public final class Storage implements PersistentStateComponent <Storage >
2222{
2323 private boolean firstLaunch ;
24+ // Must use a set that supports nullable values!
25+ // For example EnumSet will crash when encountering an unknown/null value
2426 private Set <Action > actions ;
2527 private Set <String > exclusions ;
2628 private Set <String > inclusions ;
@@ -31,7 +33,7 @@ public final class Storage implements PersistentStateComponent<Storage>
3133 public Storage ()
3234 {
3335 this .firstLaunch = true ;
34- this .actions = EnumSet . noneOf ( Action . class );
36+ this .actions = new HashSet <>( );
3537 this .exclusions = new HashSet <>();
3638 this .inclusions = new HashSet <>();
3739 this .configurationPath = null ;
@@ -42,7 +44,7 @@ public Storage()
4244 public Storage (final Storage storage )
4345 {
4446 this .firstLaunch = storage .firstLaunch ;
45- this .actions = EnumSet . copyOf (storage .actions );
47+ this .actions = new HashSet <> (storage .actions );
4648 this .exclusions = new HashSet <>(storage .exclusions );
4749 this .inclusions = new HashSet <>(storage .inclusions );
4850 this .configurationPath = storage .configurationPath ;
0 commit comments