blob: 2ec8cd757e4db241bab685f8fa460c256ac39d96 [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.
// AdsExtendedInfoEntryString is the corresponding interface of AdsExtendedInfoEntryString
type AdsExtendedInfoEntryString interface {
fmt.Stringer
utils.LengthAware
utils.Serializable
utils.Copyable
AdsExtendedInfoEntry
// IsAdsExtendedInfoEntryString is a marker method to prevent unintentional type checks (interfaces of same signature)
IsAdsExtendedInfoEntryString()
// CreateBuilder creates a AdsExtendedInfoEntryStringBuilder
CreateAdsExtendedInfoEntryStringBuilder() AdsExtendedInfoEntryStringBuilder
}
// _AdsExtendedInfoEntryString is the data-structure of this message
type _AdsExtendedInfoEntryString struct {
AdsExtendedInfoEntryContract
}
var _ AdsExtendedInfoEntryString = (*_AdsExtendedInfoEntryString)(nil)
var _ AdsExtendedInfoEntryRequirements = (*_AdsExtendedInfoEntryString)(nil)
// NewAdsExtendedInfoEntryString factory function for _AdsExtendedInfoEntryString
func NewAdsExtendedInfoEntryString(name string) *_AdsExtendedInfoEntryString {
_result := &_AdsExtendedInfoEntryString{
AdsExtendedInfoEntryContract: NewAdsExtendedInfoEntry(name),
}
_result.AdsExtendedInfoEntryContract.(*_AdsExtendedInfoEntry)._SubType = _result
return _result
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
/////////////////////// Builder
///////////////////////
// AdsExtendedInfoEntryStringBuilder is a builder for AdsExtendedInfoEntryString
type AdsExtendedInfoEntryStringBuilder interface {
utils.Copyable
// WithMandatoryFields adds all mandatory fields (convenience for using multiple builder calls)
WithMandatoryFields() AdsExtendedInfoEntryStringBuilder
// 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 AdsExtendedInfoEntryString or returns an error if something is wrong
Build() (AdsExtendedInfoEntryString, error)
// MustBuild does the same as Build but panics on error
MustBuild() AdsExtendedInfoEntryString
}
// NewAdsExtendedInfoEntryStringBuilder() creates a AdsExtendedInfoEntryStringBuilder
func NewAdsExtendedInfoEntryStringBuilder() AdsExtendedInfoEntryStringBuilder {
return &_AdsExtendedInfoEntryStringBuilder{_AdsExtendedInfoEntryString: new(_AdsExtendedInfoEntryString)}
}
type _AdsExtendedInfoEntryStringBuilder struct {
*_AdsExtendedInfoEntryString
parentBuilder *_AdsExtendedInfoEntryBuilder
collectedErr []error
}
var _ (AdsExtendedInfoEntryStringBuilder) = (*_AdsExtendedInfoEntryStringBuilder)(nil)
func (b *_AdsExtendedInfoEntryStringBuilder) setParent(contract AdsExtendedInfoEntryContract) {
b.AdsExtendedInfoEntryContract = contract
contract.(*_AdsExtendedInfoEntry)._SubType = b._AdsExtendedInfoEntryString
}
func (b *_AdsExtendedInfoEntryStringBuilder) WithMandatoryFields() AdsExtendedInfoEntryStringBuilder {
return b
}
func (b *_AdsExtendedInfoEntryStringBuilder) Build() (AdsExtendedInfoEntryString, error) {
if err := stdErrors.Join(b.collectedErr...); err != nil {
return nil, errors.Wrap(err, "error occurred during build")
}
return b._AdsExtendedInfoEntryString.deepCopy(), nil
}
func (b *_AdsExtendedInfoEntryStringBuilder) MustBuild() AdsExtendedInfoEntryString {
build, err := b.Build()
if err != nil {
panic(err)
}
return build
}
func (b *_AdsExtendedInfoEntryStringBuilder) Done() AdsExtendedInfoEntryBuilder {
if b.parentBuilder == nil {
b.parentBuilder = NewAdsExtendedInfoEntryBuilder().(*_AdsExtendedInfoEntryBuilder)
}
return b.parentBuilder
}
func (b *_AdsExtendedInfoEntryStringBuilder) buildForAdsExtendedInfoEntry() (AdsExtendedInfoEntry, error) {
return b.Build()
}
func (b *_AdsExtendedInfoEntryStringBuilder) DeepCopy() any {
_copy := b.CreateAdsExtendedInfoEntryStringBuilder().(*_AdsExtendedInfoEntryStringBuilder)
if b.collectedErr != nil {
copy(_copy.collectedErr, b.collectedErr)
}
return _copy
}
// CreateAdsExtendedInfoEntryStringBuilder creates a AdsExtendedInfoEntryStringBuilder
func (b *_AdsExtendedInfoEntryString) CreateAdsExtendedInfoEntryStringBuilder() AdsExtendedInfoEntryStringBuilder {
if b == nil {
return NewAdsExtendedInfoEntryStringBuilder()
}
return &_AdsExtendedInfoEntryStringBuilder{_AdsExtendedInfoEntryString: b.deepCopy()}
}
///////////////////////
///////////////////////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
/////////////////////// Accessors for discriminator values.
///////////////////////
func (m *_AdsExtendedInfoEntryString) GetDataType() AdsDatatypeId {
return AdsDatatypeId_ADST_STRING
}
///////////////////////
///////////////////////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
func (m *_AdsExtendedInfoEntryString) GetParent() AdsExtendedInfoEntryContract {
return m.AdsExtendedInfoEntryContract
}
// Deprecated: use the interface for direct cast
func CastAdsExtendedInfoEntryString(structType any) AdsExtendedInfoEntryString {
if casted, ok := structType.(AdsExtendedInfoEntryString); ok {
return casted
}
if casted, ok := structType.(*AdsExtendedInfoEntryString); ok {
return *casted
}
return nil
}
func (m *_AdsExtendedInfoEntryString) GetPlx4xTypeName() string {
return "AdsExtendedInfoEntryString"
}
func (m *_AdsExtendedInfoEntryString) GetLengthInBits(ctx context.Context) uint16 {
lengthInBits := uint16(m.AdsExtendedInfoEntryContract.(*_AdsExtendedInfoEntry).getLengthInBits(ctx))
return lengthInBits
}
func (m *_AdsExtendedInfoEntryString) GetLengthInBytes(ctx context.Context) uint16 {
return m.GetLengthInBits(ctx) / 8
}
func (m *_AdsExtendedInfoEntryString) parse(ctx context.Context, readBuffer utils.ReadBuffer, parent *_AdsExtendedInfoEntry, dataType AdsDatatypeId) (__adsExtendedInfoEntryString AdsExtendedInfoEntryString, err error) {
m.AdsExtendedInfoEntryContract = parent
parent._SubType = m
positionAware := readBuffer
_ = positionAware
if pullErr := readBuffer.PullContext("AdsExtendedInfoEntryString"); pullErr != nil {
return nil, errors.Wrap(pullErr, "Error pulling for AdsExtendedInfoEntryString")
}
currentPos := positionAware.GetPos()
_ = currentPos
if closeErr := readBuffer.CloseContext("AdsExtendedInfoEntryString"); closeErr != nil {
return nil, errors.Wrap(closeErr, "Error closing for AdsExtendedInfoEntryString")
}
return m, nil
}
func (m *_AdsExtendedInfoEntryString) 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 *_AdsExtendedInfoEntryString) SerializeWithWriteBuffer(ctx context.Context, writeBuffer utils.WriteBuffer) error {
positionAware := writeBuffer
_ = positionAware
log := zerolog.Ctx(ctx)
_ = log
ser := func() error {
if pushErr := writeBuffer.PushContext("AdsExtendedInfoEntryString"); pushErr != nil {
return errors.Wrap(pushErr, "Error pushing for AdsExtendedInfoEntryString")
}
if popErr := writeBuffer.PopContext("AdsExtendedInfoEntryString"); popErr != nil {
return errors.Wrap(popErr, "Error popping for AdsExtendedInfoEntryString")
}
return nil
}
return m.AdsExtendedInfoEntryContract.(*_AdsExtendedInfoEntry).serializeParent(ctx, writeBuffer, m, ser)
}
func (m *_AdsExtendedInfoEntryString) IsAdsExtendedInfoEntryString() {}
func (m *_AdsExtendedInfoEntryString) DeepCopy() any {
return m.deepCopy()
}
func (m *_AdsExtendedInfoEntryString) deepCopy() *_AdsExtendedInfoEntryString {
if m == nil {
return nil
}
_AdsExtendedInfoEntryStringCopy := &_AdsExtendedInfoEntryString{
m.AdsExtendedInfoEntryContract.(*_AdsExtendedInfoEntry).deepCopy(),
}
_AdsExtendedInfoEntryStringCopy.AdsExtendedInfoEntryContract.(*_AdsExtendedInfoEntry)._SubType = m
return _AdsExtendedInfoEntryStringCopy
}
func (m *_AdsExtendedInfoEntryString) 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()
}