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 2024/09/30 15:58:33 UTC

(plc4x) 02/06: refactor(plc4go/spi): make use of options for BoxerWriter

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 f7666a5de4bafdac8acb6bc80c08d30e428d5e89
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Mon Sep 30 12:39:17 2024 +0200

    refactor(plc4go/spi): make use of options for BoxerWriter
---
 plc4go/spi/utils/asciiBox.go      | 171 +++++++++++++++++---------------
 plc4go/spi/utils/asciiBox_test.go | 204 ++++++++++++++------------------------
 plc4go/spi/utils/dumpUtils.go     |  19 ++--
 3 files changed, 177 insertions(+), 217 deletions(-)

diff --git a/plc4go/spi/utils/asciiBox.go b/plc4go/spi/utils/asciiBox.go
index c4aa06f896..9f9010ffa1 100644
--- a/plc4go/spi/utils/asciiBox.go
+++ b/plc4go/spi/utils/asciiBox.go
@@ -36,6 +36,67 @@ type AsciiBox struct {
 	compressedBoxSet string
 }
 
+func WithAsciiBoxName(name string) func(*BoxOptions) {
+	return func(opts *BoxOptions) {
+		opts.Name = name
+	}
+}
+
+func WithAsciiBoxCharWidth(charWidth int) func(*BoxOptions) {
+	return func(opts *BoxOptions) {
+		opts.CharWidth = charWidth
+	}
+}
+
+func WithAsciiBoxOptions(boxOptions BoxOptions) func(*BoxOptions) {
+	return func(opts *BoxOptions) {
+		*opts = boxOptions
+	}
+}
+
+func WithAsciiBoxBoxSet(boxSet BoxSet) func(*BoxOptions) {
+	return func(opts *BoxOptions) {
+		opts.BoxSet = boxSet
+	}
+}
+
+type BoxOptions struct {
+	Name      string
+	CharWidth int
+	BoxSet    BoxSet
+}
+
+type BoxSet struct {
+	UpperLeftCorner  string
+	UpperRightCorner string
+	HorizontalLine   string
+	VerticalLine     string
+	LowerLeftCorner  string
+	LowerRightCorner string
+}
+
+func DefaultBoxSet() BoxSet {
+	return BoxSet{
+		"╔",
+		"╗",
+		"═",
+		"║",
+		"╚",
+		"╝",
+	}
+}
+
+func DefaultLightBoxSet() BoxSet {
+	return BoxSet{
+		"╭",
+		"╮",
+		"┄",
+		"┆",
+		"╰",
+		"╯",
+	}
+}
+
 // DebugAsciiBox set to true to get debug messages
 var DebugAsciiBox bool
 
