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.RegisteredTypeComparator |
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 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)
Convenience for
#bean(String, String, TypeImplementationPlan) when there is a single known java signature/super type |
static void |
cacheActualJavaType(RegisteredType type,
java.lang.Class<?> clazz) |
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 |
getImplementationDataStringForSpec(RegisteredType item)
returns the implementation data for a spec if it is a string (e.g.
|
static boolean |
isAnyTypeOrSuperSatisfying(java.util.Set<java.lang.Object> candidateTypes,
com.google.common.base.Predicate<java.lang.Class<?>> filter)
Queries recursively the given types (either
Class or RegisteredType )
to see whether any java superclasses satisfy the given Predicate |
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 |
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 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 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 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 |
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)
Convenience for
#cpec(String, String, TypeImplementationPlan) when there is a single known java signature/super type |
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)
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.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)
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)
#cpec(String, String, TypeImplementationPlan)
when there is a single known java signature/super type@Beta public static RegisteredType anonymousRegisteredType(BrooklynTypeRegistry.RegisteredTypeKind kind, RegisteredType.TypeImplementationPlan plan)
RegisteredType
for plan-instantiation-only use.@Beta 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.@Beta public static java.lang.Class<?> peekActualJavaType(RegisteredType type)
@Beta public static void cacheActualJavaType(RegisteredType type, java.lang.Class<?> clazz)
@Beta public static RegisteredType addSuperType(RegisteredType type, @Nullable java.lang.Class<?> superType)
@Beta public static RegisteredType addSuperType(RegisteredType type, @Nullable RegisteredType superType)
@Beta public static RegisteredType addSuperTypes(RegisteredType type, java.lang.Iterable<? extends java.lang.Object> superTypesAsClassOrRegisteredType)
@Beta public static RegisteredType addAlias(RegisteredType type, java.lang.String alias)
@Beta public static RegisteredType addAliases(RegisteredType type, java.lang.Iterable<java.lang.String> aliases)
@Beta public static RegisteredType addTag(RegisteredType type, java.lang.Object tag)
@Beta public static RegisteredType addTags(RegisteredType type, java.lang.Iterable<?> tags)
@Beta public static java.lang.String getImplementationDataStringForSpec(RegisteredType item)
@Beta 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 isAnyTypeOrSuperSatisfying(java.util.Set<java.lang.Object> candidateTypes, com.google.common.base.Predicate<java.lang.Class<?>> filter)
Class
or RegisteredType
)
to see whether any java superclasses satisfy the given Predicate
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.