public class RegisteredTypes
extends java.lang.Object
RegisteredType
instances.
Use #bean(String, String, TypeImplementationPlan)
and #spec(String, String, TypeImplementationPlan)
to create RegisteredType
instances.
See isSubtypeOf(RegisteredType, Class)
or isSubtypeOf(RegisteredType, RegisteredType)
to
inspect the type hierarchy.
Modifier and Type | Class and Description |
---|---|
static class |
RegisteredTypes.RegisteredTypeNameThenBestFirstComparator
by name, then with disabled, deprecated first, then by increasing version
|
static class |
RegisteredTypes.RegisteredTypeNameThenWorstFirstComparator
by name, then with disabled, deprecated first, then by increasing version
|
Constructor and Description |
---|
RegisteredTypes() |
Modifier and Type | Method and Description |
---|---|
static RegisteredType |
addAlias(RegisteredType type,
java.lang.String alias) |
static RegisteredType |
addAliases(RegisteredType type,
java.lang.Iterable<java.lang.String> aliases) |
static RegisteredType |
addSuperType(RegisteredType type,
java.lang.Class<?> superType) |
static RegisteredType |
addSuperType(RegisteredType type,
RegisteredType superType) |
static RegisteredType |
addSuperTypes(RegisteredType type,
java.lang.Iterable<? extends java.lang.Object> superTypesAsClassOrRegisteredType) |
static RegisteredType |
addTag(RegisteredType type,
java.lang.Object tag) |
static RegisteredType |
addTags(RegisteredType type,
java.lang.Iterable<?> tags) |
static RegisteredType |
anonymousRegisteredType(BrooklynTypeRegistry.RegisteredTypeKind kind,
RegisteredType.TypeImplementationPlan plan)
Creates an anonymous
RegisteredType for plan-instantiation-only use. |
static boolean |
arePlansEquivalent(RegisteredType type1,
RegisteredType type2)
Checks whether two types have plans which are identical, or identical after a YAML parse,
or if either has an "equivalent-plan" tag indicating its equivalence to the other plan
(as set by
#notePlanEquivalentToThis(RegisteredType, TypeImplementationPlan) ). |
static RegisteredType |
bean(java.lang.String symbolicName,
java.lang.String version,
RegisteredType.TypeImplementationPlan plan)
Preferred mechanism for defining a bean
RegisteredType . |
static RegisteredType |
bean(java.lang.String symbolicName,
java.lang.String version,
RegisteredType.TypeImplementationPlan plan,
java.lang.Class<?> superType)
Deprecated.
since 1.0.0 no need for method which adds one explicit supertype; you can do it if you need with
#bean(String, String, TypeImplementationPlan) then addSuperType(RegisteredType, Class)
but the type creation should set supertypes |
static void |
cacheActualJavaType(RegisteredType type,
java.lang.Class<?> clazz) |
static RegisteredType |
changePlan(RegisteredType type,
RegisteredType.TypeImplementationPlan plan)
Deprecated.
since 0.12.0 see
#changePlanNotingEquivalent(RegisteredType, TypeImplementationPlan) |
static RegisteredType |
changePlanNotingEquivalent(RegisteredType type,
RegisteredType.TypeImplementationPlan plan)
Changes the plan set on the given type, returning it,
and also recording that comparisons checking
arePlansEquivalent(RegisteredType, RegisteredType)
should consider the two plans equivalent. |
static RegisteredType |
copy(RegisteredType t) |
static RegisteredType |
copyResolved(BrooklynTypeRegistry.RegisteredTypeKind kind,
RegisteredType t) |
static Maybe<java.util.Map<?,?>> |
getAsYamlMap(java.lang.Object planData)
Returns a wrapped map, if the object is YAML which parses as a map;
otherwise returns absent capable of throwing an error with more details
|
static RegisteredType |
getBestVersion(java.lang.Iterable<RegisteredType> types) |
static java.lang.String |
getIconUrl(BrooklynObject object) |
static java.lang.String |
getImplementationDataStringForSpec(RegisteredType item)
returns the implementation data for a spec if it is a string (e.g.
|
static boolean |
isAnyTypeOrSuper(java.util.Set<java.lang.Object> candidateTypes,
<any> filter)
Queries recursively the given types (either
Class or RegisteredType )
to see whether any superclasses satisfy the given Predicate comparing as string or class |
static boolean |
isAnyTypeOrSuperSatisfying(java.util.Set<java.lang.Object> candidateTypes,
<any> filter)
Deprecated.
since 1.0.0 use
#isAnyTypeOrSuper(Set, Predicate) accepting any object in the predicate,
typically allowing string equivalence although it is valid to restrict to Class comparison
(might be stricter in some OSGi cases) |
static boolean |
isAnyTypeSubtypeOf(java.util.Set<java.lang.Object> candidateTypes,
java.lang.Class<?> superType)
Queries recursively the given types (either
Class or RegisteredType )
to see whether any inherit from the given Class |
static boolean |
isAnyTypeSubtypeOf(java.util.Set<java.lang.Object> candidateTypes,
java.lang.String superType)
Queries recursively the given types (either
Class or RegisteredType )
to see whether any inherit from the given type either in the registry or a java class |
static boolean |
isSubtypeOf(RegisteredType type,
java.lang.Class<?> superType)
Queries recursively the supertypes of
RegisteredType to see whether it
inherits from the given Class |
static boolean |
isSubtypeOf(RegisteredType type,
RegisteredType superType)
Queries recursively the supertypes of
RegisteredType to see whether it
inherits from the given RegisteredType |
static boolean |
isTemplate(RegisteredType type) |
static java.lang.Class<?> |
loadActualJavaType(java.lang.String javaTypeName,
ManagementContext mgmt,
RegisteredType type,
RegisteredTypeLoadingContext context)
returns the
Class object corresponding to the given java type name and registered type,
using the cache on the type in the first instance, falling back to the loader defined the type and context. |
static RegisteredType |
newInstance(BrooklynTypeRegistry.RegisteredTypeKind kind,
java.lang.String symbolicName,
java.lang.String version,
RegisteredType.TypeImplementationPlan plan,
java.lang.Iterable<java.lang.Object> superTypes,
java.lang.Iterable<java.lang.String> aliases,
java.lang.Iterable<java.lang.Object> tags,
java.lang.String containingBundle,
java.lang.Iterable<OsgiBundleWithUrl> libraryBundles,
java.lang.String displayName,
java.lang.String description,
java.lang.String catalogIconUrl,
java.lang.Boolean catalogDeprecated,
java.lang.Boolean catalogDisabled) |
static AbstractBrooklynObjectSpec<?,?> |
newSpecInstance(ManagementContext mgmt,
java.lang.Class<? extends BrooklynObject> targetType)
returns an implementation of the spec class corresponding to the given target type;
for use in
BrooklynTypePlanTransformer.create(RegisteredType, RegisteredTypeLoadingContext)
implementations when dealing with a spec; returns null if none found |
static void |
notePlanEquivalentToThis(RegisteredType type,
RegisteredType.TypeImplementationPlan plan) |
static RegisteredType |
of(CatalogItem<?,?> item)
Deprecated.
since it was introduced in 0.9.0; for backwards compatibility only, may be removed at any point
|
static java.lang.Class<?> |
peekActualJavaType(RegisteredType type) |
static RegisteredType |
setContainingBundle(RegisteredType type,
ManagedBundle bundle) |
static RegisteredType |
setDeprecated(RegisteredType type,
boolean deprecated) |
static RegisteredType |
setDisabled(RegisteredType type,
boolean disabled) |
static RegisteredType |
spec(java.lang.String symbolicName,
java.lang.String version,
RegisteredType.TypeImplementationPlan plan)
Preferred mechanism for defining a spec
RegisteredType . |
static RegisteredType |
spec(java.lang.String symbolicName,
java.lang.String version,
RegisteredType.TypeImplementationPlan plan,
java.lang.Class<?> superType)
Deprecated.
since 1.0.0 no need for method which adds one explicit supertype; you can do it if you need with
#spec(String, String, TypeImplementationPlan) then addSuperType(RegisteredType, Class)
but the type creation should set supertypes |
static CatalogItem<?,?> |
toPartialCatalogItem(RegisteredType t)
Deprecated.
since introduced in 0.12.0; for backwards compatibility only, may be removed at any point.
Returns a partially-populated CatalogItem. Many methods throw
UnsupportedOperationException
but the basic ones work. |
static Maybe<RegisteredType> |
tryValidate(RegisteredType item,
RegisteredTypeLoadingContext constraint)
Validates that the given type matches the context (if supplied);
if not satisfied.
|
static <T> Maybe<T> |
tryValidate(T object,
RegisteredType type,
RegisteredTypeLoadingContext context)
validates that the given object (required) satisfies the constraints implied by the given
type and context object, using
Maybe as the result set absent containing the error(s)
if not satisfied. |
@Deprecated public static RegisteredType of(CatalogItem<?,?> item)
@Deprecated public static CatalogItem<?,?> toPartialCatalogItem(RegisteredType t)
UnsupportedOperationException
but the basic ones work.public static RegisteredType bean(@Nonnull java.lang.String symbolicName, @Nonnull java.lang.String version, @Nonnull RegisteredType.TypeImplementationPlan plan)
RegisteredType
.
Callers should also addSuperTypes(RegisteredType, Iterable)
on the result.@Deprecated public static RegisteredType bean(@Nonnull java.lang.String symbolicName, @Nonnull java.lang.String version, @Nonnull RegisteredType.TypeImplementationPlan plan, @Nonnull java.lang.Class<?> superType)
#bean(String, String, TypeImplementationPlan)
then addSuperType(RegisteredType, Class)
but the type creation should set supertypes#bean(String, String, TypeImplementationPlan)
when there is a single known java signature/super typepublic static RegisteredType spec(@Nonnull java.lang.String symbolicName, @Nonnull java.lang.String version, @Nonnull RegisteredType.TypeImplementationPlan plan)
RegisteredType
.
Callers should also addSuperTypes(RegisteredType, Iterable)
on the result.public static RegisteredType spec(@Nonnull java.lang.String symbolicName, @Nonnull java.lang.String version, @Nonnull RegisteredType.TypeImplementationPlan plan, @Nonnull java.lang.Class<?> superType)
#spec(String, String, TypeImplementationPlan)
then addSuperType(RegisteredType, Class)
but the type creation should set supertypes#spec(String, String, TypeImplementationPlan)
when there is a single known java signature/super typepublic static RegisteredType newInstance(@Nonnull BrooklynTypeRegistry.RegisteredTypeKind kind, @Nonnull java.lang.String symbolicName, @Nonnull java.lang.String version, @Nonnull RegisteredType.TypeImplementationPlan plan, @Nonnull java.lang.Iterable<java.lang.Object> superTypes, java.lang.Iterable<java.lang.String> aliases, java.lang.Iterable<java.lang.Object> tags, java.lang.String containingBundle, java.lang.Iterable<OsgiBundleWithUrl> libraryBundles, java.lang.String displayName, java.lang.String description, java.lang.String catalogIconUrl, java.lang.Boolean catalogDeprecated, java.lang.Boolean catalogDisabled)
public static RegisteredType copy(RegisteredType t)
public static RegisteredType copyResolved(BrooklynTypeRegistry.RegisteredTypeKind kind, RegisteredType t)
public static RegisteredType anonymousRegisteredType(BrooklynTypeRegistry.RegisteredTypeKind kind, RegisteredType.TypeImplementationPlan plan)
RegisteredType
for plan-instantiation-only use.public static java.lang.Class<?> loadActualJavaType(java.lang.String javaTypeName, ManagementContext mgmt, RegisteredType type, RegisteredTypeLoadingContext context)
Class
object corresponding to the given java type name and registered type,
using the cache on the type in the first instance, falling back to the loader defined the type and context.public static java.lang.Class<?> peekActualJavaType(RegisteredType type)
public static void cacheActualJavaType(RegisteredType type, java.lang.Class<?> clazz)
public static RegisteredType setContainingBundle(RegisteredType type, @Nullable ManagedBundle bundle)
public static RegisteredType setDeprecated(RegisteredType type, boolean deprecated)
public static RegisteredType setDisabled(RegisteredType type, boolean disabled)
public static RegisteredType addSuperType(RegisteredType type, @Nullable java.lang.Class<?> superType)
public static RegisteredType addSuperType(RegisteredType type, @Nullable RegisteredType superType)
public static RegisteredType addSuperTypes(RegisteredType type, java.lang.Iterable<? extends java.lang.Object> superTypesAsClassOrRegisteredType)
public static RegisteredType addAlias(RegisteredType type, java.lang.String alias)
public static RegisteredType addAliases(RegisteredType type, java.lang.Iterable<java.lang.String> aliases)
public static RegisteredType addTag(RegisteredType type, java.lang.Object tag)
public static RegisteredType addTags(RegisteredType type, java.lang.Iterable<?> tags)
public static java.lang.String getImplementationDataStringForSpec(RegisteredType item)
public static AbstractBrooklynObjectSpec<?,?> newSpecInstance(ManagementContext mgmt, java.lang.Class<? extends BrooklynObject> targetType) throws java.lang.Exception
BrooklynTypePlanTransformer.create(RegisteredType, RegisteredTypeLoadingContext)
implementations when dealing with a spec; returns null if none foundmgmt
- java.lang.Exception
public static Maybe<java.util.Map<?,?>> getAsYamlMap(java.lang.Object planData)
public static boolean isSubtypeOf(RegisteredType type, RegisteredType superType)
RegisteredType
to see whether it
inherits from the given RegisteredType
public static boolean isSubtypeOf(RegisteredType type, java.lang.Class<?> superType)
RegisteredType
to see whether it
inherits from the given Class
public static boolean isAnyTypeSubtypeOf(java.util.Set<java.lang.Object> candidateTypes, java.lang.Class<?> superType)
Class
or RegisteredType
)
to see whether any inherit from the given Class
public static boolean isAnyTypeSubtypeOf(java.util.Set<java.lang.Object> candidateTypes, java.lang.String superType)
Class
or RegisteredType
)
to see whether any inherit from the given type either in the registry or a java classpublic static boolean isAnyTypeOrSuper(java.util.Set<java.lang.Object> candidateTypes, <any> filter)
Class
or RegisteredType
)
to see whether any superclasses satisfy the given Predicate
comparing as string or class@Deprecated public static boolean isAnyTypeOrSuperSatisfying(java.util.Set<java.lang.Object> candidateTypes, <any> filter)
#isAnyTypeOrSuper(Set, Predicate)
accepting any object in the predicate,
typically allowing string equivalence although it is valid to restrict to Class
comparison
(might be stricter in some OSGi cases)Class
or RegisteredType
)
to see whether any java superclasses satisfy the given Predicate
on the Class
public static Maybe<RegisteredType> tryValidate(RegisteredType item, RegisteredTypeLoadingContext constraint)
Maybe.Absent
if failed with details of the error,
with Maybe.Absent.isNull()
true if the object is null.public static RegisteredType getBestVersion(java.lang.Iterable<RegisteredType> types)
public static <T> Maybe<T> tryValidate(T object, @Nullable RegisteredType type, @Nullable RegisteredTypeLoadingContext context)
Maybe
as the result set absent containing the error(s)
if not satisfied. returns an Maybe.Absent
if failed with details of the error,
with Maybe.Absent.isNull()
true if the object is null.public static java.lang.String getIconUrl(BrooklynObject object)
@Deprecated public static RegisteredType changePlan(RegisteredType type, RegisteredType.TypeImplementationPlan plan)
#changePlanNotingEquivalent(RegisteredType, TypeImplementationPlan)
public static RegisteredType changePlanNotingEquivalent(RegisteredType type, RegisteredType.TypeImplementationPlan plan)
arePlansEquivalent(RegisteredType, RegisteredType)
should consider the two plans equivalent.public static void notePlanEquivalentToThis(RegisteredType type, RegisteredType.TypeImplementationPlan plan)
public static boolean arePlansEquivalent(RegisteredType type1, RegisteredType type2)
#notePlanEquivalentToThis(RegisteredType, TypeImplementationPlan)
).public static boolean isTemplate(RegisteredType type)