Documentation
¶
Index ¶
- Variables
- type AdditionalDataHolder
- type DateOnly
- type EnumFactory
- type ISODuration
- func (i ISODuration) GetDays() int
- func (i ISODuration) GetHours() int
- func (i ISODuration) GetMilliSeconds() int
- func (i ISODuration) GetMinutes() int
- func (i ISODuration) GetSeconds() int
- func (i ISODuration) GetWeeks() int
- func (i ISODuration) GetYears() int
- func (i ISODuration) SetDays(days int)
- func (i ISODuration) SetHours(hours int)
- func (i ISODuration) SetMilliSeconds(milliSeconds int)
- func (i ISODuration) SetMinutes(minutes int)
- func (i ISODuration) SetSeconds(seconds int)
- func (i ISODuration) SetWeeks(weeks int)
- func (i ISODuration) SetYears(years int)
- func (i ISODuration) String() string
- func (d ISODuration) ToDuration() (time.Duration, error)
- type Parsable
- type ParsableFactory
- type ParseNode
- type ParseNodeFactory
- type ParseNodeFactoryRegistry
- type SerializationWriter
- type SerializationWriterFactory
- type SerializationWriterFactoryRegistry
- type TimeOnly
Constants ¶
This section is empty.
Variables ¶
var DefaultParseNodeFactoryInstance = &ParseNodeFactoryRegistry{ ContentTypeAssociatedFactories: make(map[string]ParseNodeFactory), }
DefaultParseNodeFactoryInstance is the default singleton instance of the registry to be used when registering new factories that should be available by default.
var DefaultSerializationWriterFactoryInstance = &SerializationWriterFactoryRegistry{ ContentTypeAssociatedFactories: make(map[string]SerializationWriterFactory), }
DefaultSerializationWriterFactoryInstance is the default singleton instance of the registry to be used when registering new factories that should be available by default.
Functions ¶
This section is empty.
Types ¶
type AdditionalDataHolder ¶
type AdditionalDataHolder interface { // GetAdditionalData returns additional data of the object that doesn't belong to a field. GetAdditionalData() map[string]interface{} // SetAdditionalData sets additional data of the object that doesn't belong to a field. SetAdditionalData(value map[string]interface{}) }
AdditionalDataHolder defines a contract for models that can hold additional data besides the described properties.
type DateOnly ¶
type DateOnly struct {
// contains filtered or unexported fields
}
DateOnly is a struct that represents a date only from a date time (Time).
func NewDateOnly ¶
NewDateOnly creates a new DateOnly from a time.Time.
func ParseDateOnly ¶
ParseDateOnly parses a string into a DateOnly following the RFC3339 standard.
type EnumFactory ¶ added in v0.8.0
EnumFactory is a factory for creating Enum.
type ISODuration ¶
type ISODuration struct {
// contains filtered or unexported fields
}
ISODuration represents an ISO 8601 duration
func FromDuration ¶
func FromDuration(d time.Duration) *ISODuration
FromDuration returns an ISODuration from a time.Duration.
func NewDuration ¶
func NewDuration(years int, weeks int, days int, hours int, minutes int, seconds int, milliSeconds int) *ISODuration
NewISODuration creates a new ISODuration from primitive values.
func ParseISODuration ¶
func ParseISODuration(s string) (*ISODuration, error)
ParseISODuration parses a string into an ISODuration following the ISO 8601 standard.
func (ISODuration) GetHours ¶
func (i ISODuration) GetHours() int
GetHours returns the number of hours.
func (ISODuration) GetMilliSeconds ¶
func (i ISODuration) GetMilliSeconds() int
GetMilliSeconds returns the number of milliseconds.
func (ISODuration) GetMinutes ¶
func (i ISODuration) GetMinutes() int
GetMinutes returns the number of minutes.
func (ISODuration) GetSeconds ¶
func (i ISODuration) GetSeconds() int
GetSeconds returns the number of seconds.
func (ISODuration) GetWeeks ¶
func (i ISODuration) GetWeeks() int
GetWeeks returns the number of weeks.
func (ISODuration) GetYears ¶
func (i ISODuration) GetYears() int
GetYears returns the number of years.
func (ISODuration) SetDays ¶
func (i ISODuration) SetDays(days int)
SetDays sets the number of days.
func (ISODuration) SetHours ¶
func (i ISODuration) SetHours(hours int)
SetHours sets the number of hours.
func (ISODuration) SetMilliSeconds ¶
func (i ISODuration) SetMilliSeconds(milliSeconds int)
SetMilliSeconds sets the number of milliseconds.
func (ISODuration) SetMinutes ¶
func (i ISODuration) SetMinutes(minutes int)
SetMinutes sets the number of minutes.
func (ISODuration) SetSeconds ¶
func (i ISODuration) SetSeconds(seconds int)
SetSeconds sets the number of seconds.
func (ISODuration) SetWeeks ¶
func (i ISODuration) SetWeeks(weeks int)
SetWeeks sets the number of weeks.
func (ISODuration) SetYears ¶
func (i ISODuration) SetYears(years int)
SetYears sets the number of years.
func (ISODuration) String ¶
func (i ISODuration) String() string
String returns the ISO 8601 representation of the duration.
func (ISODuration) ToDuration ¶
func (d ISODuration) ToDuration() (time.Duration, error)
ToDuration returns the time.Duration representation of the ISODuration.
type Parsable ¶
type Parsable interface { // Serialize writes the objects properties to the current writer. Serialize(writer SerializationWriter) error // GetFieldDeserializers returns the deserialization information for this object. GetFieldDeserializers() map[string]func(ParseNode) error }
Parsable defines a serializable model object.
type ParsableFactory ¶
ParsableFactory is a factory for creating Parsable.
type ParseNode ¶
type ParseNode interface { // GetChildNode returns a new parse node for the given identifier. GetChildNode(index string) (ParseNode, error) // GetCollectionOfObjectValues returns the collection of Parsable values from the node. GetCollectionOfObjectValues(ctor ParsableFactory) ([]Parsable, error) // GetCollectionOfPrimitiveValues returns the collection of primitive values from the node. GetCollectionOfPrimitiveValues(targetType string) ([]interface{}, error) // GetCollectionOfEnumValues returns the collection of Enum values from the node. GetCollectionOfEnumValues(parser EnumFactory) ([]interface{}, error) // GetObjectValue returns the Parsable value from the node. GetObjectValue(ctor ParsableFactory) (Parsable, error) // GetStringValue returns a String value from the nodes. GetStringValue() (*string, error) // GetBoolValue returns a Bool value from the nodes. GetBoolValue() (*bool, error) // GetInt8Value returns a int8 value from the nodes. GetInt8Value() (*int8, error) // GetByteValue returns a Byte value from the nodes. GetByteValue() (*byte, error) // GetFloat32Value returns a Float32 value from the nodes. GetFloat32Value() (*float32, error) // GetFloat64Value returns a Float64 value from the nodes. GetFloat64Value() (*float64, error) // GetInt32Value returns a Int32 value from the nodes. GetInt32Value() (*int32, error) // GetInt64Value returns a Int64 value from the nodes. GetInt64Value() (*int64, error) // GetTimeValue returns a Time value from the nodes. GetTimeValue() (*time.Time, error) // GetISODurationValue returns a ISODuration value from the nodes. GetISODurationValue() (*ISODuration, error) // GetTimeOnlyValue returns a TimeOnly value from the nodes. GetTimeOnlyValue() (*TimeOnly, error) // GetDateOnlyValue returns a DateOnly value from the nodes. GetDateOnlyValue() (*DateOnly, error) // GetUUIDValue returns a UUID value from the nodes. GetUUIDValue() (*uuid.UUID, error) // GetEnumValue returns a Enum value from the nodes. GetEnumValue(parser EnumFactory) (interface{}, error) // GetByteArrayValue returns a ByteArray value from the nodes. GetByteArrayValue() ([]byte, error) }
ParseNode Interface for a deserialization node in a parse tree. This interace provides an abstraction layer over serialization formats, libraries and implementations.
type ParseNodeFactory ¶
type ParseNodeFactory interface { // GetValidContentType returns the content type this factory's parse nodes can deserialize. GetValidContentType() (string, error) // GetRootParseNode return a new ParseNode instance that is the root of the content GetRootParseNode(contentType string, content []byte) (ParseNode, error) }
ParseNodeFactory defines the contract for a factory that creates new ParseNode.
type ParseNodeFactoryRegistry ¶
type ParseNodeFactoryRegistry struct {
ContentTypeAssociatedFactories map[string]ParseNodeFactory
}
ParseNodeFactoryRegistry holds a list of all the registered factories for the various types of nodes.
func (*ParseNodeFactoryRegistry) GetRootParseNode ¶
func (m *ParseNodeFactoryRegistry) GetRootParseNode(contentType string, content []byte) (ParseNode, error)
GetRootParseNode returns a new ParseNode instance that is the root of the content
func (*ParseNodeFactoryRegistry) GetValidContentType ¶
func (m *ParseNodeFactoryRegistry) GetValidContentType() (string, error)
GetValidContentType returns the valid content type for the ParseNodeFactoryRegistry
type SerializationWriter ¶
type SerializationWriter interface { i.Closer // WriteStringValue writes a String value to underlying the byte array. WriteStringValue(key string, value *string) error // WriteBoolValue writes a Bool value to underlying the byte array. WriteBoolValue(key string, value *bool) error // WriteInt8Value writes a int8 value to underlying the byte array. WriteInt8Value(key string, value *int8) error // WriteByteValue writes a Byte value to underlying the byte array. WriteByteValue(key string, value *byte) error // WriteInt32Value writes a Int32 value to underlying the byte array. WriteInt32Value(key string, value *int32) error // WriteInt64Value writes a Int64 value to underlying the byte array. WriteInt64Value(key string, value *int64) error // WriteFloat32Value writes a Float32 value to underlying the byte array. WriteFloat32Value(key string, value *float32) error // WriteFloat64Value writes a Float64 value to underlying the byte array. WriteFloat64Value(key string, value *float64) error // WriteByteArrayValue writes a ByteArray value to underlying the byte array. WriteByteArrayValue(key string, value []byte) error // WriteTimeValue writes a Time value to underlying the byte array. WriteTimeValue(key string, value *time.Time) error // WriteTimeOnlyValue writes the time part of a Time value to underlying the byte array. WriteTimeOnlyValue(key string, value *TimeOnly) error // WriteDateOnlyValue writes the date part of a Time value to underlying the byte array. WriteDateOnlyValue(key string, value *DateOnly) error // WriteISODurationValue writes a ISODuration value to underlying the byte array. WriteISODurationValue(key string, value *ISODuration) error // WriteUUIDValue writes a UUID value to underlying the byte array. WriteUUIDValue(key string, value *uuid.UUID) error // WriteObjectValue writes a Parsable value to underlying the byte array. WriteObjectValue(key string, item Parsable) error // WriteCollectionOfObjectValues writes a collection of Parsable values to underlying the byte array. WriteCollectionOfObjectValues(key string, collection []Parsable) error // WriteCollectionOfStringValues writes a collection of String values to underlying the byte array. WriteCollectionOfStringValues(key string, collection []string) error // WriteCollectionOfBoolValues writes a collection of Bool values to underlying the byte array. WriteCollectionOfBoolValues(key string, collection []bool) error // WriteCollectionOfInt8Values writes a collection of Int8 values to underlying the byte array. WriteCollectionOfInt8Values(key string, collection []int8) error // WriteCollectionOfByteValues writes a collection of Byte values to underlying the byte array. WriteCollectionOfByteValues(key string, collection []byte) error // WriteCollectionOfInt32Values writes a collection of Int32 values to underlying the byte array. WriteCollectionOfInt32Values(key string, collection []int32) error // WriteCollectionOfInt64Values writes a collection of Int64 values to underlying the byte array. WriteCollectionOfInt64Values(key string, collection []int64) error // WriteCollectionOfFloat32Values writes a collection of Float32 values to underlying the byte array. WriteCollectionOfFloat32Values(key string, collection []float32) error // WriteCollectionOfFloat64Values writes a collection of Float64 values to underlying the byte array. WriteCollectionOfFloat64Values(key string, collection []float64) error // WriteCollectionOfTimeValues writes a collection of Time values to underlying the byte array. WriteCollectionOfTimeValues(key string, collection []time.Time) error // WriteCollectionOfISODurationValues writes a collection of ISODuration values to underlying the byte array. WriteCollectionOfISODurationValues(key string, collection []ISODuration) error // WriteCollectionOfDateOnlyValues writes a collection of DateOnly values to underlying the byte array. WriteCollectionOfDateOnlyValues(key string, collection []DateOnly) error // WriteCollectionOfTimeOnlyValues writes a collection of TimeOnly values to underlying the byte array. WriteCollectionOfTimeOnlyValues(key string, collection []TimeOnly) error // WriteCollectionOfUUIDValues writes a collection of UUID values to underlying the byte array. WriteCollectionOfUUIDValues(key string, collection []uuid.UUID) error // GetSerializedContent returns the resulting byte array from the serialization writer. GetSerializedContent() ([]byte, error) // WriteAdditionalData writes additional data to underlying the byte array. WriteAdditionalData(value map[string]interface{}) error }
SerializationWriter defines an interface for serialization of models to a byte array.
type SerializationWriterFactory ¶
type SerializationWriterFactory interface { // GetValidContentType returns the valid content type for the SerializationWriterFactoryRegistry GetValidContentType() (string, error) // GetSerializationWriter returns the relevant SerializationWriter instance for the given content type GetSerializationWriter(contentType string) (SerializationWriter, error) }
SerializationWriterFactory defines the contract for a factory that creates SerializationWriter instances.
type SerializationWriterFactoryRegistry ¶
type SerializationWriterFactoryRegistry struct { // ContentTypeAssociatedFactories list of factories that are registered by content type. ContentTypeAssociatedFactories map[string]SerializationWriterFactory }
SerializationWriterFactoryRegistry is a factory holds a list of all the registered factories for the various types of nodes.
func (*SerializationWriterFactoryRegistry) GetSerializationWriter ¶
func (m *SerializationWriterFactoryRegistry) GetSerializationWriter(contentType string) (SerializationWriter, error)
GetSerializationWriter returns the relevant SerializationWriter instance for the given content type
func (*SerializationWriterFactoryRegistry) GetValidContentType ¶
func (m *SerializationWriterFactoryRegistry) GetValidContentType() (string, error)
GetValidContentType returns the valid content type for the SerializationWriterFactoryRegistry
type TimeOnly ¶
type TimeOnly struct {
// contains filtered or unexported fields
}
TimeOnly is represents the time part of a date time (time) value.
func NewTimeOnly ¶
NewTimeOnly creates a new TimeOnly from a time.Time.
func ParseTimeOnly ¶
ParseTimeOnly parses a string into a TimeOnly following the RFC3339 standard.