@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>"; } }
/*************************************************************************** * * **************************************************************************/ public static String toString (@Nonnull final Object object) { try { if (object instanceof Displayable) { return ((Displayable)object).getDisplayName(); } return ""; } catch (Exception e) { return "NOT INITIALIZED"; } }
@Override @Nonnull protected List<? extends T> computeResults() { final List<T> result = new ArrayList<T>(); for (final T object : list) { if ((displayName == null) || displayName.equals(object.getDisplayName())) { result.add(object); } } return result; } }
@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()); } }
@Override @Nonnull public String toString() { return descriptor.as(Displayable).getDisplayName(); } }
@Nonnull private static String displayName (final @Nonnull As object) { try { return object.as(Displayable).getDisplayName(); } catch (AsException e) { return "???"; } } }
@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 void init (final @Nonnull Taxonomy.Builder builder) { log.trace("init({}) - @{}", builder, Integer.toHexString(System.identityHashCode(this))); RDFUtils.setDisplayName(entity, builder.getDisplayable().getDisplayName()); }
/******************************************************************************************************************* * * {@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(); }
@Nonnull private View fixedView (final @Nonnegative int position, final @Nonnull View view) { if (view instanceof TextView) { final Object item = getItem(position); Displayable displayable = null; if (item instanceof Displayable) { displayable = (Displayable)item; } else if (item instanceof As) { displayable = ((As)item).as(Displayable); } ((TextView)view).setText((displayable != null) ? displayable.getDisplayName() : "???"); } return view; } }
@Override @Nonnull public Optional<Record> getRecord() { // FIXME: check - parent should be always present - correct? return getParent().map(parent -> new NamedRecord(parent.as(Displayable).getDisplayName())); }
/******************************************************************************************************************* * * {@inheritDoc} * ******************************************************************************************************************/ @Nonnull private String getName (final @Nonnull String fallBackName) { final Node delegate = getOriginal(); // // If the delegate is not a NodePresentationModel, it is not using a Displayable for its icon, thus it is directly // providing its own icon. It could even have an Displayable in its Lookup as it could be a FilterNode; for // this reason there's this explicit check. // if (!(delegate instanceof NodePresentationModel) && !(delegate instanceof GenericFilterNode)) { return fallBackName; } final Displayable displayable = getLookup().lookup(Displayable); return (displayable != null) ? displayable.getDisplayName() : fallBackName; }
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)); }
@Test public void must_return_correct_root_children() throws Exception { // when final List<? extends Entity> children = underTest.findRoot().findChildren().results(); // then assertThat(children.size(), is(4)); assertThat(children.get(0).as(Displayable).getDisplayName(), is("Music")); assertThat(children.get(1).as(Displayable).getDisplayName(), is("Photos")); assertThat(children.get(2).as(Displayable).getDisplayName(), is("Videos")); assertThat(children.get(3).as(Displayable).getDisplayName(), is("Services")); // TODO: mock music and services, assert contents } }
/******************************************************************************************************************* * * Creates an {@code GenericNode} given the referred object, the children and a {@link Lookup}. * * @param object the referring object * @param children the children * @param lookup the {@code Lookup} * ******************************************************************************************************************/ public NodePresentationModel (final @Nonnull Object object, final @Nonnull Children children, final @Nonnull Lookup lookup) { super(children, createLookup(object, lookup)); this.object = object; try { name = find(object, Displayable).getDisplayName(); } catch (NotFoundException e) { name = "???"; // do this first logger.severe("No Displayable available for %s in %s", this, object); } installDisplayNameListener(); installIconChangeListener(); }
public AudioFileResource (final @Nonnull AudioFile audioFile) { this.id = audioFile.getId().stringValue(); this.displayName = audioFile.as(Displayable).getDisplayName(); this.path = audioFile.getPath().toString(); final Metadata metadata = audioFile.getMetadata(); this.fileSize = metadata.get(FILE_SIZE); this.duration = metadata.get(DURATION).map(Duration::toString); final String myUri = resourceUri("audiofile", id); this.content = myUri + "/content"; this.coverArt = metadata.get(ARTWORK).map(x -> myUri + "/coverart"); } }