Trivial patch for improve readibility of scoreapi/method.go
Define KeyForPositionalParameters constant
Consolidate comments to changed names of methods
@@ -62,6 +62,10 @@ const (
valueTagMask = (1 << valueTagBits) - 1
)
+const (
+ KeyForPositionalParameters = "."
+)
+
func (t TypeTag) String() string {
switch t {
case TInteger:
@@ -246,7 +250,7 @@ func (t DataType) String() string {
return prefix + t.Tag().String()
}
-// DecodeJSO decode json object comes from JSON.
+// ConvertJSONToTypedObj decode json object comes from JSON.
func (t DataType) ConvertJSONToTypedObj(bs []byte, fields []Field, nullable bool) (*codec.TypedObj, error) {
if string(bs) == "null" {
if nullable {
@@ -283,7 +287,7 @@ func (t DataType) ConvertJSONToTypedObj(bs []byte, fields []Field, nullable bool
return t.Tag().ConvertJSONToTypedObj(bs, fields)
}
-// DecodeForJSON convert default bytes and event bytes into JSON value type.
+// ConvertBytesToJSO convert default bytes and event bytes into JSON value type.
func (t DataType) ConvertBytesToJSO(bs []byte) (interface{}, error) {
if bs == nil {
return nil, nil
@@ -317,8 +321,11 @@ func (t DataType) ConvertBytesToJSO(bs []byte) (interface{}, error) {
}
}
-// Decode convert default bytes into native type
+// ConvertBytesToTypedObj convert default bytes into native type
func (t DataType) ConvertBytesToTypedObj(bs []byte) (*codec.TypedObj, error) {
+ if t == Unknown {
+ return nil, errors.InvalidStateError.Errorf("unknown data type")
+ }
if bs == nil {
return codec.Nil, nil
}
@@ -353,7 +360,7 @@ func (t DataType) ConvertBytesToTypedObj(bs []byte) (*codec.TypedObj, error) {
}
}
-// ValidateBytes validate event bytes.
+// ValidateEvent validate event bytes.
func (t DataType) ValidateEvent(bs []byte) error {
if bs == nil {
return nil
@@ -663,7 +670,7 @@ func (a *Method) ToJSON(version module.JSONVersion) (interface{}, error) {
}
func getPositionalInKeywordParams(obj *codec.TypedDict) []*codec.TypedObj {
- p, ok := obj.Map["."]
+ p, ok := obj.Map[KeyForPositionalParameters]
if !ok || p.Type != codec.TypeList {
return nil
}
