mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-09 20:47:44 +00:00
Working in generics now to reduce code.
generics are a little funky still. sigh.
This commit is contained in:
@@ -6,8 +6,9 @@ type HasNode interface {
|
||||
GetNode() *yaml.Node
|
||||
}
|
||||
|
||||
type Buildable interface {
|
||||
type Buildable[T any] interface {
|
||||
Build(node *yaml.Node) error
|
||||
*T
|
||||
}
|
||||
|
||||
type NodeReference[T any] struct {
|
||||
@@ -16,6 +17,16 @@ type NodeReference[T any] struct {
|
||||
KeyNode *yaml.Node
|
||||
}
|
||||
|
||||
type KeyReference[T any] struct {
|
||||
Value T
|
||||
KeyNode *yaml.Node
|
||||
}
|
||||
|
||||
type ValueReference[T any] struct {
|
||||
Value T
|
||||
ValueNode *yaml.Node
|
||||
}
|
||||
|
||||
type ObjectReference struct {
|
||||
Value interface{}
|
||||
ValueNode *yaml.Node
|
||||
@@ -25,3 +36,11 @@ type ObjectReference struct {
|
||||
func (n NodeReference[T]) IsEmpty() bool {
|
||||
return n.KeyNode == nil && n.ValueNode == nil
|
||||
}
|
||||
|
||||
func (n NodeReference[T]) IsMapKeyNode() bool {
|
||||
return n.KeyNode != nil && n.ValueNode == nil
|
||||
}
|
||||
|
||||
func (n NodeReference[T]) IsMapValueNode() bool {
|
||||
return n.KeyNode == nil && n.ValueNode != nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user