BasicBrooklynTypeRegistry implements BrooklynTypeRegistry { @SuppressWarnings("deprecation") @Override public Iterable<RegisteredType> getMatching(Predicate<? super RegisteredType> filter) { Set<RegisteredType> result = MutableSet.of(); Set<String> typeNamesFound = MutableSet.of(); for (RegisteredType rt: getAllWithoutCatalog(filter)) { result.add(rt); typeNamesFound.add(rt.getId()); } for (RegisteredType rt: Iterables.filter( Iterables.transform(mgmt.getCatalog().getCatalogItemsLegacy(), RegisteredTypes.CI_TO_RT), filter)) { if (!typeNamesFound.contains(rt.getId())) { typeNamesFound.add(rt.getId()); result.add(rt); } } return result; } BasicBrooklynTypeRegistry(ManagementContext mgmt); @Override Iterable<RegisteredType> getAll(); @SuppressWarnings("deprecation") @Override Iterable<RegisteredType> getMatching(Predicate<? super RegisteredType> filter); @Override RegisteredType get(String symbolicName, String version); @Override RegisteredType get(String symbolicNameWithOptionalVersion, RegisteredTypeLoadingContext context); @Override Maybe<RegisteredType> getMaybe(String symbolicNameWithOptionalVersion, RegisteredTypeLoadingContext context); @Override RegisteredType get(String symbolicNameWithOptionalVersion); @Override SpecT createSpec(RegisteredType type, @Nullable RegisteredTypeLoadingContext constraint, @Nullable Class<SpecT> specSuperType); @Override SpecT createSpecFromPlan(@Nullable String planFormat, Object planData, @Nullable RegisteredTypeLoadingContext optionalConstraint, @Nullable Class<SpecT> optionalSpecSuperType); @Override T createBean(RegisteredType type, @Nullable RegisteredTypeLoadingContext constraint, @Nullable Class<T> optionalResultSuperType); @Override T createBeanFromPlan(String planFormat, Object planData, @Nullable RegisteredTypeLoadingContext optionalConstraint, @Nullable Class<T> optionalSuperType); @Override T create(RegisteredType type, @Nullable RegisteredTypeLoadingContext constraint, @Nullable Class<T> optionalResultSuperType); @Override T createFromPlan(RegisteredTypeKind kind, @Nullable String planFormat, Object planData, @Nullable RegisteredTypeLoadingContext optionalConstraint, @Nullable Class<T> superTypeHint); @Beta // API is stabilising void addToLocalUnpersistedTypeRegistry(RegisteredType type, boolean canForce); @Beta // API stabilising void delete(VersionedName type); void delete(RegisteredType type); @Beta // API stabilising void delete(String id); void clear(); @Beta void storeCatalogUpgradesInstructions(CatalogUpgrades catalogUpgrades); @Beta CatalogUpgrades getCatalogUpgradesInstructions();  }
@Test public void testGetWithFilter() { add(SAMPLE_TYPE); Assert.assertEquals( Iterables.size(registry().getMatching(Predicates.and( RegisteredTypePredicates.symbolicName(SAMPLE_TYPE.getSymbolicName()), RegisteredTypePredicates.subtypeOf(String.class) ))), 1 ); Assert.assertTrue( Iterables.isEmpty(registry().getMatching(Predicates.and( RegisteredTypePredicates.symbolicName(SAMPLE_TYPE.getSymbolicName()), RegisteredTypePredicates.subtypeOf(Integer.class) ))) ); }