You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/09/15 03:33:18 UTC

[GitHub] [dubbo-go-hessian2] Mulavar commented on a change in pull request #278: feat(*): support wrapper classes for Java basic types

Mulavar commented on a change in pull request #278:
URL: https://github.com/apache/dubbo-go-hessian2/pull/278#discussion_r708810090



##########
File path: array.go
##########
@@ -0,0 +1,257 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package hessian
+
+import (
+	"strings"
+)
+
+func init() {
+	SetCollectionSerialize(&IntegerArray{})
+	SetCollectionSerialize(&ByteArray{})
+	SetCollectionSerialize(&ShortArray{})
+	SetCollectionSerialize(&BooleanArray{})
+	SetCollectionSerialize(&LongArray{})
+	SetCollectionSerialize(&FloatArray{})
+	SetCollectionSerialize(&DoubleArray{})
+	SetCollectionSerialize(&CharacterArray{})
+}
+
+// BooleanArray Boolean[]
+type BooleanArray struct {
+	Values []bool
+}
+
+// nolint
+func (ba *BooleanArray) Get() []interface{} {
+	res := make([]interface{}, len(ba.Values))
+	for i, v := range ba.Values {
+		res[i] = v
+	}
+	return res
+}
+
+// nolint
+func (ba *BooleanArray) Set(vs []interface{}) {
+	values := make([]bool, len(vs))
+	for i, v := range vs {
+		values[i] = v.(bool)
+	}
+	ba.Values = values
+}
+
+// nolint
+func (*BooleanArray) JavaClassName() string {
+	return "[java.lang.Boolean"
+}
+
+//IntegerArray Integer[]
+type IntegerArray struct {
+	Values []int32
+}
+
+// nolint
+func (ia *IntegerArray) Get() []interface{} {
+	res := make([]interface{}, len(ia.Values))
+	for i, v := range ia.Values {
+		res[i] = v
+	}
+	return res
+}
+
+// nolint
+func (ia *IntegerArray) Set(vs []interface{}) {
+	values := make([]int32, len(vs))
+	for i, v := range vs {
+		values[i] = v.(int32)
+	}
+	ia.Values = values
+}
+
+// nolint
+func (*IntegerArray) JavaClassName() string {
+	return "[java.lang.Integer"
+}
+
+// ByteArray Byte[]
+type ByteArray struct {
+	IntegerArray

Review comment:
       In the beginning, it was for simplicity, but you are right, and I will alse use []int16 as ShortArray.Values in the next commit.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org