blob: 6512844723c122a8a2ff322c326c099072ff94f9 [file]
/*
* 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 (
"context"
stdErrors "errors"
"fmt"
"github.com/rs/zerolog"
"github.com/apache/plc4x/plc4go/spi/errors"
"github.com/apache/plc4x/plc4go/spi/utils"
)
// Code generated by code-generation. DO NOT EDIT.
// AdsExtendedInfoEntryWstring is the corresponding interface of AdsExtendedInfoEntryWstring
type AdsExtendedInfoEntryWstring interface {
fmt.Stringer
utils.LengthAware
utils.Serializable
utils.Copyable
AdsExtendedInfoEntry
// IsAdsExtendedInfoEntryWstring is a marker method to prevent unintentional type checks (interfaces of same signature)
IsAdsExtendedInfoEntryWstring()
// CreateBuilder creates a AdsExtendedInfoEntryWstringBuilder
CreateAdsExtendedInfoEntryWstringBuilder() AdsExtendedInfoEntryWstringBuilder
}
// _AdsExtendedInfoEntryWstring is the data-structure of this message
type _AdsExtendedInfoEntryWstring struct {
AdsExtendedInfoEntryContract
}
var _ AdsExtendedInfoEntryWstring = (*_AdsExtendedInfoEntryWstring)(nil)
var _ AdsExtendedInfoEntryRequirements = (*_AdsExtendedInfoEntryWstring)(nil)
// NewAdsExtendedInfoEntryWstring factory function for _AdsExtendedInfoEntryWstring
func NewAdsExtendedInfoEntryWstring(name string) *_AdsExtendedInfoEntryWstring {
_result := &_AdsExtendedInfoEntryWstring{
AdsExtendedInfoEntryContract: NewAdsExtendedInfoEntry(name),
}
_result.AdsExtendedInfoEntryContract.(*_AdsExtendedInfoEntry)._SubType = _result
return _result
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
/////////////////////// Builder
///////////////////////
// AdsExtendedInfoEntryWstringBuilder is a builder for AdsExtendedInfoEntryWstring
type AdsExtendedInfoEntryWstringBuilder interface {
utils.Copyable
// WithMandatoryFields adds all mandatory fields (convenience for using multiple builder calls)
WithMandatoryFields() AdsExtendedInfoEntryWstringBuilder
// Done is used to finish work on this child and return (or create one if none) to the parent builder
Done() AdsExtendedInfoEntryBuilder
// Build builds the AdsExtendedInfoEntryWstring or returns an error if something is wrong
Build() (AdsExtendedInfoEntryWstring, error)
// MustBuild does the same as Build but panics on error
MustBuild() AdsExtendedInfoEntryWstring
}
// NewAdsExtendedInfoEntryWstringBuilder() creates a AdsExtendedInfoEntryWstringBuilder
func NewAdsExtendedInfoEntryWstringBuilder() AdsExtendedInfoEntryWstringBuilder {
return &_AdsExtendedInfoEntryWstringBuilder{_AdsExtendedInfoEntryWstring: new(_AdsExtendedInfoEntryWstring)}
}
type _AdsExtendedInfoEntryWstringBuilder struct {
*_AdsExtendedInfoEntryWstring
parentBuilder *_AdsExtendedInfoEntryBuilder
collectedErr []error
}
var _ (AdsExtendedInfoEntryWstringBuilder) = (*_AdsExtendedInfoEntryWstringBuilder)(nil)
func (b *_AdsExtendedInfoEntryWstringBuilder) setParent(contract AdsExtendedInfoEntryContract) {
b.AdsExtendedInfoEntryContract = contract
contract.(*_AdsExtendedInfoEntry)._SubType = b._AdsExtendedInfoEntryWstring
}
func (b *_AdsExtendedInfoEntryWstringBuilder) WithMandatoryFields() AdsExtendedInfoEntryWstringBuilder {
return b
}
func (b *_AdsExtendedInfoEntryWstringBuilder) Build() (AdsExtendedInfoEntryWstring, error) {
if err := stdErrors.Join(b.collectedErr...); err != nil {
return nil, errors.Wrap(err, "error occurred during build")
}
return b._AdsExtendedInfoEntryWstring.deepCopy(), nil
}
func (b *_AdsExtendedInfoEntryWstringBuilder) MustBuild() AdsExtendedInfoEntryWstring {
build, err := b.Build()
if err != nil {
panic(err)
}
return build
}
func (b *_AdsExtendedInfoEntryWstringBuilder) Done() AdsExtendedInfoEntryBuilder {
if b.parentBuilder == nil {
b.parentBuilder = NewAdsExtendedInfoEntryBuilder().(*_AdsExtendedInfoEntryBuilder)
}
return b.parentBuilder
}
func (b *_AdsExtendedInfoEntryWstringBuilder) buildForAdsExtendedInfoEntry() (AdsExtendedInfoEntry, error) {
return b.Build()
}
func (b *_AdsExtendedInfoEntryWstringBuilder) DeepCopy() any {
_copy := b.CreateAdsExtendedInfoEntryWstringBuilder().(*_AdsExtendedInfoEntryWstringBuilder)
if b.collectedErr != nil {
copy(_copy.collectedErr, b.collectedErr)
}
return _copy
}
// CreateAdsExtendedInfoEntryWstringBuilder creates a AdsExtendedInfoEntryWstringBuilder
func (b *_AdsExtendedInfoEntryWstring) CreateAdsExtendedInfoEntryWstringBuilder() AdsExtendedInfoEntryWstringBuilder {
if b == nil {
return NewAdsExtendedInfoEntryWstringBuilder()
}
return &_AdsExtendedInfoEntryWstringBuilder{_AdsExtendedInfoEntryWstring: b.deepCopy()}
}
///////////////////////
///////////////////////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
/////////////////////// Accessors for discriminator values.
///////////////////////
func (m *_AdsExtendedInfoEntryWstring) GetDataType() AdsDatatypeId {
return AdsDatatypeId_ADST_WSTRING
}
///////////////////////
///////////////////////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
func (m *_AdsExtendedInfoEntryWstring) GetParent() AdsExtendedInfoEntryContract {
return m.AdsExtendedInfoEntryContract
}
// Deprecated: use the interface for direct cast
func CastAdsExtendedInfoEntryWstring(structType any) AdsExtendedInfoEntryWstring {
if casted, ok := structType.(AdsExtendedInfoEntryWstring); ok {
return casted
}
if casted, ok := structType.(*AdsExtendedInfoEntryWstring); ok {
return *casted
}
return nil
}
func (m *_AdsExtendedInfoEntryWstring) GetPlx4xTypeName() string {
return "AdsExtendedInfoEntryWstring"
}
func (m *_AdsExtendedInfoEntryWstring) GetLengthInBits(ctx context.Context) uint64 {
lengthInBits := uint64(m.AdsExtendedInfoEntryContract.(*_AdsExtendedInfoEntry).getLengthInBits(ctx))
return lengthInBits
}
func (m *_AdsExtendedInfoEntryWstring) GetLengthInBytes(ctx context.Context) uint64 {
return m.GetLengthInBits(ctx) / 8
}
func (m *_AdsExtendedInfoEntryWstring) parse(ctx context.Context, readBuffer utils.ReadBuffer, parent *_AdsExtendedInfoEntry, dataType AdsDatatypeId) (__adsExtendedInfoEntryWstring AdsExtendedInfoEntryWstring, err error) {
m.AdsExtendedInfoEntryContract = parent
parent._SubType = m
positionAware := readBuffer
_ = positionAware
if pullErr := readBuffer.PullContext("AdsExtendedInfoEntryWstring"); pullErr != nil {
return nil, errors.Wrap(pullErr, "Error pulling for AdsExtendedInfoEntryWstring")
}
currentPos := positionAware.GetPos()
_ = currentPos
if closeErr := readBuffer.CloseContext("AdsExtendedInfoEntryWstring"); closeErr != nil {
return nil, errors.Wrap(closeErr, "Error closing for AdsExtendedInfoEntryWstring")
}
return m, nil
}
func (m *_AdsExtendedInfoEntryWstring) Serialize() ([]byte, error) {
wb := utils.NewWriteBufferByteBased(utils.WithInitialSizeForByteBasedBuffer(int(m.GetLengthInBytes(context.Background()))))
if err := m.SerializeWithWriteBuffer(context.Background(), wb); err != nil {
return nil, err
}
return wb.GetBytes(), nil
}
func (m *_AdsExtendedInfoEntryWstring) SerializeWithWriteBuffer(ctx context.Context, writeBuffer utils.WriteBuffer) error {
positionAware := writeBuffer
_ = positionAware
log := zerolog.Ctx(ctx)
_ = log
ser := func() error {
if pushErr := writeBuffer.PushContext("AdsExtendedInfoEntryWstring"); pushErr != nil {
return errors.Wrap(pushErr, "Error pushing for AdsExtendedInfoEntryWstring")
}
if popErr := writeBuffer.PopContext("AdsExtendedInfoEntryWstring"); popErr != nil {
return errors.Wrap(popErr, "Error popping for AdsExtendedInfoEntryWstring")
}
return nil
}
return m.AdsExtendedInfoEntryContract.(*_AdsExtendedInfoEntry).serializeParent(ctx, writeBuffer, m, ser)
}
func (m *_AdsExtendedInfoEntryWstring) IsAdsExtendedInfoEntryWstring() {}
func (m *_AdsExtendedInfoEntryWstring) DeepCopy() any {
return m.deepCopy()
}
func (m *_AdsExtendedInfoEntryWstring) deepCopy() *_AdsExtendedInfoEntryWstring {
if m == nil {
return nil
}
_AdsExtendedInfoEntryWstringCopy := &_AdsExtendedInfoEntryWstring{
m.AdsExtendedInfoEntryContract.(*_AdsExtendedInfoEntry).deepCopy(),
}
_AdsExtendedInfoEntryWstringCopy.AdsExtendedInfoEntryContract.(*_AdsExtendedInfoEntry)._SubType = m
return _AdsExtendedInfoEntryWstringCopy
}
func (m *_AdsExtendedInfoEntryWstring) String() string {
if m == nil {
return "<nil>"
}
wb := utils.NewWriteBufferBoxBased(
utils.WithWriteBufferBoxBasedMergeSingleBoxes(),
utils.WithWriteBufferBoxBasedOmitEmptyBoxes(),
utils.WithWriteBufferBoxBasedPrintPosLengthFooter(),
)
if err := wb.WriteSerializable(context.Background(), m); err != nil {
return err.Error()
}
return wb.GetBox().String()
}