ColorProperty extends OptionalProperty<Color> implements ActionListener { public ColorProperty(@NotNull ColorPanel colorPanel) { myColorPanel = colorPanel; myColorPanel.addActionListener(this); } ColorProperty(@NotNull ColorPanel colorPanel); @Override void actionPerformed(ActionEvent actionEvent); @NotNull @Override Optional<Color> get();  }
@Test public void testColorProperty() throws Exception { ColorPanel colorPanel = new ColorPanel(); ColorProperty color = new ColorProperty(colorPanel); CountListener listener = new CountListener(); color.addListener(listener); assertThat(color.get().isPresent()).isFalse(); assertThat(listener.getCount()).isEqualTo(0); colorPanel.setSelectedColor(Color.RED); assertThat(color.get().isPresent()).isTrue(); assertThat(color.getValue()).isEqualTo(Color.RED); color.setValue(Color.BLUE); assertThat(colorPanel.getSelectedColor()).isEqualTo(Color.BLUE); assertThat(listener.getCount()).isEqualTo(1); color.clear(); assertThat(colorPanel.getSelectedColor()).isNull(); assertThat(listener.getCount()).isEqualTo(2); }