@Test public void setNullPersistenceTagShouldThrow() { BackstackDelegate backstackDelegate = new BackstackDelegate(); try { backstackDelegate.setPersistenceTag(null); fail(); } catch(IllegalArgumentException e) { } }
@SuppressWarnings("StringEquality") public void setPersistenceTag(@Nonnull String persistenceTag) { if(backstack != null && backstack.isInitialized()) { throw new IllegalStateException("Persistence tag should be set before calling `onCreate()`"); } if(persistenceTag == null) { throw new IllegalArgumentException("Null persistence tag is not allowed!"); } if(this.persistenceTag == UNINITIALIZED) { this.persistenceTag = persistenceTag; } else if(!this.persistenceTag.equals(persistenceTag)) { throw new IllegalStateException("The persistence tag cannot be set to a new value once it's already set!"); } }
BackstackDelegate { @SuppressWarnings("StringEquality") public void setPersistenceTag(@Nonnull String persistenceTag) { if(backstack != null && backstack.isInitialized()) { throw new IllegalStateException("Persistence tag should be set before calling `onCreate()`"); } if(persistenceTag == null) { throw new IllegalArgumentException("Null persistence tag is not allowed!"); } if(this.persistenceTag == UNINITIALIZED) { this.persistenceTag = persistenceTag; } else if(!this.persistenceTag.equals(persistenceTag)) { throw new IllegalStateException("The persistence tag cannot be set to a new value once it's already set!"); } } }
BackstackDelegate { @SuppressWarnings("StringEquality") public void setPersistenceTag(@Nonnull String persistenceTag) { if(backstack != null && backstack.isInitialized()) { throw new IllegalStateException("Persistence tag should be set before calling `onCreate()`"); } if(persistenceTag == null) { throw new IllegalArgumentException("Null persistence tag is not allowed!"); } if(this.persistenceTag == UNINITIALIZED) { this.persistenceTag = persistenceTag; } else if(!this.persistenceTag.equals(persistenceTag)) { throw new IllegalStateException("The persistence tag cannot be set to a new value once it's already set!"); } } BackstackDelegate();  BackstackDelegate(@Nullable StateChanger stateChanger); }
BackstackDelegate { @SuppressWarnings("StringEquality") public void setPersistenceTag(@Nonnull String persistenceTag) { if(backstack != null && backstack.isInitialized()) { throw new IllegalStateException("Persistence tag should be set before calling `onCreate()`"); } if(persistenceTag == null) { throw new IllegalArgumentException("Null persistence tag is not allowed!"); } if(this.persistenceTag == UNINITIALIZED) { this.persistenceTag = persistenceTag; } else if(!this.persistenceTag.equals(persistenceTag)) { throw new IllegalStateException("The persistence tag cannot be set to a new value once it's already set!"); } } BackstackDelegate();  BackstackDelegate(@Nullable StateChanger stateChanger); void setKeyFilter(@Nonnull KeyFilter keyFilter); void setKeyParceler(@Nonnull KeyParceler keyParceler); void setStateClearStrategy(@Nonnull Backstack.StateClearStrategy stateClearStrategy); void setScopedServices(@Nullable Activity activity, @Nonnull ScopedServices scopedServices); void setGlobalServices(@Nullable Activity activity, @Nonnull GlobalServices globalServices); void setGlobalServices(@Nullable Activity activity, @Nonnull GlobalServices.Factory globalServiceFactory); void addStateChangeCompletionListener(@Nonnull Backstack.CompletionListener stateChangeCompletionListener); @SuppressWarnings("StringEquality") void setPersistenceTag(@Nonnull String persistenceTag); @TargetApi(14) void registerForLifecycleCallbacks(@Nonnull final Activity activity); void onCreate(@Nullable Bundle savedInstanceState, @Nullable Object nonConfigurationInstance, @Nonnull List<?> initialKeys); void setStateChanger(@Nullable StateChanger stateChanger); NonConfigurationInstance onRetainCustomNonConfigurationInstance(); boolean onBackPressed(); void onSaveInstanceState(@Nonnull Bundle outState); void onPostResume(); void onPause(); void onDestroy(); void persistViewToState(@Nullable View view); void restoreViewFromState(@Nonnull View view); @Nonnull SavedState getSavedState(@Nonnull Object key); boolean hasScope(@Nonnull String scopeTag); boolean hasService(@Nonnull ScopeKey scopeKey, @Nonnull String serviceTag); boolean hasService(@Nonnull String scopeTag, @Nonnull String serviceTag); @Nonnull T getService(@Nonnull ScopeKey scopeKey, @Nonnull String serviceTag); @Nonnull T getService(@Nonnull String scopeTag, @Nonnull String serviceTag); boolean canFindService(@Nonnull String serviceTag); @Nonnull T lookupService(@Nonnull String serviceTag); @Nonnull List<String> findScopesForKey(@Nonnull Object key, @Nonnull ScopeLookupMode lookupMode); boolean canFindFromScope(@Nonnull String scopeTag, @Nonnull String serviceTag); boolean canFindFromScope(@Nonnull String scopeTag, @Nonnull String serviceTag, @Nonnull ScopeLookupMode lookupMode); @Nonnull T lookupFromScope(@Nonnull String scopeTag, @Nonnull String serviceTag); @Nonnull T lookupFromScope(@Nonnull String scopeTag, @Nonnull String serviceTag, @Nonnull ScopeLookupMode lookupMode); @Nonnull Backstack getBackstack(); }
BackstackDelegate { @SuppressWarnings("StringEquality") public void setPersistenceTag(@Nonnull String persistenceTag) { if(backstack != null && backstack.isInitialized()) { throw new IllegalStateException("Persistence tag should be set before calling `onCreate()`"); } if(persistenceTag == null) { throw new IllegalArgumentException("Null persistence tag is not allowed!"); } if(this.persistenceTag == UNINITIALIZED) { this.persistenceTag = persistenceTag; } else if(!this.persistenceTag.equals(persistenceTag)) { throw new IllegalStateException("The persistence tag cannot be set to a new value once it's already set!"); } } BackstackDelegate();  BackstackDelegate(@Nullable StateChanger stateChanger); void setKeyFilter(@Nonnull KeyFilter keyFilter); void setKeyParceler(@Nonnull KeyParceler keyParceler); void setStateClearStrategy(@Nonnull Backstack.StateClearStrategy stateClearStrategy); void setScopedServices(@Nullable Activity activity, @Nonnull ScopedServices scopedServices); void setGlobalServices(@Nullable Activity activity, @Nonnull GlobalServices globalServices); void setGlobalServices(@Nullable Activity activity, @Nonnull GlobalServices.Factory globalServiceFactory); void addStateChangeCompletionListener(@Nonnull Backstack.CompletionListener stateChangeCompletionListener); @SuppressWarnings("StringEquality") void setPersistenceTag(@Nonnull String persistenceTag); @TargetApi(14) void registerForLifecycleCallbacks(@Nonnull final Activity activity); void onCreate(@Nullable Bundle savedInstanceState, @Nullable Object nonConfigurationInstance, @Nonnull List<?> initialKeys); void setStateChanger(@Nullable StateChanger stateChanger); NonConfigurationInstance onRetainCustomNonConfigurationInstance(); boolean onBackPressed(); void onSaveInstanceState(@Nonnull Bundle outState); void onPostResume(); void onPause(); void onDestroy(); void persistViewToState(@Nullable View view); void restoreViewFromState(@Nonnull View view); @Nonnull SavedState getSavedState(@Nonnull Object key); boolean hasScope(@Nonnull String scopeTag); boolean hasService(@Nonnull ScopeKey scopeKey, @Nonnull String serviceTag); boolean hasService(@Nonnull String scopeTag, @Nonnull String serviceTag); @Nonnull T getService(@Nonnull ScopeKey scopeKey, @Nonnull String serviceTag); @Nonnull T getService(@Nonnull String scopeTag, @Nonnull String serviceTag); boolean canFindService(@Nonnull String serviceTag); @Nonnull T lookupService(@Nonnull String serviceTag); @Nonnull List<String> findScopesForKey(@Nonnull Object key, @Nonnull ScopeLookupMode lookupMode); boolean canFindFromScope(@Nonnull String scopeTag, @Nonnull String serviceTag); boolean canFindFromScope(@Nonnull String scopeTag, @Nonnull String serviceTag, @Nonnull ScopeLookupMode lookupMode); @Nonnull T lookupFromScope(@Nonnull String scopeTag, @Nonnull String serviceTag); @Nonnull T lookupFromScope(@Nonnull String scopeTag, @Nonnull String serviceTag, @Nonnull ScopeLookupMode lookupMode); @Nonnull Backstack getBackstack();  }