Documentation ¶
Index ¶
- Constants
- func NameOfPropertyAssignmentFunction(baseName string, parameterType astmodel.TypeName, direction Direction, ...) string
- type ConvertFromDirection
- func (dir *ConvertFromDirection) SelectExpr(fromExpr dst.Expr, _ dst.Expr) dst.Expr
- func (dir *ConvertFromDirection) SelectName(from astmodel.InternalTypeName, _ astmodel.InternalTypeName) astmodel.InternalTypeName
- func (dir *ConvertFromDirection) SelectString(fromString string, _ string) string
- func (dir *ConvertFromDirection) SelectType(fromType astmodel.Type, _ astmodel.Type) astmodel.Type
- func (dir *ConvertFromDirection) WhenFrom(fn func()) Direction
- func (dir *ConvertFromDirection) WhenTo(_ func()) Direction
- type ConvertToDirection
- func (dir *ConvertToDirection) SelectExpr(_ dst.Expr, toExpr dst.Expr) dst.Expr
- func (dir *ConvertToDirection) SelectName(_ astmodel.InternalTypeName, to astmodel.InternalTypeName) astmodel.InternalTypeName
- func (dir *ConvertToDirection) SelectString(_ string, toValue string) string
- func (dir *ConvertToDirection) SelectType(_ astmodel.Type, toType astmodel.Type) astmodel.Type
- func (dir *ConvertToDirection) WhenFrom(_ func()) Direction
- func (dir *ConvertToDirection) WhenTo(fn func()) Direction
- type Direction
- type PropertyBagMemberType
- func (b *PropertyBagMemberType) AsDeclarations(codeGenerationContext *astmodel.CodeGenerationContext, ...) ([]dst.Decl, error)
- func (b *PropertyBagMemberType) AsTypeExpr(codeGenerationContext *astmodel.CodeGenerationContext) (dst.Expr, error)
- func (b *PropertyBagMemberType) AsZero(definitions astmodel.TypeDefinitionSet, ctx *astmodel.CodeGenerationContext) dst.Expr
- func (b *PropertyBagMemberType) Element() astmodel.Type
- func (b *PropertyBagMemberType) Equals(t astmodel.Type, override astmodel.EqualityOverrides) bool
- func (b *PropertyBagMemberType) References() astmodel.TypeNameSet
- func (b *PropertyBagMemberType) RequiredPackageReferences() *astmodel.PackageReferenceSet
- func (b *PropertyBagMemberType) String() string
- func (b *PropertyBagMemberType) Unwrap() astmodel.Type
- func (b *PropertyBagMemberType) WriteDebugDescription(builder *strings.Builder, currentPackage astmodel.InternalPackageReference)
- type PropertyConversion
- type PropertyConversionContext
- func (c *PropertyConversionContext) AddPackageReference(ref astmodel.PackageReference)
- func (c *PropertyConversionContext) FindNextType(name astmodel.InternalTypeName) (astmodel.InternalTypeName, error)
- func (c *PropertyConversionContext) FindPivotType(start astmodel.InternalTypeName, finish astmodel.InternalTypeName) (astmodel.InternalTypeName, bool)
- func (c *PropertyConversionContext) FunctionBaseName() string
- func (c *PropertyConversionContext) HasDirection(dir Direction) bool
- func (c *PropertyConversionContext) IDFactory() astmodel.IdentifierFactory
- func (c *PropertyConversionContext) PathExists(start astmodel.InternalTypeName, finish astmodel.InternalTypeName) bool
- func (c *PropertyConversionContext) PropertyBagName() string
- func (c *PropertyConversionContext) PropertyRename(container astmodel.InternalTypeName, property astmodel.PropertyName) (string, bool)
- func (c *PropertyConversionContext) ResolveType(t astmodel.Type) (astmodel.InternalTypeName, astmodel.Type, bool)
- func (c *PropertyConversionContext) TypeRename(name astmodel.InternalTypeName) (string, bool)
- func (c *PropertyConversionContext) Types() astmodel.TypeDefinitionSet
- func (c *PropertyConversionContext) WithConfiguration(configuration *config.ObjectModelConfiguration) *PropertyConversionContext
- func (c *PropertyConversionContext) WithConversionGraph(conversionGraph *storage.ConversionGraph) *PropertyConversionContext
- func (c *PropertyConversionContext) WithDirection(dir Direction) *PropertyConversionContext
- func (c *PropertyConversionContext) WithPackageReferenceSet(set *astmodel.PackageReferenceSet) *PropertyConversionContext
- func (c *PropertyConversionContext) WithPropertyBag(name string) *PropertyConversionContext
- type PropertyConversionFactory
- type ReadableConversionEndpoint
- func NewReadableConversionEndpointReadingProperty(property *astmodel.PropertyDefinition) *ReadableConversionEndpoint
- func NewReadableConversionEndpointReadingPropertyBagMember(itemName string, itemType astmodel.Type) *ReadableConversionEndpoint
- func NewReadableConversionEndpointReadingValueFunction(fnName string, fnReturnType astmodel.Type) *ReadableConversionEndpoint
- type ReadableConversionEndpointSet
- type TypedConversionEndpoint
- func (endpoint *TypedConversionEndpoint) IsBagItem() bool
- func (endpoint *TypedConversionEndpoint) IsOptional() bool
- func (endpoint *TypedConversionEndpoint) Name() string
- func (endpoint *TypedConversionEndpoint) Path() string
- func (endpoint *TypedConversionEndpoint) Type() astmodel.Type
- func (endpoint *TypedConversionEndpoint) WithPath(namePath []astmodel.PropertyName) *TypedConversionEndpoint
- func (endpoint *TypedConversionEndpoint) WithType(theType astmodel.Type) *TypedConversionEndpoint
- type WritableConversionEndpoint
- type WritableConversionEndpointSet
Constants ¶
const ( AssignPropertiesMethodPrefix = "AssignProperties" InitializationMethodPrefix = "Initialize" )
Variables ¶
This section is empty.
Functions ¶
func NameOfPropertyAssignmentFunction ¶
func NameOfPropertyAssignmentFunction( baseName string, parameterType astmodel.TypeName, direction Direction, idFactory astmodel.IdentifierFactory, ) string
NameOfPropertyAssignmentFunction returns the name of the property assignment function
Types ¶
type ConvertFromDirection ¶
type ConvertFromDirection struct{}
func (*ConvertFromDirection) SelectExpr ¶
SelectExpr returns the expression for conversion FROM
func (*ConvertFromDirection) SelectName ¶
func (dir *ConvertFromDirection) SelectName( from astmodel.InternalTypeName, _ astmodel.InternalTypeName, ) astmodel.InternalTypeName
SelectName returns one of the provided names, depending on the direction of conversion
func (*ConvertFromDirection) SelectString ¶
func (dir *ConvertFromDirection) SelectString(fromString string, _ string) string
SelectString returns the string for conversion FROM
func (*ConvertFromDirection) SelectType ¶
SelectType returns the type for conversion FROM
func (*ConvertFromDirection) WhenFrom ¶
func (dir *ConvertFromDirection) WhenFrom(fn func()) Direction
WhenFrom will run the supplied function, returning this FROM direction for chaining
func (*ConvertFromDirection) WhenTo ¶
func (dir *ConvertFromDirection) WhenTo(_ func()) Direction
WhenTo will skip the supplied function, returning this FROM direction for chaining
type ConvertToDirection ¶
type ConvertToDirection struct{}
func (*ConvertToDirection) SelectExpr ¶
SelectExpr returns the expression for conversion TO
func (*ConvertToDirection) SelectName ¶
func (dir *ConvertToDirection) SelectName( _ astmodel.InternalTypeName, to astmodel.InternalTypeName, ) astmodel.InternalTypeName
SelectName returns one of the provided names, depending on the direction of conversion
func (*ConvertToDirection) SelectString ¶
func (dir *ConvertToDirection) SelectString(_ string, toValue string) string
SelectString returns the string for conversion TO
func (*ConvertToDirection) SelectType ¶
SelectType returns the type for conversion TO
func (*ConvertToDirection) WhenFrom ¶
func (dir *ConvertToDirection) WhenFrom(_ func()) Direction
WhenFrom will skip the supplied function, returning this TO direction for chaining
func (*ConvertToDirection) WhenTo ¶
func (dir *ConvertToDirection) WhenTo(fn func()) Direction
WhenTo will run the supplied function, returning this TO direction for chaining
type Direction ¶
type Direction interface { // SelectString returns one of the provided strings, depending on the direction of conversion SelectString(from string, to string) string // SelectType returns one of the provided types, depending on the direction of conversion SelectType(from astmodel.Type, to astmodel.Type) astmodel.Type // SelectName returns one of the provided names, depending on the direction of conversion SelectName(from astmodel.InternalTypeName, to astmodel.InternalTypeName) astmodel.InternalTypeName // SelectExpr returns on one of the provided expressions, depending on the direction of conversion SelectExpr(from dst.Expr, to dst.Expr) dst.Expr // WhenFrom will run the specified function only if the direction is "From", returning the current direction for chaining WhenFrom(fn func()) Direction // WhenTo will run the specified function only if the direction is "To", returning the current direction for chaining WhenTo(fn func()) Direction }
Direction specifies the direction of conversion we're implementing with this function
var ( // ConvertFrom indicates the conversion is from the passed 'other', populating the receiver with properties from the other ConvertFrom Direction = &ConvertFromDirection{} // ConvertTo indicates the conversion is to the passed 'other', populating the other with properties from the receiver ConvertTo Direction = &ConvertToDirection{} )
type PropertyBagMemberType ¶
type PropertyBagMemberType struct {
// contains filtered or unexported fields
}
PropertyBagMemberType is a wrapper type for properties that are stored-in/recalled-from a PropertyBag Using this custom type allows us to cleanly define endpoints that read-from/write-to the property bag without needing to introduce special cases through the conversions package. Instead, code generation of the conversion steps now naturally falls out of the usual flow - the endpoints contain definitions, and handlers for those definitions pick up the context and generate the required code.
func AsPropertyBagMemberType ¶
func AsPropertyBagMemberType(aType astmodel.Type) (*PropertyBagMemberType, bool)
AsPropertyBagMemberType unwraps any wrappers around the provided type and returns either the underlying PropertyBagMemberType and true, or nil and false.
func NewPropertyBagMemberType ¶
func NewPropertyBagMemberType(element astmodel.Type) *PropertyBagMemberType
NewPropertyBagMemberType returns a new PropertyBagMemberType, ready for use by the conversion framework A bag item can't be optional, so if we're given an optional type we just unwrap it
func (*PropertyBagMemberType) AsDeclarations ¶
func (b *PropertyBagMemberType) AsDeclarations( codeGenerationContext *astmodel.CodeGenerationContext, declContext astmodel.DeclarationContext, ) ([]dst.Decl, error)
AsDeclarations panics because this is a metatype that will never be rendered
func (*PropertyBagMemberType) AsTypeExpr ¶
func (b *PropertyBagMemberType) AsTypeExpr(codeGenerationContext *astmodel.CodeGenerationContext) (dst.Expr, error)
AsType renders as our contained type
func (*PropertyBagMemberType) AsZero ¶
func (b *PropertyBagMemberType) AsZero(definitions astmodel.TypeDefinitionSet, ctx *astmodel.CodeGenerationContext) dst.Expr
AsZero renders an expression for the "zero" value of the type
func (*PropertyBagMemberType) Element ¶
func (b *PropertyBagMemberType) Element() astmodel.Type
Element returns the type contained by the bag item
func (*PropertyBagMemberType) Equals ¶
func (b *PropertyBagMemberType) Equals(t astmodel.Type, override astmodel.EqualityOverrides) bool
Equals returns true if the passed type is a PropertyBagMemberType with the same element this one, false otherwise
func (*PropertyBagMemberType) References ¶
func (b *PropertyBagMemberType) References() astmodel.TypeNameSet
References returns the names of all definitions that the element type we wrap references.
func (*PropertyBagMemberType) RequiredPackageReferences ¶
func (b *PropertyBagMemberType) RequiredPackageReferences() *astmodel.PackageReferenceSet
RequiredPackageReferences returns a set of packages imports required by the element we wrap
func (*PropertyBagMemberType) String ¶
func (b *PropertyBagMemberType) String() string
String returns a string representing the type
func (*PropertyBagMemberType) Unwrap ¶
func (b *PropertyBagMemberType) Unwrap() astmodel.Type
Unwrap returns the type contained within the wrapper type
func (*PropertyBagMemberType) WriteDebugDescription ¶
func (b *PropertyBagMemberType) WriteDebugDescription(builder *strings.Builder, currentPackage astmodel.InternalPackageReference)
WriteDebugDescription adds a description of the current type to the passed builder builder receives the full description, including nested definitions definitions is a dictionary for resolving named definitions
type PropertyConversion ¶
type PropertyConversion func( reader dst.Expr, writer func(dst.Expr) []dst.Stmt, knownLocals *astmodel.KnownLocalsSet, generationContext *astmodel.CodeGenerationContext, ) ([]dst.Stmt, error)
PropertyConversion generates the AST for a given property conversion. reader is an expression to read the original value. writer is a function that accepts an expression for reading a value and creates one or more statements to write that value. Both of these might be complex expressions, possibly involving indexing into arrays or maps.
func CreateTypeConversion ¶
func CreateTypeConversion( sourceEndpoint *TypedConversionEndpoint, destinationEndpoint *TypedConversionEndpoint, conversionContext *PropertyConversionContext, ) (PropertyConversion, error)
CreateTypeConversion tries to create a type conversion between the two provided definitions, using all of the available type conversion functions in priority order to do so.
The method works by considering the conversion requested by sourceEndpoint & destinationEndpoint, with recursive calls breaking the conversion down into multiple steps that are then combined.
Example:
CreateTypeConversion() is called to create a conversion from an optional string to an optional Sku, where Sku is a new type based on string:
source *string => destination *Sku
assuming
type Sku string
assignFromOptional can handle the optionality of sourceEndpoint and makes a recursive call to CreateTypeConversion() with the simpler target:
source string => destination *Sku
assignToOptional can handle the optionality of destinationEndpoint and makes a recursive call to CreateTypeConversion() with a simpler target: source string => destination Sku assignToAliasedPrimitive can handle the type conversion of string to Sku, and makes a recursive call to CreateTypeConversion() with a simpler target: source string => destination string assignPrimitiveFromPrimitive can handle primitive values, and generates a conversion that does a simple assignment: destination = source assignToAliasedPrimitive injects the necessary type conversion: destination = Sku(source) assignToOptional injects a local variable and takes it's address sku := Sku(source) destination = &sku
finally, assignFromOptional injects the check to see if we have a value to assign in the first place, assigning a suitable zero value if we don't:
if source != nil { sku := Sku(source) destination := &sku } else { destination := "" }
type PropertyConversionContext ¶
type PropertyConversionContext struct {
// contains filtered or unexported fields
}
PropertyConversionContext captures additional supporting information that may be needed when a storage conversion factory creates a conversion
func NewPropertyConversionContext ¶
func NewPropertyConversionContext( functionBaseName string, definitions astmodel.TypeDefinitionSet, idFactory astmodel.IdentifierFactory, ) *PropertyConversionContext
NewPropertyConversionContext creates a new instance of a PropertyConversionContext
func (*PropertyConversionContext) AddPackageReference ¶
func (c *PropertyConversionContext) AddPackageReference(ref astmodel.PackageReference)
AddPackageReference adds a new reference that's needed by the given conversion
func (*PropertyConversionContext) FindNextType ¶
func (c *PropertyConversionContext) FindNextType(name astmodel.InternalTypeName) (astmodel.InternalTypeName, error)
FindNextType returns the next type in the storage conversion graph, if any. If no conversion graph is available, returns an empty type name and no error.
func (*PropertyConversionContext) FindPivotType ¶
func (c *PropertyConversionContext) FindPivotType( start astmodel.InternalTypeName, finish astmodel.InternalTypeName, ) (astmodel.InternalTypeName, bool)
FindPivotType returns the type name of the pivot type between the two specified types, if any.
func (*PropertyConversionContext) FunctionBaseName ¶
func (c *PropertyConversionContext) FunctionBaseName() string
FunctionBaseName returns the base name of the function we're generating
func (*PropertyConversionContext) HasDirection ¶
func (c *PropertyConversionContext) HasDirection(dir Direction) bool
HasDirection returns true if this context has the specified direction.
func (*PropertyConversionContext) IDFactory ¶
func (c *PropertyConversionContext) IDFactory() astmodel.IdentifierFactory
IDFactory returns a reference to our identifier factory
func (*PropertyConversionContext) PathExists ¶
func (c *PropertyConversionContext) PathExists( start astmodel.InternalTypeName, finish astmodel.InternalTypeName, ) bool
PathExists returns true if a path exists in the conversion graph starting from the specified type name and ending at the specified type name. If no conversion graph is available, returns false.
func (*PropertyConversionContext) PropertyBagName ¶
func (c *PropertyConversionContext) PropertyBagName() string
PropertyBagName returns the name to use for a local property bag variable
func (*PropertyConversionContext) PropertyRename ¶
func (c *PropertyConversionContext) PropertyRename( container astmodel.InternalTypeName, property astmodel.PropertyName, ) (string, bool)
PropertyRename looks up a property-rename for the specified type, returning the new name and true if found, or empty string and false if not. If no configuration is available, acts as though there is no configuration for this rename, returning "" and false.
func (*PropertyConversionContext) ResolveType ¶
func (c *PropertyConversionContext) ResolveType(t astmodel.Type) (astmodel.InternalTypeName, astmodel.Type, bool)
ResolveType resolves a type that might be a type name into both the name and the actual type it references, returning true iff it was a TypeName that could be resolved
func (*PropertyConversionContext) TypeRename ¶
func (c *PropertyConversionContext) TypeRename(name astmodel.InternalTypeName) (string, bool)
TypeRename looks up a type-rename for the specified type, returning the new name and true if found, or empty string and false if not. If no configuration is available, acts as though there is no configuration for this rename, returning "" and false.
func (*PropertyConversionContext) Types ¶
func (c *PropertyConversionContext) Types() astmodel.TypeDefinitionSet
Types returns the set of definitions available in this context
func (*PropertyConversionContext) WithConfiguration ¶
func (c *PropertyConversionContext) WithConfiguration(configuration *config.ObjectModelConfiguration) *PropertyConversionContext
WithConfiguration returns a new context with the specified configuration included
func (*PropertyConversionContext) WithConversionGraph ¶
func (c *PropertyConversionContext) WithConversionGraph(conversionGraph *storage.ConversionGraph) *PropertyConversionContext
WithConversionGraph returns a new context with the specified conversion graph included
func (*PropertyConversionContext) WithDirection ¶
func (c *PropertyConversionContext) WithDirection(dir Direction) *PropertyConversionContext
WithDirection returns a new context with the specified direction
func (*PropertyConversionContext) WithPackageReferenceSet ¶
func (c *PropertyConversionContext) WithPackageReferenceSet(set *astmodel.PackageReferenceSet) *PropertyConversionContext
WithPackageReferenceSet returns a new context that collects new package references
func (*PropertyConversionContext) WithPropertyBag ¶
func (c *PropertyConversionContext) WithPropertyBag(name string) *PropertyConversionContext
WithPropertyBag returns a new context with the specified property bag name included
type PropertyConversionFactory ¶
type PropertyConversionFactory func( source *TypedConversionEndpoint, destination *TypedConversionEndpoint, conversionContext *PropertyConversionContext) (PropertyConversion, error)
PropertyConversionFactory represents factory methods that can be used to create a PropertyConversion for a specific pair of properties source is the property conversion endpoint that will be read destination is the property conversion endpoint that will be written ctx contains additional information that may be needed when creating the property conversion
The factory should return one of three result sets:
- For a fatal error, one that guarantees no conversion can be generated, return (nil, error) This will abort the conversion process and return an error for logging.
- For a valid conversion, return (conversion, nil)
- When no conversion could be generated by this factory, return (nil, nil) to delegate to another factory
Each conversion should be written with lead predicates to make sure that it only fires in the correct circumstances. This requires, in particular, that most conversions check for optionality and bag items and exit early when those are found. Phrased another way, conversions should not rely on the order of listing in propertyConversionFactories in order to generate the correct code; any conversion that relies on being "protected" from particular situations by having other conversions earlier in the list held by propertyConversionFactories is brittle and likely to generate the incorrect code if the order of items in the list is modified.
type ReadableConversionEndpoint ¶
type ReadableConversionEndpoint struct {
// contains filtered or unexported fields
}
ReadableConversionEndpoint is an endpoint that includes a way to generate an expression for the source value
func NewReadableConversionEndpointReadingProperty ¶
func NewReadableConversionEndpointReadingProperty( property *astmodel.PropertyDefinition, ) *ReadableConversionEndpoint
NewReadableConversionEndpointReadingProperty creates a ReadableConversionEndpoint that reads a value from a specific property
func NewReadableConversionEndpointReadingPropertyBagMember ¶
func NewReadableConversionEndpointReadingPropertyBagMember( itemName string, itemType astmodel.Type, ) *ReadableConversionEndpoint
NewReadableConversionEndpointReadingPropertyBagMember creates a ReadableConversionEndpoint that reads an item from a property bag.
func NewReadableConversionEndpointReadingValueFunction ¶
func NewReadableConversionEndpointReadingValueFunction( fnName string, fnReturnType astmodel.Type, ) *ReadableConversionEndpoint
NewReadableConversionEndpointReadingValueFunction creates a ReadableConversionEndpoint that reads a value from a specific single valued function
func (*ReadableConversionEndpoint) Endpoint ¶
func (r *ReadableConversionEndpoint) Endpoint() *TypedConversionEndpoint
Endpoint provides access to the end point we read
func (*ReadableConversionEndpoint) Name ¶
func (r *ReadableConversionEndpoint) Name() string
Name returns the name of the underlying endpoint
func (*ReadableConversionEndpoint) Read ¶
func (r *ReadableConversionEndpoint) Read(expr dst.Expr) dst.Expr
Read generates an expression to read our endpoint
func (*ReadableConversionEndpoint) String ¶
func (r *ReadableConversionEndpoint) String() string
String returns a human-readable description of the endpoint
type ReadableConversionEndpointSet ¶
type ReadableConversionEndpointSet map[string]*ReadableConversionEndpoint
ReadableConversionEndpointSet is a set of uniquely named readable conversion endpoints
func NewReadableConversionEndpointSet ¶
func NewReadableConversionEndpointSet() ReadableConversionEndpointSet
NewReadableConversionEndpointSet returns a new set of readable conversion endpoints
func (ReadableConversionEndpointSet) CreatePropertyEndpoints ¶
func (set ReadableConversionEndpointSet) CreatePropertyEndpoints(sourceType astmodel.Type) int
CreatePropertyEndpoints will create readable conversion endpoints for any properties found on the passed instance type. Existing endpoints won't be overwritten. Returns the count of new endpoints created
func (ReadableConversionEndpointSet) CreateValueFunctionEndpoints ¶
func (set ReadableConversionEndpointSet) CreateValueFunctionEndpoints(sourceType astmodel.Type) int
CreateValueFunctionEndpoints will create additional readable conversion endpoints for any compatible functions found on the passed instance type that don't collide with the names of existing endpoints. Returns the count of new endpoints created
func (ReadableConversionEndpointSet) Delete ¶
func (set ReadableConversionEndpointSet) Delete(name string)
Delete removes a specific endpoint from the set
type TypedConversionEndpoint ¶
type TypedConversionEndpoint struct {
// contains filtered or unexported fields
}
TypedConversionEndpoint represents either a source or a destination target for a storage conversion In simple cases these will be fields, but can also represent indexed members of slices and maps.
func NewTypedConversionEndpoint ¶
func NewTypedConversionEndpoint(theType astmodel.Type, name string) *TypedConversionEndpoint
func (*TypedConversionEndpoint) IsBagItem ¶
func (endpoint *TypedConversionEndpoint) IsBagItem() bool
IsBagItem returns true if the endpoint contains a property bag item, false otherwise
func (*TypedConversionEndpoint) IsOptional ¶
func (endpoint *TypedConversionEndpoint) IsOptional() bool
IsOptional returns true if the endpoint contains an optional type, false otherwise
func (*TypedConversionEndpoint) Name ¶
func (endpoint *TypedConversionEndpoint) Name() string
Name returns the actual property name of this endpoint
func (*TypedConversionEndpoint) Path ¶
func (endpoint *TypedConversionEndpoint) Path() string
Path returns a dot qualified path for this endpoint (might be empty)
func (*TypedConversionEndpoint) Type ¶
func (endpoint *TypedConversionEndpoint) Type() astmodel.Type
Type returns the type of this endpoint
func (*TypedConversionEndpoint) WithPath ¶
func (endpoint *TypedConversionEndpoint) WithPath( namePath []astmodel.PropertyName, ) *TypedConversionEndpoint
func (*TypedConversionEndpoint) WithType ¶
func (endpoint *TypedConversionEndpoint) WithType(theType astmodel.Type) *TypedConversionEndpoint
WithType creates a new endpoint with a different type
type WritableConversionEndpoint ¶
type WritableConversionEndpoint struct {
// contains filtered or unexported fields
}
WritableConversionEndpoint is an endpoint that includes a way to generate statements to write the final value
func NewWritableConversionEndpointWritingProperty ¶
func NewWritableConversionEndpointWritingProperty( property *astmodel.PropertyDefinition, ) *WritableConversionEndpoint
NewWritableConversionEndpointWritingProperty creates a WritableConversionEndpoint for a specific property
func NewWritableConversionEndpointWritingPropertyBagMember ¶
func NewWritableConversionEndpointWritingPropertyBagMember( itemName string, itemType astmodel.Type, ) *WritableConversionEndpoint
NewWritableConversionEndpointWritingPropertyBagMember creates a WritableConversionEndpoint that writes an item into a property bag
func (*WritableConversionEndpoint) Endpoint ¶
func (w *WritableConversionEndpoint) Endpoint() *TypedConversionEndpoint
Endpoint provides access to the endpoint we write
func (*WritableConversionEndpoint) Name ¶
func (w *WritableConversionEndpoint) Name() string
Name returns the name of the underlying endpoint
func (*WritableConversionEndpoint) String ¶
func (w *WritableConversionEndpoint) String() string
String returns a human-readable description of the endpoint
type WritableConversionEndpointSet ¶
type WritableConversionEndpointSet map[string]*WritableConversionEndpoint
WritableConversionEndpointSet is a set of uniquely named writable conversion endpoints
func NewWritableConversionEndpointSet ¶
func NewWritableConversionEndpointSet() WritableConversionEndpointSet
NewWritableConversionEndpointSet returns a new empty set of writable conversion endpoints
func (WritableConversionEndpointSet) CreatePropertyEndpoints ¶
func (set WritableConversionEndpointSet) CreatePropertyEndpoints(destinationType astmodel.Type) int
CreatePropertyEndpoints will create writable conversion endpoints for any properties found on the passed instance type. Existing endpoints won't be overwritten. Returns the count of new endpoints created
func (WritableConversionEndpointSet) Delete ¶
func (set WritableConversionEndpointSet) Delete(name string)
Delete removes a specific endpoint from the set