Class ConfigurableProjectionTransformer<T>
- java.lang.Object
-
- software.amazon.smithy.build.transforms.ConfigurableProjectionTransformer<T>
-
- Type Parameters:
T
- The configuration setting type (e.g., a POJO).
- All Implemented Interfaces:
ProjectionTransformer
- Direct Known Subclasses:
Apply
,ChangeStringEnumsToEnumShapes
,ChangeTypes
,ExcludeMetadata
,ExcludeShapesBySelector
,ExcludeShapesByTag
,ExcludeShapesByTrait
,ExcludeTags
,ExcludeTraits
,ExcludeTraitsByTag
,FilterSuppressions
,FlattenNamespaces
,IncludeMetadata
,IncludeNamespaces
,IncludeServices
,IncludeShapesBySelector
,IncludeShapesByTag
,IncludeTags
,IncludeTraits
,IncludeTraitsByTag
,RemoveTraitDefinitions
,RemoveUnusedShapes
,RenameShapes
public abstract class ConfigurableProjectionTransformer<T> extends java.lang.Object implements ProjectionTransformer
An abstract class used to more easily implement a Smithy build projection transformer that expects configuration input in a specific type,T
.This class will automatically deserialize the given
Node
value in theT
and invoketransformWithConfig(TransformContext, Object)
with the deserialized configuration of typeT
.If your build transformer requires configuration, then you typically should just extend this class.
Note: if you overridegetAdditionalProjectionsFunction()
and do not overridetransform(TransformContext)
, the configuration for your transformer will be deserialized twice during execution.
-
-
Constructor Summary
Constructors Constructor Description ConfigurableProjectionTransformer()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.util.List<java.lang.String>
getAdditionalProjections(TransformContext context)
Allows the composition of projections by returning additional projections to run after the current one.protected java.util.Optional<java.util.function.BiFunction<TransformContext,T,java.util.List<java.lang.String>>>
getAdditionalProjectionsFunction()
abstract java.lang.Class<T>
getConfigType()
Gets the configuration class type.Model
transform(TransformContext context)
Transforms the given model using the providedTransformContext
.protected abstract Model
transformWithConfig(TransformContext context, T config)
Executes the transform using the deserialized configuration object.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface software.amazon.smithy.build.ProjectionTransformer
getName
-
-
-
-
Method Detail
-
getConfigType
public abstract java.lang.Class<T> getConfigType()
Gets the configuration class type.The referenced
configType
class must be a public POJO with a public, zero-arg constructor, getters, and setters. If the POJO has a public staticfromNode
method, it will be invoked and is expected to deserialize the Node. If the POJO has a public staticbuilder
method, it will be invoked, setters will be called on the builder POJO, and finally the result of calling thebuild
method is used as the configuration type. Finally, the deserializer will attempt to create the type and call setters on the instantiated object that correspond to property names (either named "set" + property name, or just property name).- Returns:
- Returns the configuration class (a POJO with setters/getters).
-
transform
public Model transform(TransformContext context)
Description copied from interface:ProjectionTransformer
Transforms the given model using the providedTransformContext
.- Specified by:
transform
in interfaceProjectionTransformer
- Parameters:
context
- Transformation context.- Returns:
- Returns the created transformer.
-
getAdditionalProjections
public java.util.List<java.lang.String> getAdditionalProjections(TransformContext context)
Description copied from interface:ProjectionTransformer
Allows the composition of projections by returning additional projections to run after the current one.- Specified by:
getAdditionalProjections
in interfaceProjectionTransformer
- Parameters:
context
- Transformation context.- Returns:
- a collection of named projections to run.
-
transformWithConfig
protected abstract Model transformWithConfig(TransformContext context, T config)
Executes the transform using the deserialized configuration object.- Parameters:
context
- Transform context.config
- Deserialized configuration object.- Returns:
- Returns the transformed model.
-
getAdditionalProjectionsFunction
protected java.util.Optional<java.util.function.BiFunction<TransformContext,T,java.util.List<java.lang.String>>> getAdditionalProjectionsFunction()
- Returns:
- an Optional of either a BiFunction that returns the additional projections to run after this one, or empty to indicate this projection will never compose other ones.
-
-