You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2023/05/17 12:40:52 UTC
[plc4x] 03/03: fix(plc4go/spi): fix small refactoring woopsie
This is an automated email from the ASF dual-hosted git repository.
sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git
commit da294bae2d7905bcf4723ac155df58ccf2968756
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Wed May 17 14:40:40 2023 +0200
fix(plc4go/spi): fix small refactoring woopsie
---
plc4go/spi/model/DefaultPlcBrowseRequestResult.go | 45 +++++++++
.../DefaultPlcBrowseRequestResult_plc4xgen.go | 101 +++++++++++++++++++++
.../model/DefaultPlcSubscriptionRequestResult.go | 45 +++++++++
...DefaultPlcSubscriptionRequestResult_plc4xgen.go | 101 +++++++++++++++++++++
plc4go/spi/model/render_test.go | 2 +
5 files changed, 294 insertions(+)
diff --git a/plc4go/spi/model/DefaultPlcBrowseRequestResult.go b/plc4go/spi/model/DefaultPlcBrowseRequestResult.go
new file mode 100644
index 0000000000..e1f6a39188
--- /dev/null
+++ b/plc4go/spi/model/DefaultPlcBrowseRequestResult.go
@@ -0,0 +1,45 @@
+/*
+ * 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
+ *
+ * https://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 model
+
+import apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
+
+//go:generate go run ../../tools/plc4xgenerator/gen.go -type=DefaultPlcBrowseRequestResult
+type DefaultPlcBrowseRequestResult struct {
+ Request apiModel.PlcBrowseRequest
+ Response apiModel.PlcBrowseResponse
+ Err error
+}
+
+func NewDefaultPlcBrowseRequestResult(Request apiModel.PlcBrowseRequest, Response apiModel.PlcBrowseResponse, Err error) apiModel.PlcBrowseRequestResult {
+ return &DefaultPlcBrowseRequestResult{Request, Response, Err}
+}
+
+func (d *DefaultPlcBrowseRequestResult) GetRequest() apiModel.PlcBrowseRequest {
+ return d.Request
+}
+
+func (d *DefaultPlcBrowseRequestResult) GetResponse() apiModel.PlcBrowseResponse {
+ return d.Response
+}
+
+func (d *DefaultPlcBrowseRequestResult) GetErr() error {
+ return d.Err
+}
diff --git a/plc4go/spi/model/DefaultPlcBrowseRequestResult_plc4xgen.go b/plc4go/spi/model/DefaultPlcBrowseRequestResult_plc4xgen.go
new file mode 100644
index 0000000000..8f6b1f3154
--- /dev/null
+++ b/plc4go/spi/model/DefaultPlcBrowseRequestResult_plc4xgen.go
@@ -0,0 +1,101 @@
+/*
+ * 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
+ *
+ * https://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.
+ */
+
+// Code generated by "plc4xgenerator -type=DefaultPlcBrowseRequestResult"; DO NOT EDIT.
+
+package model
+
+import (
+ "context"
+ "encoding/binary"
+ "fmt"
+ "github.com/apache/plc4x/plc4go/spi/utils"
+)
+
+var _ = fmt.Printf
+
+func (d *DefaultPlcBrowseRequestResult) Serialize() ([]byte, error) {
+ wb := utils.NewWriteBufferByteBased(utils.WithByteOrderForByteBasedBuffer(binary.BigEndian))
+ if err := d.SerializeWithWriteBuffer(context.Background(), wb); err != nil {
+ return nil, err
+ }
+ return wb.GetBytes(), nil
+}
+
+func (d *DefaultPlcBrowseRequestResult) SerializeWithWriteBuffer(ctx context.Context, writeBuffer utils.WriteBuffer) error {
+ if err := writeBuffer.PushContext("PlcBrowseRequestResult"); err != nil {
+ return err
+ }
+
+ if d.Request != nil {
+ if serializableField, ok := d.Request.(utils.Serializable); ok {
+ if err := writeBuffer.PushContext("request"); err != nil {
+ return err
+ }
+ if err := serializableField.SerializeWithWriteBuffer(ctx, writeBuffer); err != nil {
+ return err
+ }
+ if err := writeBuffer.PopContext("request"); err != nil {
+ return err
+ }
+ } else {
+ stringValue := fmt.Sprintf("%v", d.Request)
+ if err := writeBuffer.WriteString("request", uint32(len(stringValue)*8), "UTF-8", stringValue); err != nil {
+ return err
+ }
+ }
+ }
+
+ if d.Response != nil {
+ if serializableField, ok := d.Response.(utils.Serializable); ok {
+ if err := writeBuffer.PushContext("response"); err != nil {
+ return err
+ }
+ if err := serializableField.SerializeWithWriteBuffer(ctx, writeBuffer); err != nil {
+ return err
+ }
+ if err := writeBuffer.PopContext("response"); err != nil {
+ return err
+ }
+ } else {
+ stringValue := fmt.Sprintf("%v", d.Response)
+ if err := writeBuffer.WriteString("response", uint32(len(stringValue)*8), "UTF-8", stringValue); err != nil {
+ return err
+ }
+ }
+ }
+
+ if d.Err != nil {
+ if err := writeBuffer.WriteString("err", uint32(len(d.Err.Error())*8), "UTF-8", d.Err.Error()); err != nil {
+ return err
+ }
+ }
+ if err := writeBuffer.PopContext("PlcBrowseRequestResult"); err != nil {
+ return err
+ }
+ return nil
+}
+
+func (d *DefaultPlcBrowseRequestResult) String() string {
+ writeBuffer := utils.NewWriteBufferBoxBasedWithOptions(true, true)
+ if err := writeBuffer.WriteSerializable(context.Background(), d); err != nil {
+ return err.Error()
+ }
+ return writeBuffer.GetBox().String()
+}
diff --git a/plc4go/spi/model/DefaultPlcSubscriptionRequestResult.go b/plc4go/spi/model/DefaultPlcSubscriptionRequestResult.go
new file mode 100644
index 0000000000..71a3393e5e
--- /dev/null
+++ b/plc4go/spi/model/DefaultPlcSubscriptionRequestResult.go
@@ -0,0 +1,45 @@
+/*
+ * 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
+ *
+ * https://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 model
+
+import apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
+
+//go:generate go run ../../tools/plc4xgenerator/gen.go -type=DefaultPlcSubscriptionRequestResult
+type DefaultPlcSubscriptionRequestResult struct {
+ Request apiModel.PlcSubscriptionRequest
+ Response apiModel.PlcSubscriptionResponse
+ Err error
+}
+
+func NewDefaultPlcSubscriptionRequestResult(Request apiModel.PlcSubscriptionRequest, Response apiModel.PlcSubscriptionResponse, Err error) apiModel.PlcSubscriptionRequestResult {
+ return &DefaultPlcSubscriptionRequestResult{Request, Response, Err}
+}
+
+func (d *DefaultPlcSubscriptionRequestResult) GetRequest() apiModel.PlcSubscriptionRequest {
+ return d.Request
+}
+
+func (d *DefaultPlcSubscriptionRequestResult) GetResponse() apiModel.PlcSubscriptionResponse {
+ return d.Response
+}
+
+func (d *DefaultPlcSubscriptionRequestResult) GetErr() error {
+ return d.Err
+}
diff --git a/plc4go/spi/model/DefaultPlcSubscriptionRequestResult_plc4xgen.go b/plc4go/spi/model/DefaultPlcSubscriptionRequestResult_plc4xgen.go
new file mode 100644
index 0000000000..dd04d7bb9f
--- /dev/null
+++ b/plc4go/spi/model/DefaultPlcSubscriptionRequestResult_plc4xgen.go
@@ -0,0 +1,101 @@
+/*
+ * 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
+ *
+ * https://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.
+ */
+
+// Code generated by "plc4xgenerator -type=DefaultPlcSubscriptionRequestResult"; DO NOT EDIT.
+
+package model
+
+import (
+ "context"
+ "encoding/binary"
+ "fmt"
+ "github.com/apache/plc4x/plc4go/spi/utils"
+)
+
+var _ = fmt.Printf
+
+func (d *DefaultPlcSubscriptionRequestResult) Serialize() ([]byte, error) {
+ wb := utils.NewWriteBufferByteBased(utils.WithByteOrderForByteBasedBuffer(binary.BigEndian))
+ if err := d.SerializeWithWriteBuffer(context.Background(), wb); err != nil {
+ return nil, err
+ }
+ return wb.GetBytes(), nil
+}
+
+func (d *DefaultPlcSubscriptionRequestResult) SerializeWithWriteBuffer(ctx context.Context, writeBuffer utils.WriteBuffer) error {
+ if err := writeBuffer.PushContext("PlcSubscriptionRequestResult"); err != nil {
+ return err
+ }
+
+ if d.Request != nil {
+ if serializableField, ok := d.Request.(utils.Serializable); ok {
+ if err := writeBuffer.PushContext("request"); err != nil {
+ return err
+ }
+ if err := serializableField.SerializeWithWriteBuffer(ctx, writeBuffer); err != nil {
+ return err
+ }
+ if err := writeBuffer.PopContext("request"); err != nil {
+ return err
+ }
+ } else {
+ stringValue := fmt.Sprintf("%v", d.Request)
+ if err := writeBuffer.WriteString("request", uint32(len(stringValue)*8), "UTF-8", stringValue); err != nil {
+ return err
+ }
+ }
+ }
+
+ if d.Response != nil {
+ if serializableField, ok := d.Response.(utils.Serializable); ok {
+ if err := writeBuffer.PushContext("response"); err != nil {
+ return err
+ }
+ if err := serializableField.SerializeWithWriteBuffer(ctx, writeBuffer); err != nil {
+ return err
+ }
+ if err := writeBuffer.PopContext("response"); err != nil {
+ return err
+ }
+ } else {
+ stringValue := fmt.Sprintf("%v", d.Response)
+ if err := writeBuffer.WriteString("response", uint32(len(stringValue)*8), "UTF-8", stringValue); err != nil {
+ return err
+ }
+ }
+ }
+
+ if d.Err != nil {
+ if err := writeBuffer.WriteString("err", uint32(len(d.Err.Error())*8), "UTF-8", d.Err.Error()); err != nil {
+ return err
+ }
+ }
+ if err := writeBuffer.PopContext("PlcSubscriptionRequestResult"); err != nil {
+ return err
+ }
+ return nil
+}
+
+func (d *DefaultPlcSubscriptionRequestResult) String() string {
+ writeBuffer := utils.NewWriteBufferBoxBasedWithOptions(true, true)
+ if err := writeBuffer.WriteSerializable(context.Background(), d); err != nil {
+ return err.Error()
+ }
+ return writeBuffer.GetBox().String()
+}
diff --git a/plc4go/spi/model/render_test.go b/plc4go/spi/model/render_test.go
index e6987e58f4..1c4e44d1b5 100644
--- a/plc4go/spi/model/render_test.go
+++ b/plc4go/spi/model/render_test.go
@@ -44,6 +44,7 @@ func TestRenderTest(t *testing.T) {
&DefaultPlcBrowseItem{},
&DefaultPlcBrowseRequest{},
&DefaultPlcBrowseRequestBuilder{},
+ &DefaultPlcBrowseRequestResult{},
&DefaultPlcBrowseResponse{},
&DefaultPlcBrowseResponseItem{},
&DefaultPlcConsumerRegistration{},
@@ -55,6 +56,7 @@ func TestRenderTest(t *testing.T) {
&DefaultPlcSubscriptionEventItem{},
&DefaultPlcSubscriptionHandle{},
&DefaultPlcSubscriptionRequest{DefaultPlcTagRequest: NewDefaultPlcTagRequest(nil, nil)},
+ &DefaultPlcSubscriptionRequestResult{},
&DefaultPlcSubscriptionResponse{},
&DefaultPlcSubscriptionResponseItem{},
&DefaultPlcTagRequest{},