@Test public void getStyleShouldReturnSelectedStyle() throws Exception { final JRadioButtonFixture fixture = findRadioButtonByName("settings.name.style.gson"); fixture.requireEnabled(); fixture.requireNotSelected(); fixture.target().setSelected(true); final Style actual = underTest.getStyle(); assertThat(actual) .overridingErrorMessage("Expected style to be <%s> but was <%s>", Style.GSON, actual) .isEqualTo(Style.GSON); }
@Nonnull @CheckReturnValue public Style getStyle() { final ButtonModel selected = styleGroup.getSelection(); return getStyleButtonStream() .filter(button -> { final ButtonModel model = button.getModel(); return model.equals(selected); }) .map(button -> { final String name = button.getText(); return Style.fromName(name, Style.NONE); }) .findFirst() .orElse(Style.NONE); }
SettingsPanel implements Disposable, ActionListener, DocumentListener { @Nonnull @CheckReturnValue public Style getStyle() { final ButtonModel selected = styleGroup.getSelection(); return getStyleButtonStream() .filter(button -> { final ButtonModel model = button.getModel(); return model.equals(selected); }) .map(button -> { final String name = button.getText(); return Style.fromName(name, Style.NONE); }) .findFirst() .orElse(Style.NONE); } }
SettingsPanel implements Disposable, ActionListener, DocumentListener { @Nonnull @CheckReturnValue public Style getStyle() { final ButtonModel selected = styleGroup.getSelection(); return getStyleButtonStream() .filter(button -> { final ButtonModel model = button.getModel(); return model.equals(selected); }) .map(button -> { final String name = button.getText(); return Style.fromName(name, Style.NONE); }) .findFirst() .orElse(Style.NONE); } SettingsPanel(); }
SettingsPanel implements Disposable, ActionListener, DocumentListener { @Nonnull @CheckReturnValue public Style getStyle() { final ButtonModel selected = styleGroup.getSelection(); return getStyleButtonStream() .filter(button -> { final ButtonModel model = button.getModel(); return model.equals(selected); }) .map(button -> { final String name = button.getText(); return Style.fromName(name, Style.NONE); }) .findFirst() .orElse(Style.NONE); } SettingsPanel(); @Override void dispose(); @Override void actionPerformed(@Nonnull ActionEvent event); @Override void insertUpdate(@Nonnull DocumentEvent event); @Override void removeUpdate(@Nonnull DocumentEvent event); @Override void changedUpdate(@Nonnull DocumentEvent event); @Nonnull @CheckReturnValue JComponent getComponent(); @Nonnull @CheckReturnValue Style getStyle(); void setStyle(@Nonnull Style style); @Nonnull @CheckReturnValue String getClassNamePrefix(); void setClassNamePrefix(@Nonnull String prefix); @Nonnull @CheckReturnValue String getClassNameSuffix(); void setClassNameSuffix(@Nonnull String suffix); @CheckReturnValue boolean isGeneratedAnnotationEnabled(); void setGeneratedAnnotationEnabled(boolean enabled); @CheckReturnValue boolean isSuppressWarningsAnnotationEnabled(); void setSuppressWarningsAnnotationEnabled(boolean enabled); void setPreviewText(@Nonnull String text); }
SettingsPanel implements Disposable, ActionListener, DocumentListener { @Nonnull @CheckReturnValue public Style getStyle() { final ButtonModel selected = styleGroup.getSelection(); return getStyleButtonStream() .filter(button -> { final ButtonModel model = button.getModel(); return model.equals(selected); }) .map(button -> { final String name = button.getText(); return Style.fromName(name, Style.NONE); }) .findFirst() .orElse(Style.NONE); } SettingsPanel(); @Override void dispose(); @Override void actionPerformed(@Nonnull ActionEvent event); @Override void insertUpdate(@Nonnull DocumentEvent event); @Override void removeUpdate(@Nonnull DocumentEvent event); @Override void changedUpdate(@Nonnull DocumentEvent event); @Nonnull @CheckReturnValue JComponent getComponent(); @Nonnull @CheckReturnValue Style getStyle(); void setStyle(@Nonnull Style style); @Nonnull @CheckReturnValue String getClassNamePrefix(); void setClassNamePrefix(@Nonnull String prefix); @Nonnull @CheckReturnValue String getClassNameSuffix(); void setClassNameSuffix(@Nonnull String suffix); @CheckReturnValue boolean isGeneratedAnnotationEnabled(); void setGeneratedAnnotationEnabled(boolean enabled); @CheckReturnValue boolean isSuppressWarningsAnnotationEnabled(); void setSuppressWarningsAnnotationEnabled(boolean enabled); void setPreviewText(@Nonnull String text);  }