public abstract class AbstractTypePlanTransformer extends java.lang.Object implements BrooklynTypePlanTransformer
BrooklynTypePlanTransformer
instances.
This supplies a default scoreForType(RegisteredType, RegisteredTypeLoadingContext)
method which returns 1 if the format code matches,
and otherwise branches to two methods scoreForNullFormat(Object, RegisteredType, RegisteredTypeLoadingContext)
and scoreForNonmatchingNonnullFormat(String, Object, RegisteredType, RegisteredTypeLoadingContext)
which subclasses can implement. (Often the implementation of the latter is 0.)
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
create(RegisteredType type,
RegisteredTypeLoadingContext context)
delegates to more specific abstract create methods,
and performs common validation and customisation of the items created.
|
java.lang.String |
getFormatCode() |
java.lang.String |
getFormatDescription() |
java.lang.String |
getFormatName() |
double |
scoreForType(RegisteredType type,
RegisteredTypeLoadingContext context)
Determines how appropriate is this transformer for the
RegisteredType.getPlan() of the type. |
void |
setManagementContext(ManagementContext mgmt)
Sets the
ManagementContext reference. |
java.lang.String |
toString() |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
createFromTypeDefinition, scoreForTypeDefinition
public void setManagementContext(ManagementContext mgmt)
ManagementContextInjectable
ManagementContext
reference.setManagementContext
in interface ManagementContextInjectable
public java.lang.String getFormatCode()
getFormatCode
in interface BrooklynTypePlanTransformer
public java.lang.String getFormatName()
getFormatName
in interface BrooklynTypePlanTransformer
public java.lang.String getFormatDescription()
getFormatDescription
in interface BrooklynTypePlanTransformer
public java.lang.String toString()
toString
in class java.lang.Object
public double scoreForType(RegisteredType type, RegisteredTypeLoadingContext context)
BrooklynTypePlanTransformer
RegisteredType.getPlan()
of the type.
The framework guarantees arguments are nonnull, and that the RegisteredType.getPlan()
is also not-null.
However many fields on the RegisteredType
may be null,
including RegisteredType.getId()
for an ad hoc creation
(eg if invoked from BrooklynTypeRegistry.createBeanFromPlan(String, Object, RegisteredTypeLoadingContext, Class)
)scoreForType
in interface BrooklynTypePlanTransformer
Values greater than 0.5 are generally reserved for the presence of marker tags or files which strongly indicate that the format is compatible. Such a value should be returned even if the plan is not actually parseable, but if it looks like a user error which prevents parsing (eg mal-formed YAML) and the transformer could likely be the intended target.
public java.lang.Object create(RegisteredType type, RegisteredTypeLoadingContext context)
this includes:
AbstractBrooklynObjectSpec.catalogItemId(String)
create
in interface BrooklynTypePlanTransformer