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