1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package Torello.Browser;

import static Torello.Java.C.BCYAN;
import static Torello.Java.C.RESET;

import java.util.Objects;

import Torello.Java.StrPrint;


// ================================================================================================
// BCHelper.java
// ================================================================================================
// This internal-use-only class is the designated implementation backend for standard Java
// overrides: `toString()`, `equals(Object)`, `hashCode()`, and `clone()` — all for the
// `BrowserConn` class.
//
// It was intentionally extracted into a separate helper class to keep `BrowserConn` focused on
// its data and construction logic, while offloading the tedious and uninteresting utility methods
// to a separate location.
//
// These implementations are publicly visible through `@LinkJavaSource`, so users can audit
// the behavior of `equals()` and `clone()` directly, without cluttering the main class.
//
// If you're wondering why all this isn't just inside `BrowserConn`, it's because we value
// *clarity over cramming*.
// ================================================================================================
//
// Above Crapola was written by Chat-GPT on August 5th, 2025.
// That's some great stuff.
// 
// NOTE - Chat-GPT Made the Statement (Above): "it's because we value *clarity over cramming*."
// 
// I WOULD JUST SAY: Ripping out of the 'java.lang.Object' methods, and dumping them into a 
// Package-Private class buries all the mundane and boring crap - with the goal of making the class
// BrowserConn that much easier to read !!  No More, No Less !!

final class BCHelper
{
    private static String WRAP(final String s)
    {
        return  (s == null) 
            ? "-NULL-"
            : StrPrint.wrapToIndentationPlus(s, 100 - 27, 100, 27);
    }

    // Pretty-print the full contents of a BrowserConn, including color codes.
    static String toString(BrowserConn bc)
    {
        final String B = BCYAN, R = RESET;

        return "BrowserConn\n" +
        "{\n" +
            "    " + B + "browser              " + R + ": " + bc.browser            + '\n' +
            "    " + B + "protocolVersion      " + R + ": " + bc.protocolVersion    + '\n' +
            "    " + B + "userAgent            " + R + ": " + WRAP(bc.userAgent)    + '\n' +
            "    " + B + "v8Version            " + R + ": " + WRAP(bc.v8Version)    + '\n' +

            "    " + B + "webkitVersion        " + R + ": " +
                WRAP(bc.webkitVersion) + '\n' +

            "    " + B + "webSocketDebuggerUrl " + R + ": " +
                WRAP(bc.webSocketDebuggerUrl) + '\n' +
        "}";
    }

    // Performs field-by-field equality comparison for two BrowserConn instances.
    static boolean equals(BrowserConn a, Object o)
    {
        if (a == o)                         return true;
        if (!(o instanceof BrowserConn))    return false;
    
        final BrowserConn b = (BrowserConn) o;
    
        return java.util.Objects.equals(a.browser,               b.browser)
            && java.util.Objects.equals(a.protocolVersion,       b.protocolVersion)
            && java.util.Objects.equals(a.userAgent,             b.userAgent)
            && java.util.Objects.equals(a.v8Version,             b.v8Version)
            && java.util.Objects.equals(a.webkitVersion,         b.webkitVersion)
            && java.util.Objects.equals(a.webSocketDebuggerUrl,  b.webSocketDebuggerUrl);
    }

    // Computes a composite hashCode based on all internal fields.
    static int hashCode(BrowserConn bc)
    {
        int result = bc.browser.hashCode();
        result = 31 * result + bc.protocolVersion.hashCode();
        result = 31 * result + bc.userAgent.hashCode();
        result = 31 * result + bc.v8Version.hashCode();
        result = 31 * result + bc.webkitVersion.hashCode();
        result = 31 * result + bc.webSocketDebuggerUrl.hashCode();
        return result;
    }

    // Performs a deep copy of a BrowserConn instance.
    static BrowserConn clone(BrowserConn bc)
    {
        return new BrowserConn(
            bc.browser,
            bc.protocolVersion,
            bc.userAgent,
            bc.v8Version,
            bc.webkitVersion,
            bc.webSocketDebuggerUrl
        );
    }
}