Entities { public static <T> Supplier<T> attributeSupplier(Entity entity, AttributeSensor<T> sensor) { return EntityAndAttribute.create(entity, sensor); }  static Task<List<T>> invokeEffectorList(Entity callingEntity, Iterable<? extends Entity> entitiesToCall,
            final Effector<T> effector, final Map<String,?> parameters); static Task<List<T>> invokeEffectorListWithMap(Entity callingEntity, Iterable<? extends Entity> entitiesToCall,
            final Effector<T> effector, final Map<String,?> parameters); @SuppressWarnings("unchecked") static Task<List<T>> invokeEffectorListWithArgs(Entity callingEntity, Iterable<? extends Entity> entitiesToCall,
            final Effector<T> effector, Object ...args); static Task<List<T>> invokeEffectorList(Entity callingEntity, Iterable<? extends Entity> entitiesToCall,
            final Effector<T> effector); static Task<T> invokeEffector(Entity callingEntity, Entity entityToCall,
            final Effector<T> effector, final Map<String,?> parameters); @SuppressWarnings("unchecked") static Task<T> invokeEffectorWithArgs(Entity callingEntity, Entity entityToCall,
            final Effector<T> effector, Object ...args); static Task<T> invokeEffector(Entity callingEntity, Entity entityToCall,
            final Effector<T> effector); static Task<?> invokeEffector(Entity callingEntity, Iterable<? extends Entity> entitiesToCall,
            final Effector<?> effector, final Map<String,?> parameters); static Task<?> invokeEffector(Entity callingEntity, Iterable<? extends Entity> entitiesToCall,
            final Effector<?> effector); @Deprecated static boolean isSecret(String name); static boolean isTrivial(Object v); @Deprecated static void dumpInfo(Iterable<? extends Entity> entities); @Deprecated static void dumpInfo(Entity e); @Deprecated static void dumpInfo(Entity e, Writer out); @Deprecated static void dumpInfo(Entity e, String currentIndentation, String tab); @Deprecated static void dumpInfo(Entity e, Writer out, String currentIndentation, String tab); @Deprecated static void dumpInfo(Location loc); @Deprecated static void dumpInfo(Location loc, Writer out); @Deprecated static void dumpInfo(Location loc, String currentIndentation, String tab); @Deprecated static void dumpInfo(Location loc, Writer out, String currentIndentation, String tab); @Deprecated static void dumpInfo(Task<?> t); @Deprecated static void dumpInfo(Enricher enr); @Deprecated static void dumpInfo(Enricher enr, Writer out); @Deprecated static void dumpInfo(Enricher enr, String currentIndentation, String tab); @Deprecated static void dumpInfo(Enricher enr, Writer out, String currentIndentation, String tab); @Deprecated static void dumpInfo(Feed feed, String currentIndentation, String tab); @Deprecated static void dumpInfo(Feed feed, Writer out, String currentIndentation, String tab); @Deprecated static void dumpInfo(Policy pol); @Deprecated static void dumpInfo(Policy pol, Writer out); @Deprecated static void dumpInfo(Policy pol, String currentIndentation, String tab); @Deprecated static void dumpInfo(Policy pol, Writer out, String currentIndentation, String tab); @Deprecated static List<Sensor<?>> sortSensors(Set<Sensor<?>> sensors); @Deprecated static List<ConfigKey<?>> sortConfigKeys(Set<ConfigKey<?>> configs); @Deprecated static Map<String, T> sortMap(Map<String, T> map); static boolean isAncestor(Entity descendant, Entity potentialAncestor); static boolean isDescendant(Entity ancestor, Entity potentialDescendant); @SuppressWarnings("unused") static Iterable<Entity> descendants(Entity root, Predicate<? super Entity> matching, boolean includeSelf); static Iterable<Entity> descendantsAndSelf(Entity root, Predicate<? super Entity> matching); static Iterable<Entity> descendantsAndSelf(Entity root); static Iterable<Entity> descendantsWithoutSelf(Entity root); static Iterable<T> descendantsAndSelf(Entity root, Class<T> ofType); @SuppressWarnings("unused") static Iterable<Entity> ancestorsAndSelf(final Entity root); static Iterable<Entity> ancestorsWithoutSelf(Entity root); @Deprecated static Iterable<Entity> descendants(Entity root, Predicate<? super Entity> matching); @Deprecated static Iterable<Entity> descendants(Entity root); @Deprecated static Iterable<T> descendants(Entity root, Class<T> ofType); @Deprecated static Iterable<Entity> ancestors(final Entity root); static void invokeStopOnShutdown(Entity entity); static void start(Entity e, Collection<? extends Location> locations); static void destroy(Entity e); static void destroyCatching(Entity entity); static void destroy(Location loc); static void destroyCatching(Location loc); static void destroyAll(final ManagementContext mgmt); static void destroyAllCatching(ManagementContext mgmt); static boolean isManaged(Entity e); static boolean isNoLongerManaged(Entity e); @Beta static Boolean isReadOnly(Entity e); @Beta @VisibleForTesting static AbstractEntity deproxy(Entity e); @Beta @SuppressWarnings("unchecked") static T proxy(T e); @Deprecated static boolean manage(Entity e); @Deprecated @Beta static ManagementContext startManagement(Entity e); @Deprecated static ManagementContext startManagement(Application app, ManagementContext mgmt); @Deprecated static ManagementContext startManagement(Application app, BrooklynProperties props); static ManagementContext newManagementContext(); static ManagementContext newManagementContext(BrooklynProperties props); static ManagementContext newManagementContext(Map<?,?> props); static ManagementContext getManagementContext(Entity entity); static void unmanage(Entity entity); static DownloadResolver newDownloader(EntityDriver driver); static DownloadResolver newDownloader(EntityDriver driver, Map<String,?> properties); static DownloadResolver newDownloader(EntityDriver driver, String addon); static DownloadResolver newDownloader(EntityDriver driver, String addon, Map<String,?> properties); static Supplier<T> attributeSupplier(Entity entity, AttributeSensor<T> sensor); static Supplier<T> attributeSupplier(EntityAndAttribute<T> tuple); static Supplier<T> attributeSupplierWhenReady(EntityAndAttribute<T> tuple); @SuppressWarnings({ "unchecked", "serial" }) static Supplier<T> attributeSupplierWhenReady(final Entity entity, final AttributeSensor<T> sensor); @Deprecated static void manage(Location loc, ManagementContext managementContext); static String getRequiredUrlConfig(Entity entity, ConfigKey<String> urlKey); static String getRequiredUrlConfig(Entity entity, HasConfigKey<String> urlKey); static String checkRequiredUrl(Entity entity, String url); static T submit(final Entity entity, final TaskFactory<T> taskFactory); static T submit(final Entity entity, final T task); static void warnOnIgnoringConfig(Entity entity, ConfigKey<?> key); static void waitFor(Entity entity, Predicate<Entity> condition, Duration timeout); static void waitForServiceUp(final Entity entity, Duration timeout); static void waitForServiceUp(final Entity entity, long duration, TimeUnit units); static void waitForServiceUp(final Entity entity); @Beta static ProcessTaskWrapper<Integer> shell(ManagementContext mgmt, String command); static Entity catalogItemScopeRoot(Entity entity); static Set<Location> getAllInheritedLocations(Entity entity); static final Object UNCHANGED; static final Object REMOVE; }
@Test public void testAttributeSupplier() throws Exception { entity.sensors().set(TestEntity.NAME, "myname"); assertEquals(Entities.attributeSupplier(entity, TestEntity.NAME).get(), "myname"); }