github.com/cayleygraph/cayley@v0.7.7/graph/proto/serializations_helpers.go (about)

     1  package proto
     2  
     3  import (
     4  	"github.com/cayleygraph/quad"
     5  	"github.com/cayleygraph/quad/pquads"
     6  )
     7  
     8  //go:generate protoc --proto_path=$GOPATH/src:. --gogo_out=. serializations.proto
     9  
    10  // GetNativeValue returns the value stored in Node.
    11  func (m *NodeData) GetNativeValue() quad.Value {
    12  	if m == nil {
    13  		return nil
    14  	} else if m.Value == nil {
    15  		if m.Name == "" {
    16  			return nil
    17  		}
    18  		return quad.Raw(m.Name)
    19  	}
    20  	return m.Value.ToNative()
    21  }
    22  
    23  func (m *NodeData) Upgrade() {
    24  	if m.Value == nil {
    25  		m.Value = pquads.MakeValue(quad.Raw(m.Name))
    26  		m.Name = ""
    27  	}
    28  }