@Override public int compare (final @Nonnull Displayable d1, final @Nonnull Displayable d2) { return collator.compare(d1.getDisplayName(), d2.getDisplayName()); } }
@Override @Nonnull public String getDisplayName() { final String originalName = delegate.getDisplayName(); return !originalName.startsWith(".") ? originalName : "<em>" + originalName + "</em>"; } }
@Nonnull private static String displayNameOf (final @Nonnull As8 object) { return object.asOptional(Displayable).map(d -> d.getDisplayName()).orElse("???"); } }
@Override public int compare (final @Nonnull As object1, final @Nonnull As object2) { return collator.compare(object1.as(Displayable).getDisplayName(), object2.as(Displayable).getDisplayName()); } }
@Nonnull private Collection<MediaFolder> musicFactory (final @Nonnull MediaFolder parent) { // TODO: filter by MIME type return entityBrowsers.stream() .sorted(comparing(browser -> browser.as(Displayable).getDisplayName())) .map(browser -> createMediaFolder(parent, browser)) .collect(toList()); }
/******************************************************************************************************************* * * {@inheritDoc} * ******************************************************************************************************************/ @Override public int compareTo (final @Nonnull GeoCoderEntity geoCoderEntity) { return displayable.getDisplayName().compareTo(geoCoderEntity.as(Displayable).getDisplayName()); }
@Nonnull public String getTaxonomyDisplayName() { return taxonomyPreferences.getTaxonomy().as(Displayable.class).getDisplayName(); }
@Override @Nonnull public Optional<Record> getRecord() { // FIXME: check - parent should be always present - correct? return getParent().map(parent -> new NamedRecord(parent.as(Displayable).getDisplayName())); }
public TiledImageLayer (final @Nonnull TileProviderDescriptor descriptor) { super(new LevelSet(makeParams(descriptor)), descriptor.as(Displayable).getDisplayName()); this.descriptor = descriptor; setSplitScale(1.3); // FIXME: what's this? }
@Test(dataProvider = "keysAndExpectedValues") public void must_create_proper_Displayables (final @Nonnull Key<?> key, final @Nonnull String expectedValue) throws NotFoundException, IOException { // given the properties // when final Displayable displayable = PropertyUtilities.displayableForValue(properties, key); // then assertThat(displayable.getDisplayName(), is(expectedValue)); }
/******************************************************************************************************************* * ******************************************************************************************************************/ @Nonnull private String displayNameOf (final @Nonnull MusicPerformer musicPerformer) { final MusicArtist artist = musicPerformer.getMusicArtist(); final Optional<Entity> role = musicPerformer.getRole(); final String performer = role.get().as(Displayable).getDisplayName().replaceAll("^performer_", "").replace('_', ' '); return String.format("%-20s %s", performer, displayNameOf(artist)); }
/******************************************************************************************************************* * ******************************************************************************************************************/ @Nonnull private String displayNameOf (final @Nonnull Entity entity) { return String.format("%s (%s)", entity.as(Displayable).getDisplayName(), entity.as(Identifiable).getId()); }
@Test public void mustHaveTheDisplayName() { assertThat(hvManager.as(Displayable).getDisplayName(), is("Hierarchic Views")); }
@Test public void mustUseTheProvidedDisplayableEvenWhenTheBoundObjectHasGotExpicitDisplayable() { final Displayable displayable = mock(Displayable.class); final Lookup lookup = Lookups.fixed(displayable); final Lookup.Provider boundObject = mock(Lookup.Provider.class); when(boundObject.getLookup()).thenReturn(lookup); final HItem item = fixture.createChild().boundTo(boundObject).withDisplayName("new name").build(); assertThat(item.as(Displayable), is(not(sameInstance(displayable)))); assertThat(item.as(Displayable).getDisplayName(), is("new name")); }
@Test public void aDefaultItemMustHaveTheCorrectName() { final HItem item = fixture.createChild(). withDisplayName("My Item 1"). build(); assertThat(item, is(notNullValue())); assertThat(item.as(Displayable).getDisplayName(), is("My Item 1")); }
@Test public void aRenamableItemMustHaveTheCorrectName() { final HItem item = fixture.createChild(). withDisplayName("My Item 1"). thatCanBeRenamed(). build(); assertThat(item, is(notNullValue())); assertThat(item.as(Displayable).getDisplayName(), is("My Item 1")); }
@Test public void aRenamableViewMustHaveTheCorrectName() { final HView view = hvManager.createView(). withDisplayName("My View 1"). thatCanBeRenamed(). build(); assertThat(view, is(notNullValue())); assertThat(view.as(Displayable).getDisplayName(), is("My View 1")); }
@Test public void aRenamableItemCanBeRenamed() { final HItem item = fixture.createChild(). withDisplayName("My Item 1"). thatCanBeRenamed(). build(); assertThat(item, is(notNullValue())); item.as(MutableDisplayable.class).setDisplayName("New Item Name"); assertThat(item.as(Displayable).getDisplayName(), is("New Item Name")); }
@Test public void aRenamableViewCanBeRenamed() { final HView view = hvManager.createView(). withDisplayName("My View 1"). thatCanBeRenamed(). build(); assertThat(view, is(notNullValue())); view.as(MutableDisplayable.class).setDisplayName("New View Name"); assertThat(view.as(Displayable).getDisplayName(), is("New View Name")); }
@Test public void testFindOrCreateItemWithExistingItem() { final HItem item1 = fixture.createChild().withDisplayName("a name").build(); final HItem item2 = fixture.findOrCreateChild().withId(item1.getId()). withDisplayName("the name"). build(); assertThat(item2, is(sameInstance(item1))); assertThat(item1.as(Displayable).getDisplayName(), is("a name")); }