@Override public Void run() throws Exception { removable.remove(); return null; } });
@Override public Void run() { try { find(object, MutableDisplayable).setDisplayName(name); } catch (NotFoundException e) { // FIXME: do nothing or throw runtime exception? } return null; } });
@Override @Nonnull public Finder<Type> findChildren() { return delegate.findChildren().sort(sortController.getSortCriterion(), sortController.getSortDirection()); } }
/*************************************************************************** * * **************************************************************************/ public static String toString (@Nonnull final Object object) { try { if (object instanceof Displayable) { return ((Displayable)object).getDisplayName(); } return ""; } catch (Exception e) { return "NOT INITIALIZED"; } }
@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")); }
/******************************************************************************************************************* * ******************************************************************************************************************/ @Nonnull private String displayNameOf (final @Nonnull Entity entity) { return String.format("%s (%s)", entity.as(Displayable).getDisplayName(), entity.as(Identifiable).getId()); }
/******************************************************************************************************************* * * ******************************************************************************************************************/ @Override public boolean isEnabled() { try { observation.as(Identifiable).getId(); // to probe existence of id return true; } catch (AsException e) { return false; } } }
@Nonnull public static <T, R> R accept (final @Nonnull T object, final @Nonnull Visitor<T, R> visitor) throws NotFoundException { visitor.visit(object); for (final Object child : lookup(object, Composite).findChildren().results()) { accept((T)child, visitor); } return visitor.getValue(); } }
@Override @Nonnull // TODO: refactor with Composite public <Type> Type accept (final @Nonnull Visitor<Layout, Type> visitor) throws NotFoundException { visitor.preVisit(this); visitor.visit(this); for (final DefaultLayout child : children) { child.accept(visitor); } visitor.postVisit(this); return visitor.getValue(); }
private void closeSpringContext() { log.info("Closing Spring context..."); context.close(); context = null; // don't keep in memory useless stuff ContextManager.Locator.set(null); } }
/******************************************************************************************************************* * * ******************************************************************************************************************/ private int computeCount() { if (!countComputed) { log.debug(">>>> computing children count..."); count = delegateComposite.findChildren().count(); countComputed = true; } return count; }
/******************************************************************************************************************* * * Runs a {@link Task} associated with a the samples contexts. * * @param task the task * ******************************************************************************************************************/ public <V, T extends Throwable> V runWithContexts (@Nonnull Task<V, T> task) throws T { return contextManager.runWithContexts(contexts, task); } }
@Override public int compare (final @Nonnull Displayable d1, final @Nonnull Displayable d2) { return collator.compare(d1.getDisplayName(), d2.getDisplayName()); } }
@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")); }
/******************************************************************************************************************* * * Constrains the search to artists who are makers of the given entity. * * @param entity the entity * @return the {@code Finder}, in fluent fashion * ******************************************************************************************************************/ @Nonnull public default MusicArtistFinder makerOf (final @Nonnull Identifiable entity) { return makerOf(entity.getId()); } }
@Nonnull public Builder withDisplayName (final @Nonnull String displayName, final @Nonnull Locale locale) { ((MutableDisplayable)displayable).setDisplayName(displayName, locale); return this; }
@Override @Nonnull public String getDisplayName() { final String originalName = delegate.getDisplayName(); return !originalName.startsWith(".") ? originalName : "<em>" + originalName + "</em>"; } }
@Nonnull public Builder withDisplayName (final @Nonnull String displayName, final @Nonnull Locale locale) { ((MutableDisplayable)displayable).setDisplayName(displayName, locale); return this; }
@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 "???"; } } }