@@ -50,14 +111,7 @@ type AsciiBoxer interface {
 
 var AsciiBoxWriterDefault = NewAsciiBoxWriter()
 
-var AsciiBoxWriterLight = NewAsciiBoxWriterWithCustomBorders(
-	"╭",
-	"╮",
-	"┄",
-	"┆",
-	"╰",
-	"╯",
-)
+var AsciiBoxWriterLight = NewAsciiBoxWriter(WithAsciiBoxWriterDefaultBoxSet(DefaultLightBoxSet()))
 
 type AsciiBoxWriter interface {
 	BoxBox(box AsciiBox, options ...func(*BoxOptions)) AsciiBox
@@ -67,80 +121,40 @@ type AsciiBoxWriter interface {
 	BoxBelowBox(box1 AsciiBox, box2 AsciiBox, options ...func(*BoxOptions)) AsciiBox
 }
 
-func NewAsciiBoxWriter() AsciiBoxWriter {
-	return NewAsciiBoxWriterWithCustomBorders(
-		"╔",
-		"╗",
-		"═",
-		"║",
-		"╚",
-		"╝",
-	)
-}
-
-func NewAsciiBoxWriterWithCustomBorders(upperLeftCorner string, upperRightCorner string, horizontalLine string, verticalLine string, lowerLeftCorner string, lowerRightCorner string) AsciiBoxWriter {
-	return &asciiBoxWriter{
-		boxSet: boxSet{
-			upperLeftCorner:  upperLeftCorner,
-			upperRightCorner: upperRightCorner,
-			horizontalLine:   horizontalLine,
-			verticalLine:     verticalLine,
-			lowerLeftCorner:  lowerLeftCorner,
-			lowerRightCorner: lowerRightCorner,
-		},
+func NewAsciiBoxWriter(opts ...func(writer *asciiBoxWriter)) AsciiBoxWriter {
+	a := &asciiBoxWriter{
 		newLine:      '\n',
 		emptyPadding: " ",
 		// the name gets prefixed with an extra symbol for indent
 		extraNameCharIndent: 1,
 		borderWidth:         1,
 		newLineCharWidth:    1,
-		boxNameRegex:        regexp.MustCompile(`^` + upperLeftCorner + horizontalLine + `(?P<name>[\w /]+)` + horizontalLine + `*` + upperRightCorner),
-	}
-}
-
-func WithAsciiBoxName(name string) func(*BoxOptions) {
-	return func(opts *BoxOptions) {
-		opts.name = name
+		defaultBoxSet:       DefaultBoxSet(),
 	}
-}
-
-func WithAsciiBoxCharWidth(charWidth int) func(*BoxOptions) {
-	return func(opts *BoxOptions) {
-		opts.charWidth = charWidth
+	for _, opt := range opts {
+		opt(a)
 	}
+	a.boxNameRegex = regexp.MustCompile(`^` + a.defaultBoxSet.UpperLeftCorner + a.defaultBoxSet.HorizontalLine + `(?P<name>[\w /]+)` + a.defaultBoxSet.HorizontalLine + `*` + a.defaultBoxSet.UpperRightCorner)
+	return a
 }
 
-func WithAsciiBoxOptions(boxOptions BoxOptions) func(*BoxOptions) {
-	return func(opts *BoxOptions) {
-		*opts = boxOptions
+func WithAsciiBoxWriterDefaultBoxSet(boxSet BoxSet) func(*asciiBoxWriter) {
+	return func(a *asciiBoxWriter) {
+		a.defaultBoxSet = boxSet
 	}
 }
 
-type BoxOptions struct {
-	name      string
-	charWidth int
-}
-
 ///////////////////////////////////////
 ///////////////////////////////////////
 //
 // Internal section
 //
 
-type boxSet struct {
-	upperLeftCorner  string
-	upperRightCorner string
-	horizontalLine   string
-	verticalLine     string
-	lowerLeftCorner  string
-	lowerRightCorner string
-}
-
-func (b boxSet) compressBoxSet() string {
-	return b.upperLeftCorner + b.upperRightCorner + b.horizontalLine + b.verticalLine + b.lowerLeftCorner + b.lowerRightCorner
+func (b BoxSet) compressBoxSet() string {
+	return b.UpperLeftCorner + b.UpperRightCorner + b.HorizontalLine + b.VerticalLine + b.LowerLeftCorner + b.LowerRightCorner
 }
 
-func (b boxSet) contributeToCompressedBoxSet(box AsciiBox) string {
+func (b BoxSet) contributeToCompressedBoxSet(box AsciiBox) string {
 	actualSet := b.compressBoxSet()
 	if box.compressedBoxSet == "" {
 		// they have nothing to contribute
@@ -173,13 +187,13 @@ func combineCompressedBoxSets(box1, box2 AsciiBox) string {
 }
 
 type asciiBoxWriter struct {
-	boxSet
 	newLine      rune
 	emptyPadding string
 	// the name gets prefixed with an extra symbol for indent
 	extraNameCharIndent int
 	borderWidth         int
 	newLineCharWidth    int
+	defaultBoxSet       BoxSet
 	boxNameRegex        *regexp.Regexp
 }
 
@@ -187,15 +201,16 @@ var _ AsciiBoxWriter = (*asciiBoxWriter)(nil)
 
 func (a *asciiBoxWriter) boxString(data string, options ...func(*BoxOptions)) AsciiBox {
 	var opts BoxOptions
+	opts.BoxSet = a.defaultBoxSet
 	for _, opt := range options {
 		opt(&opts)
 	}
-	name := opts.name
-	charWidth := opts.charWidth
+	name := opts.Name
+	charWidth := opts.CharWidth
 
 	data = strings.ReplaceAll(data, "\r\n", "\n") // carriage return just messes with boxes
 	data = strings.ReplaceAll(data, "\t", "  ")   // Tabs just don't work well as they distort the boxes so we convert them to a double space
-	rawBox := AsciiBox{data, a, a.compressBoxSet()}
+	rawBox := AsciiBox{data, a, opts.BoxSet.compressBoxSet()}
 	longestLine := rawBox.Width()
 	if charWidth < longestLine {
 		if DebugAsciiBox {
@@ -206,7 +221,7 @@ func (a *asciiBoxWriter) boxString(data string, options ...func(*BoxOptions)) As
 	var boxedString strings.Builder
 	boxedString.Grow((a.borderWidth + longestLine + a.borderWidth + a.newLineCharWidth) * rawBox.Height())
 	namePadding := int(math.Max(float64(charWidth-countChars(name)-a.borderWidth-a.extraNameCharIndent-a.borderWidth), 0))
-	boxedString.WriteString(a.upperLeftCorner + a.horizontalLine + name + strings.Repeat(a.horizontalLine, namePadding) + a.upperRightCorner)
+	boxedString.WriteString(opts.BoxSet.UpperLeftCorner + opts.BoxSet.HorizontalLine + name + strings.Repeat(opts.BoxSet.HorizontalLine, namePadding) + opts.BoxSet.UpperRightCorner)
 	boxedString.WriteRune(a.newLine)
 	// Name of the header stretches the box so we align to that
 	charWidth = a.borderWidth + a.extraNameCharIndent + countChars(name) + namePadding + a.borderWidth
@@ -218,12 +233,12 @@ func (a *asciiBoxWriter) boxString(data string, options ...func(*BoxOptions)) As
 		// TODO: this distorts boxes...
 		frontPadding := math.Floor(linePadding / 2.0)
 		backPadding := math.Ceil(linePadding / 2.0)
-		boxedString.WriteString(a.verticalLine + strings.Repeat(a.emptyPadding, int(frontPadding)) + line + strings.Repeat(a.emptyPadding, int(backPadding)) + a.verticalLine)
+		boxedString.WriteString(opts.BoxSet.VerticalLine + strings.Repeat(a.emptyPadding, int(frontPadding)) + line + strings.Repeat(a.emptyPadding, int(backPadding)) + opts.BoxSet.VerticalLine)
 		boxedString.WriteRune(a.newLine)
 	}
 	bottomPadding := namePadding + countChars(name) + a.extraNameCharIndent
-	boxedString.WriteString(a.lowerLeftCorner + strings.Repeat(a.horizontalLine, bottomPadding) + a.lowerRightCorner)
-	return AsciiBox{boxedString.String(), a, a.compressBoxSet()}
+	boxedString.WriteString(opts.BoxSet.LowerLeftCorner + strings.Repeat(opts.BoxSet.HorizontalLine, bottomPadding) + opts.BoxSet.LowerRightCorner)
+	return AsciiBox{boxedString.String(), a, opts.BoxSet.compressBoxSet()}
 }
 
 func (a *asciiBoxWriter) getBoxName(box AsciiBox) string {
@@ -241,17 +256,17 @@ func (a *asciiBoxWriter) changeBoxName(box AsciiBox, newName string) AsciiBox {
 	if !a.hasBorders(box) {
 		return a.boxString(box.String(), WithAsciiBoxName(newName))
 	}
-	minimumWidthWithNewName := countChars(a.upperLeftCorner + a.horizontalLine + newName + a.upperRightCorner)
+	minimumWidthWithNewName := countChars(a.defaultBoxSet.UpperLeftCorner + a.defaultBoxSet.HorizontalLine + newName + a.defaultBoxSet.UpperRightCorner)
 	nameLengthDifference := minimumWidthWithNewName - (a.unwrap(box).Width() + a.borderWidth + a.borderWidth)
 	newBox := a.BoxString(a.unwrap(box).String(), WithAsciiBoxName(newName), WithAsciiBoxCharWidth(box.Width()+nameLengthDifference))
-	newBox.compressedBoxSet = a.contributeToCompressedBoxSet(box)
+	newBox.compressedBoxSet = a.defaultBoxSet.contributeToCompressedBoxSet(box)
 	return newBox
 }
 
 func (a *asciiBoxWriter) mergeHorizontal(boxes []AsciiBox) AsciiBox {
 	switch len(boxes) {
 	case 0:
-		return AsciiBox{"", a, a.compressBoxSet()}
+		return AsciiBox{"", a, a.defaultBoxSet.compressBoxSet()}
 	case 1:
 		return boxes[0]
 	case 2:
@@ -278,7 +293,7 @@ func (a *asciiBoxWriter) expandBox(box AsciiBox, desiredWidth int) AsciiBox {
 			newBox.WriteRune(a.newLine)
 		}
 	}
-	return AsciiBox{newBox.String(), a, a.contributeToCompressedBoxSet(box)}
+	return AsciiBox{newBox.String(), a, a.defaultBoxSet.contributeToCompressedBoxSet(box)}
 }
 
 func (a *asciiBoxWriter) unwrap(box AsciiBox) AsciiBox {
@@ -287,7 +302,7 @@ func (a *asciiBoxWriter) unwrap(box AsciiBox) AsciiBox {
 	}
 	originalLines := box.Lines()
 	newLines := make([]string, len(originalLines)-2)
-	completeBoxSet := a.contributeToCompressedBoxSet(box)
+	completeBoxSet := a.defaultBoxSet.contributeToCompressedBoxSet(box)
 	for i, line := range originalLines {
 		if i == 0 {
 			// we ignore the first line
@@ -314,7 +329,7 @@ func (a *asciiBoxWriter) hasBorders(box AsciiBox) bool {
 		return false
 	}
 	// Check if the first char is the upper left corner
-	return []rune(box.String())[0] == []rune(a.upperLeftCorner)[0]
+	return []rune(box.String())[0] == []rune(a.defaultBoxSet.UpperLeftCorner)[0]
 }
 
 func countChars(s string) int {
@@ -373,7 +388,7 @@ func (m AsciiBox) String() string {
 func (a *asciiBoxWriter) BoxBox(box AsciiBox, options ...func(*BoxOptions)) AsciiBox {
 	// TODO: if there is a box bigger then others in that this will get distorted
 	newBox := a.BoxString(box.data, options...)
-	newBox.compressedBoxSet = a.contributeToCompressedBoxSet(box)
+	newBox.compressedBoxSet = a.defaultBoxSet.contributeToCompressedBoxSet(box)
 	return newBox
 }
 
@@ -385,7 +400,7 @@ func (a *asciiBoxWriter) BoxString(data string, options ...func(*BoxOptions)) As
 // AlignBoxes aligns all boxes to a desiredWidth and orders them from left to right and top to bottom (size will be at min the size of the biggest box)
 func (a *asciiBoxWriter) AlignBoxes(boxes []AsciiBox, desiredWidth int, options ...func(*BoxOptions)) AsciiBox {
 	if len(boxes) == 0 {
-		return AsciiBox{"", a, a.compressBoxSet()}
+		return AsciiBox{"", a, a.defaultBoxSet.compressBoxSet()}
 	}
 	actualWidth := desiredWidth
 	for _, box := range boxes {
@@ -400,7 +415,7 @@ func (a *asciiBoxWriter) AlignBoxes(boxes []AsciiBox, desiredWidth int, options
 	if DebugAsciiBox {
 		AsciiBoxLogger.Debug().Int("actualWidth", actualWidth).Msg("Working with actualWidth chars")
 	}
-	bigBox := AsciiBox{"", a, a.compressBoxSet()}
+	bigBox := AsciiBox{"", a, a.defaultBoxSet.compressBoxSet()}
 	currentBoxRow := make([]AsciiBox, 0)
 	currentRowLength := 0
 	for _, box := range boxes {
diff --git a/plc4go/spi/utils/asciiBox_test.go b/plc4go/spi/utils/asciiBox_test.go
index ec2e1f8b83..3fdc1cc166 100644
--- a/plc4go/spi/utils/asciiBox_test.go
+++ b/plc4go/spi/utils/asciiBox_test.go
@@ -991,7 +991,7 @@ func BenchmarkExpandBox(b *testing.B) {
 }
 
 func asciiBoxForTest(value string) AsciiBox {
-	return AsciiBox{value, AsciiBoxWriterDefault.(*asciiBoxWriter), AsciiBoxWriterDefault.(*asciiBoxWriter).compressBoxSet()}
+	return AsciiBox{value, AsciiBoxWriterDefault.(*asciiBoxWriter), AsciiBoxWriterDefault.(*asciiBoxWriter).defaultBoxSet.compressBoxSet()}
 }
 
 func TestNewAsciiBoxWriter(t *testing.T) {
@@ -1008,13 +1008,13 @@ func TestNewAsciiBoxWriter(t *testing.T) {
 		{
 			name: "create one",
 			want: &asciiBoxWriter{
-				boxSet: boxSet{
-					upperLeftCorner:  upperLeftCorner,
-					upperRightCorner: upperRightCorner,
-					horizontalLine:   horizontalLine,
-					verticalLine:     verticalLine,
-					lowerLeftCorner:  lowerLeftCorner,
-					lowerRightCorner: lowerRightCorner,
+				defaultBoxSet: BoxSet{
+					UpperLeftCorner:  upperLeftCorner,
+					UpperRightCorner: upperRightCorner,
+					HorizontalLine:   horizontalLine,
+					VerticalLine:     verticalLine,
+					LowerLeftCorner:  lowerLeftCorner,
+					LowerRightCorner: lowerRightCorner,
 				},
 				newLine:      '\n',
 				emptyPadding: " ",
@@ -1033,65 +1033,9 @@ func TestNewAsciiBoxWriter(t *testing.T) {
 	}
 }
 
-func TestNewAsciiBoxWriterWithCustomBorders(t *testing.T) {
-	upperLeftCorner := "p"
-	upperRightCorner := "l"
-	horizontalLine := "c"
-	verticalLine := "4"
-	lowerLeftCorner := "x"
-	lowerRightCorner := "!"
-	type args struct {
-		upperLeftCorner  string
-		upperRightCorner string
-		horizontalLine   string
-		verticalLine     string
-		lowerLeftCorner  string
-		lowerRightCorner string
-	}
-	tests := []struct {
-		name string
-		args args
-		want AsciiBoxWriter
-	}{
-		{
-			name: "create one",
-			args: args{
-				upperLeftCorner:  upperLeftCorner,
-				upperRightCorner: upperRightCorner,
-				horizontalLine:   horizontalLine,
-				verticalLine:     verticalLine,
-				lowerLeftCorner:  lowerLeftCorner,
-				lowerRightCorner: lowerRightCorner,
-			},
-			want: &asciiBoxWriter{
-				boxSet: boxSet{
-					upperLeftCorner:  upperLeftCorner,
-					upperRightCorner: upperRightCorner,
-					horizontalLine:   horizontalLine,
-					verticalLine:     verticalLine,
-					lowerLeftCorner:  lowerLeftCorner,
-					lowerRightCorner: lowerRightCorner,
-				},
-				newLine:      '\n',
-				emptyPadding: " ",
-				// the name gets prefixed with a extra symbol for indent
-				extraNameCharIndent: 1,
-				borderWidth:         1,
-				newLineCharWidth:    1,
-				boxNameRegex:        regexp.MustCompile(`^` + upperLeftCorner + horizontalLine + `(?P<name>[\w /]+)` + horizontalLine + `*` + upperRightCorner),
-			},
-		},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			assert.Equalf(t, tt.want, NewAsciiBoxWriterWithCustomBorders(tt.args.upperLeftCorner, tt.args.upperRightCorner, tt.args.horizontalLine, tt.args.verticalLine, tt.args.lowerLeftCorner, tt.args.lowerRightCorner), "NewAsciiBoxWriterWithCustomBorders(%v, %v, %v, %v, %v, %v)", tt.args.upperLeftCorner, tt.args.upperRightCorner, tt.args.horizontalLine, tt.args.verticalLine, tt.args.lowerLeftCorner, tt.args.lowerRightCorner)
-		})
-	}
-}
-
 func Test_asciiBoxWriter_AlignBoxes(t *testing.T) {
 	type fields struct {
-		boxSet              boxSet
+		defaultBoxSet       BoxSet
 		newLine             rune
 		emptyPadding        string
 		extraNameCharIndent int
@@ -1150,13 +1094,13 @@ func Test_asciiBoxWriter_AlignBoxes(t *testing.T) {
 		{
 			name: "not enough space",
 			fields: fields{
-				boxSet: boxSet{
-					upperLeftCorner:  "p",
-					upperRightCorner: "l",
-					horizontalLine:   "c",
-					verticalLine:     "4",
-					lowerLeftCorner:  "x",
-					lowerRightCorner: "!",
+				defaultBoxSet: BoxSet{
+					UpperLeftCorner:  "p",
+					UpperRightCorner: "l",
+					HorizontalLine:   "c",
+					VerticalLine:     "4",
+					LowerLeftCorner:  "x",
+					LowerRightCorner: "!",
 				},
 			},
 			args: args{
@@ -1168,13 +1112,13 @@ func Test_asciiBoxWriter_AlignBoxes(t *testing.T) {
 ║123123ABABABABABAB123123║
 ╚════════════════════════╝`[1:],
 						asciiBoxWriter: &asciiBoxWriter{
-							boxSet: boxSet{
-								upperLeftCorner:  "p",
-								upperRightCorner: "l",
-								horizontalLine:   "c",
-								verticalLine:     "4",
-								lowerLeftCorner:  "x",
-								lowerRightCorner: "!",
+							defaultBoxSet: BoxSet{
+								UpperLeftCorner:  "p",
+								UpperRightCorner: "l",
+								HorizontalLine:   "c",
+								VerticalLine:     "4",
+								LowerLeftCorner:  "x",
+								LowerRightCorner: "!",
 							},
 						},
 					},
@@ -1185,13 +1129,13 @@ func Test_asciiBoxWriter_AlignBoxes(t *testing.T) {
 ║123123123123123123123123║
 ╚════════════════════════╝`[1:],
 						asciiBoxWriter: &asciiBoxWriter{
-							boxSet: boxSet{
-								upperLeftCorner:  "p",
-								upperRightCorner: "l",
-								horizontalLine:   "c",
-								verticalLine:     "4",
-								lowerLeftCorner:  "x",
-								lowerRightCorner: "!",
+							defaultBoxSet: BoxSet{
+								UpperLeftCorner:  "p",
+								UpperRightCorner: "l",
+								HorizontalLine:   "c",
+								VerticalLine:     "4",
+								LowerLeftCorner:  "x",
+								LowerRightCorner: "!",
 							},
 						},
 					},
@@ -1209,13 +1153,13 @@ func Test_asciiBoxWriter_AlignBoxes(t *testing.T) {
 ║123123123123123123123123║
 ╚════════════════════════╝`[1:],
 				asciiBoxWriter: &asciiBoxWriter{
-					boxSet: boxSet{
-						upperLeftCorner:  "p",
-						upperRightCorner: "l",
-						horizontalLine:   "c",
-						verticalLine:     "4",
-						lowerLeftCorner:  "x",
-						lowerRightCorner: "!",
+					defaultBoxSet: BoxSet{
+						UpperLeftCorner:  "p",
+						UpperRightCorner: "l",
+						HorizontalLine:   "c",
+						VerticalLine:     "4",
+						LowerLeftCorner:  "x",
+						LowerRightCorner: "!",
 					},
 				},
 			},
@@ -1224,7 +1168,7 @@ func Test_asciiBoxWriter_AlignBoxes(t *testing.T) {
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 			a := &asciiBoxWriter{
-				boxSet:              tt.fields.boxSet,
+				defaultBoxSet:       tt.fields.defaultBoxSet,
 				newLine:             tt.fields.newLine,
 				emptyPadding:        tt.fields.emptyPadding,
 				extraNameCharIndent: tt.fields.extraNameCharIndent,
@@ -1239,7 +1183,7 @@ func Test_asciiBoxWriter_AlignBoxes(t *testing.T) {
 
 func Test_asciiBoxWriter_BoxBelowBox(t *testing.T) {
 	type fields struct {
-		boxSet              boxSet
+		defaultBoxSet       BoxSet
 		newLine             rune
 		emptyPadding        string
 		extraNameCharIndent int
@@ -1267,7 +1211,7 @@ func Test_asciiBoxWriter_BoxBelowBox(t *testing.T) {
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 			a := &asciiBoxWriter{
-				boxSet:              tt.fields.boxSet,
+				defaultBoxSet:       tt.fields.defaultBoxSet,
 				newLine:             tt.fields.newLine,
 				emptyPadding:        tt.fields.emptyPadding,
 				extraNameCharIndent: tt.fields.extraNameCharIndent,
@@ -1283,7 +1227,7 @@ func Test_asciiBoxWriter_BoxBelowBox(t *testing.T) {
 
 func Test_asciiBoxWriter_BoxBox(t *testing.T) {
 	type fields struct {
-		boxSet              boxSet
+		defaultBoxSet       BoxSet
 		newLine             rune
 		emptyPadding        string
 		extraNameCharIndent int
@@ -1311,7 +1255,7 @@ func Test_asciiBoxWriter_BoxBox(t *testing.T) {
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 			a := &asciiBoxWriter{
-				boxSet:              tt.fields.boxSet,
+				defaultBoxSet:       tt.fields.defaultBoxSet,
 				newLine:             tt.fields.newLine,
 				emptyPadding:        tt.fields.emptyPadding,
 				extraNameCharIndent: tt.fields.extraNameCharIndent,
@@ -1327,7 +1271,7 @@ func Test_asciiBoxWriter_BoxBox(t *testing.T) {
 
 func Test_asciiBoxWriter_BoxSideBySide(t *testing.T) {
 	type fields struct {
-		boxSet              boxSet
+		defaultBoxSet       BoxSet
 		newLine             rune
 		emptyPadding        string
 		extraNameCharIndent int
@@ -1352,7 +1296,7 @@ func Test_asciiBoxWriter_BoxSideBySide(t *testing.T) {
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 			a := &asciiBoxWriter{
-				boxSet:              tt.fields.boxSet,
+				defaultBoxSet:       tt.fields.defaultBoxSet,
 				newLine:             tt.fields.newLine,
 				emptyPadding:        tt.fields.emptyPadding,
 				extraNameCharIndent: tt.fields.extraNameCharIndent,
@@ -1368,7 +1312,7 @@ func Test_asciiBoxWriter_BoxSideBySide(t *testing.T) {
 
 func Test_asciiBoxWriter_BoxString(t *testing.T) {
 	type fields struct {
-		boxSet              boxSet
+		defaultBoxSet       BoxSet
 		newLine             rune
 		emptyPadding        string
 		extraNameCharIndent int
@@ -1395,7 +1339,7 @@ func Test_asciiBoxWriter_BoxString(t *testing.T) {
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 			a := &asciiBoxWriter{
-				boxSet:              tt.fields.boxSet,
+				defaultBoxSet:       tt.fields.defaultBoxSet,
 				newLine:             tt.fields.newLine,
 				emptyPadding:        tt.fields.emptyPadding,
 				extraNameCharIndent: tt.fields.extraNameCharIndent,
@@ -1411,7 +1355,7 @@ func Test_asciiBoxWriter_BoxString(t *testing.T) {
 
 func Test_asciiBoxWriter_boxString(t *testing.T) {
 	type fields struct {
-		boxSet              boxSet
+		defaultBoxSet       BoxSet
 		newLine             rune
 		emptyPadding        string
 		extraNameCharIndent int
@@ -1436,7 +1380,7 @@ func Test_asciiBoxWriter_boxString(t *testing.T) {
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 			a := &asciiBoxWriter{
-				boxSet:              tt.fields.boxSet,
+				defaultBoxSet:       tt.fields.defaultBoxSet,
 				newLine:             tt.fields.newLine,
 				emptyPadding:        tt.fields.emptyPadding,
 				extraNameCharIndent: tt.fields.extraNameCharIndent,
@@ -1452,7 +1396,7 @@ func Test_asciiBoxWriter_boxString(t *testing.T) {
 
 func Test_asciiBoxWriter_changeBoxName(t *testing.T) {
 	type fields struct {
-		boxSet              boxSet
+		defaultBoxSet       BoxSet
 		newLine             rune
 		emptyPadding        string
 		extraNameCharIndent int
@@ -1478,7 +1422,7 @@ func Test_asciiBoxWriter_changeBoxName(t *testing.T) {
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 			a := &asciiBoxWriter{
-				boxSet:              tt.fields.boxSet,
+				defaultBoxSet:       tt.fields.defaultBoxSet,
 				newLine:             tt.fields.newLine,
 				emptyPadding:        tt.fields.emptyPadding,
 				extraNameCharIndent: tt.fields.extraNameCharIndent,
@@ -1494,7 +1438,7 @@ func Test_asciiBoxWriter_changeBoxName(t *testing.T) {
 
 func Test_asciiBoxWriter_expandBox(t *testing.T) {
 	type fields struct {
-		boxSet              boxSet
+		defaultBoxSet       BoxSet
 		newLine             rune
 		emptyPadding        string
 		extraNameCharIndent int
@@ -1519,7 +1463,7 @@ func Test_asciiBoxWriter_expandBox(t *testing.T) {
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 			a := &asciiBoxWriter{
-				boxSet:              tt.fields.boxSet,
+				defaultBoxSet:       tt.fields.defaultBoxSet,
 				newLine:             tt.fields.newLine,
 				emptyPadding:        tt.fields.emptyPadding,
 				extraNameCharIndent: tt.fields.extraNameCharIndent,
@@ -1534,7 +1478,7 @@ func Test_asciiBoxWriter_expandBox(t *testing.T) {
 
 func Test_asciiBoxWriter_getBoxName(t *testing.T) {
 	type fields struct {
-		boxSet              boxSet
+		defaultBoxSet       BoxSet
 		newLine             rune
 		emptyPadding        string
 		extraNameCharIndent int
@@ -1561,7 +1505,7 @@ func Test_asciiBoxWriter_getBoxName(t *testing.T) {
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 			a := &asciiBoxWriter{
-				boxSet:              tt.fields.boxSet,
+				defaultBoxSet:       tt.fields.defaultBoxSet,
 				newLine:             tt.fields.newLine,
 				emptyPadding:        tt.fields.emptyPadding,
 				extraNameCharIndent: tt.fields.extraNameCharIndent,
@@ -1588,7 +1532,7 @@ func Test_asciiBoxWriter_getBoxNameWrongRegex(t *testing.T) {
 
 func Test_asciiBoxWriter_hasBorders(t *testing.T) {
 	type fields struct {
-		boxSet              boxSet
+		defaultBoxSet       BoxSet
 		newLine             rune
 		emptyPadding        string
 		extraNameCharIndent int
@@ -1612,7 +1556,7 @@ func Test_asciiBoxWriter_hasBorders(t *testing.T) {
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 			a := &asciiBoxWriter{
-				boxSet:              tt.fields.boxSet,
+				defaultBoxSet:       tt.fields.defaultBoxSet,
 				newLine:             tt.fields.newLine,
 				emptyPadding:        tt.fields.emptyPadding,
 				extraNameCharIndent: tt.fields.extraNameCharIndent,
@@ -1627,7 +1571,7 @@ func Test_asciiBoxWriter_hasBorders(t *testing.T) {
 
 func Test_asciiBoxWriter_mergeHorizontal(t *testing.T) {
 	type fields struct {
-		boxSet              boxSet
+		defaultBoxSet       BoxSet
 		newLine             rune
 		emptyPadding        string
 		extraNameCharIndent int
@@ -1651,7 +1595,7 @@ func Test_asciiBoxWriter_mergeHorizontal(t *testing.T) {
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 			a := &asciiBoxWriter{
-				boxSet:              tt.fields.boxSet,
+				defaultBoxSet:       tt.fields.defaultBoxSet,
 				newLine:             tt.fields.newLine,
 				emptyPadding:        tt.fields.emptyPadding,
 				extraNameCharIndent: tt.fields.extraNameCharIndent,
@@ -1667,7 +1611,7 @@ func Test_asciiBoxWriter_mergeHorizontal(t *testing.T) {
 
 func Test_asciiBoxWriter_unwrap(t *testing.T) {
 	type fields struct {
-		boxSet              boxSet
+		defaultBoxSet       BoxSet
 		newLine             rune
 		emptyPadding        string
 		extraNameCharIndent int
@@ -1691,7 +1635,7 @@ func Test_asciiBoxWriter_unwrap(t *testing.T) {
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 			a := &asciiBoxWriter{
-				boxSet:              tt.fields.boxSet,
+				defaultBoxSet:       tt.fields.defaultBoxSet,
 				newLine:             tt.fields.newLine,
 				emptyPadding:        tt.fields.emptyPadding,
 				extraNameCharIndent: tt.fields.extraNameCharIndent,
@@ -1724,13 +1668,13 @@ func Test_boxSet_compressBoxSet(t *testing.T) {
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
-			b := boxSet{
-				upperLeftCorner:  tt.fields.upperLeftCorner,
-				upperRightCorner: tt.fields.upperRightCorner,
-				horizontalLine:   tt.fields.horizontalLine,
-				verticalLine:     tt.fields.verticalLine,
-				lowerLeftCorner:  tt.fields.lowerLeftCorner,
-				lowerRightCorner: tt.fields.lowerRightCorner,
+			b := BoxSet{
+				UpperLeftCorner:  tt.fields.upperLeftCorner,
+				UpperRightCorner: tt.fields.upperRightCorner,
+				HorizontalLine:   tt.fields.horizontalLine,
+				VerticalLine:     tt.fields.verticalLine,
+				LowerLeftCorner:  tt.fields.lowerLeftCorner,
+				LowerRightCorner: tt.fields.lowerRightCorner,
 			}
 			assert.Equalf(t, tt.want, b.compressBoxSet(), "compressBoxSet()")
 		})
@@ -1814,13 +1758,13 @@ func Test_boxSet_contributeToCompressedBoxSet(t *testing.T) {
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
-			b := boxSet{
-				upperLeftCorner:  tt.fields.upperLeftCorner,
-				upperRightCorner: tt.fields.upperRightCorner,
-				horizontalLine:   tt.fields.horizontalLine,
-				verticalLine:     tt.fields.verticalLine,
-				lowerLeftCorner:  tt.fields.lowerLeftCorner,
-				lowerRightCorner: tt.fields.lowerRightCorner,
+			b := BoxSet{
+				UpperLeftCorner:  tt.fields.upperLeftCorner,
+				UpperRightCorner: tt.fields.upperRightCorner,
+				HorizontalLine:   tt.fields.horizontalLine,
+				VerticalLine:     tt.fields.verticalLine,
+				LowerLeftCorner:  tt.fields.lowerLeftCorner,
+				LowerRightCorner: tt.fields.lowerRightCorner,
 			}
 			assert.Equalf(t, tt.want, b.contributeToCompressedBoxSet(tt.args.box), "contributeToCompressedBoxSet(%v)", tt.args.box)
 		})
diff --git a/plc4go/spi/utils/dumpUtils.go b/plc4go/spi/utils/dumpUtils.go
index de1fed01b6..9b7a352974 100644
--- a/plc4go/spi/utils/dumpUtils.go
+++ b/plc4go/spi/utils/dumpUtils.go
@@ -29,14 +29,15 @@ import (
 // BoxedDump dumps a 56+2 char wide hex string
 func BoxedDump(data []byte, options ...func(*BoxOptions)) AsciiBox {
 	var opts BoxOptions
+	opts.BoxSet = DefaultBoxSet()
 	for _, opt := range options {
 		opt(&opts)
 	}
-	if opts.charWidth <= 0 {
-		opts.charWidth = DefaultWidth + boxLineOverheat
+	if opts.CharWidth <= 0 {
+		opts.CharWidth = DefaultWidth + boxLineOverheat
 	}
 	// we substract the 2 lines at the side
-	dumpWidth := opts.charWidth - 1 - 1
+	dumpWidth := opts.CharWidth - 1 - 1
 	return AsciiBoxWriterDefault.BoxString(DumpFixedWidth(data, dumpWidth), WithAsciiBoxOptions(opts))
 }
 
@@ -51,8 +52,8 @@ func DumpAnything(anything any, options ...func(*BoxOptions)) string {
 	for _, opt := range options {
 		opt(&opts)
 	}
-	if opts.charWidth <= 0 {
-		opts.charWidth = DefaultWidth
+	if opts.CharWidth <= 0 {
+		opts.CharWidth = DefaultWidth
 	}
 	convertedBytes, err := toBytes(anything)
 	if err != nil {
@@ -61,7 +62,7 @@ func DumpAnything(anything any, options ...func(*BoxOptions)) string {
 		}
 		return "<undumpable>"
 	}
-	return DumpFixedWidth(convertedBytes, opts.charWidth)
+	return DumpFixedWidth(convertedBytes, opts.CharWidth)
 }
 
 func BoxAnything(anything any, options ...func(*BoxOptions)) AsciiBox {
@@ -85,7 +86,7 @@ func BoxAnything(anything any, options ...func(*BoxOptions)) AsciiBox {
 		return AsciiBoxWriterDefault.BoxString(fmt.Sprintf("%#0*x %d", hexDigits, anything, anything), options...)
 	case []byte:
 		//return AsciiBox{DumpFixedWidth(anything.([]byte), charWidth), AsciiBoxWriterDefault.(*asciiBoxWriter), AsciiBoxWriterDefault.(*asciiBoxWriter).compressBoxSet()}
-		return AsciiBoxWriterDefault.BoxString(DumpFixedWidth(anything.([]byte), opts.charWidth), options...)
+		return AsciiBoxWriterDefault.BoxString(DumpFixedWidth(anything.([]byte), opts.CharWidth), options...)
 	case string:
 		return AsciiBoxWriterDefault.BoxString(anything.(string), options...)
 	case fmt.Stringer:
@@ -97,9 +98,9 @@ func BoxAnything(anything any, options ...func(*BoxOptions)) AsciiBox {
 			boxes := make([]AsciiBox, valueOf.Len())
 			for i := 0; i < valueOf.Len(); i++ {
 				index := valueOf.Index(i)
-				boxes[i] = BoxAnything(index.Interface(), WithAsciiBoxCharWidth(opts.charWidth-2))
+				boxes[i] = BoxAnything(index.Interface(), WithAsciiBoxCharWidth(opts.CharWidth-2))
 			}
-			return AsciiBoxWriterDefault.BoxBox(AsciiBoxWriterDefault.AlignBoxes(boxes, opts.charWidth), options...)
+			return AsciiBoxWriterDefault.BoxBox(AsciiBoxWriterDefault.AlignBoxes(boxes, opts.CharWidth), options...)
 		case reflect.Ptr, reflect.Uintptr:
 			return BoxAnything(valueOf.Elem().Interface(), options...)
 		default: