private void initialize() { if (!initialized) { initialized = true; if (lookup(object, TextReadable, null) != null) { actions.add(new OpenTextReadableAction(lookup(object, TextReadable))); } else if (lookup(object, BinaryReadable, null) != null) { actions.add(new OpenBinaryReadableAction(lookup(object, BinaryReadable))); } } } };
@Nonnull public static <T> T lookup (final @Nonnull Object object, final @Nonnull Class<T> clazz) { try { final Field defaultField = clazz.getDeclaredField("DEFAULT"); return lookup(object, clazz, (T)defaultField.get(null)); } catch (NoSuchFieldException e) { throw new IllegalArgumentException("Class " + clazz + " doesn't provide a public static DEFAULT implementation", e); } catch (SecurityException e) { throw new IllegalArgumentException("Class " + clazz + " doesn't provide a public static DEFAULT implementation", e); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Class " + clazz + " doesn't provide a public static DEFAULT implementation", e); } catch (IllegalAccessException e) { throw new IllegalArgumentException("Class " + clazz + " doesn't provide a public static DEFAULT implementation", e); } } //@bluebook-end 2
@Override @Nonnull public Lookup filter (final @Nonnull Lookup lookup) { final Composite<Object, Finder<Object>> delegateComposite = lookup(lookup, Composite); final SortableCompositeDecorator<Object> sortableComposite = new SortableCompositeDecorator<Object>(delegateComposite, sortable); return createLookupWith(createLookupReplacing(lookup, Composite, sortableComposite), sortable); } };
@Nonnegative public int count (final @Nonnull Object object) { int r = 1; for (final Object child : EnhancedLookups.lookup(object, Composite.class, Composite.DEFAULT).findChildren().results()) { r += count(child); } return r; } }
@Nonnegative public int count (final @Nonnull Object object) { int r = 1; for (final Object child : lookup(object, Composite).findChildren().results()) { r += count(child); } return r; } }
@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(); } }