-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andrew Omondi
committed
Feb 14, 2024
1 parent
2291b08
commit b43405f
Showing
10 changed files
with
205 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package serialization | ||
|
||
// UntypedArray defines an untyped collection. | ||
type UntypedArray struct { | ||
UntypedNode | ||
} | ||
|
||
// GetValue returns a collection of UntypedNode. | ||
func (un *UntypedArray) GetValue() []UntypedNodeable { | ||
return un.value.([]UntypedNodeable) | ||
} | ||
|
||
// NewUntypedArray creates a new UntypedArray object. | ||
func NewUntypedArray(collection []UntypedNodeable) *UntypedArray { | ||
m := &UntypedArray{} | ||
m.value = collection | ||
return m | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package serialization | ||
|
||
// UntypedBoolean defines an untyped boolean object. | ||
type UntypedBoolean struct { | ||
UntypedNode | ||
} | ||
|
||
// GetValue returns the bool value. | ||
func (un *UntypedBoolean) GetValue() *bool { | ||
return un.value.(*bool) | ||
} | ||
|
||
// NewUntypedBoolean creates a new UntypedBoolean object. | ||
func NewUntypedBoolean(boolValue *bool) *UntypedBoolean { | ||
m := &UntypedBoolean{} | ||
m.value = boolValue | ||
return m | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package serialization | ||
|
||
// UntypedDouble defines an untyped float64 object. | ||
type UntypedDouble struct { | ||
UntypedNode | ||
} | ||
|
||
// GetValue returns the float64 value. | ||
func (un *UntypedDouble) GetValue() *float64 { | ||
return un.value.(*float64) | ||
} | ||
|
||
// NewUntypedDouble creates a new UntypedDouble object. | ||
func NewUntypedDouble(float64Value *float64) *UntypedDouble { | ||
m := &UntypedDouble{} | ||
m.value = float64Value | ||
return m | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package serialization | ||
|
||
// UntypedFloat defines an untyped float32 value. | ||
type UntypedFloat struct { | ||
UntypedNode | ||
} | ||
|
||
// GetValue returns the float32 value. | ||
func (un *UntypedFloat) GetValue() *float32 { | ||
return un.value.(*float32) | ||
} | ||
|
||
// NewUntypedFloat creates a new UntypedFloat object. | ||
func NewUntypedFloat(float32Value *float32) *UntypedFloat { | ||
m := &UntypedFloat{} | ||
m.value = float32Value | ||
return m | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package serialization | ||
|
||
// UntypedInteger defines an untyped integer value. | ||
type UntypedInteger struct { | ||
UntypedNode | ||
} | ||
|
||
// GetValue returns the int32 value. | ||
func (un *UntypedInteger) GetValue() *int32 { | ||
return un.value.(*int32) | ||
} | ||
|
||
// NewUntypedInteger creates a new UntypedInteger object. | ||
func NewUntypedInteger(int32Value *int32) *UntypedInteger { | ||
m := &UntypedInteger{} | ||
m.value = int32Value | ||
return m | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package serialization | ||
|
||
// UntypedLong defines an untyped int64 value. | ||
type UntypedLong struct { | ||
UntypedNode | ||
} | ||
|
||
// GetValue returns the int64 value. | ||
func (un *UntypedLong) GetValue() *int64 { | ||
return un.value.(*int64) | ||
} | ||
|
||
// NewUntypedLong creates a new UntypedLong object. | ||
func NewUntypedLong(int64Value *int64) *UntypedLong { | ||
m := &UntypedLong{} | ||
m.value = int64Value | ||
return m | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package serialization | ||
|
||
type UntypedNodeable interface { | ||
Parsable | ||
GetIsUntypedNode() bool | ||
} | ||
|
||
// Base model for an untyped object. | ||
type UntypedNode struct { | ||
value any | ||
} | ||
|
||
// GetIsUntypedNode returns true if the node is untyped, false otherwise. | ||
func (m *UntypedNode) GetIsUntypedNode() bool { | ||
return true | ||
} | ||
|
||
// GetValue gets the underlying object value. | ||
func (m *UntypedNode) GetValue() any { | ||
return m.value | ||
} | ||
|
||
// Serialize writes the objects properties to the current writer. | ||
func (m *UntypedNode) Serialize(writer SerializationWriter) error { | ||
// Serialize the entity | ||
return nil | ||
} | ||
|
||
// GetFieldDeserializers returns the deserialization information for this object. | ||
func (m *UntypedNode) GetFieldDeserializers() map[string]func(ParseNode) error { | ||
return make(map[string]func(ParseNode) error) | ||
} | ||
|
||
// NewUntypedNode instantiates a new untyped node and sets the default values. | ||
func NewUntypedNode(value any) *UntypedNode { | ||
m := &UntypedNode{} | ||
m.value = value | ||
return m | ||
} | ||
|
||
// CreateUntypedNodeFromDiscriminatorValue a new untyped node and from a parse node. | ||
func CreateUntypedNodeFromDiscriminatorValue(parseNode ParseNode) (Parsable, error) { | ||
return NewUntypedNode(nil), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package serialization | ||
|
||
// UntypedNull defines a untyped nil object. | ||
type UntypedNull struct { | ||
UntypedNode | ||
} | ||
|
||
// GetValue returns a nil value. | ||
func (un *UntypedNull) GetValue() any { | ||
return nil | ||
} | ||
|
||
// NewUntypedString creates a new UntypedNull object. | ||
func NewUntypedNull() *UntypedNull { | ||
m := &UntypedNull{} | ||
return m | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package serialization | ||
|
||
// UntypedObject defines an untyped object. | ||
type UntypedObject struct { | ||
UntypedNode | ||
} | ||
|
||
// GetValue gets a map of the properties of the object. | ||
func (un *UntypedObject) GetValue() map[string]UntypedNodeable { | ||
return un.value.(map[string]UntypedNodeable) | ||
} | ||
|
||
// NewUntypedObject creates a new UntypedObject object. | ||
func NewUntypedObject(properties map[string]UntypedNodeable) *UntypedObject { | ||
m := &UntypedObject{} | ||
m.value = properties | ||
return m | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package serialization | ||
|
||
// UntypedString defines an untyped string object. | ||
type UntypedString struct { | ||
UntypedNode | ||
} | ||
|
||
// GetValue returns the string object. | ||
func (un *UntypedString) GetValue() *string { | ||
return un.value.(*string) | ||
} | ||
|
||
// NewUntypedString creates a new UntypedString object. | ||
func NewUntypedString(stringValue *string) *UntypedString { | ||
m := &UntypedString{} | ||
m.value = stringValue | ||
return m | ||
} |