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
108
109
110
111
112
113
package Torello.Browser;

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

import java.util.Objects;

import Torello.Java.StrPrint;


// ================================================================================================
// PCHelper.java
// ================================================================================================
// This internal-use-only class is the designated implementation backend for standard Java
// overrides: `toString()`, `equals(Object)`, `hashCode()`, and `clone()` — all for the
// `PageConn` class.
//
// It was intentionally extracted into a separate helper class to keep `PageConn` 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 `PageConn`, 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 !!

class PCHelper
{
    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 PageConn, including color codes.
    static String toString(PageConn pc)
    {
        final String B = BCYAN, R = RESET;
        final int L = 26;

        return "PageConn\n" +
        "{\n" +
            "    " + B + "id                   " + R + ": " + pc.id                 + '\n' +
            "    " + B + "type                 " + R + ": " + pc.type               + '\n' +
            "    " + B + "title                " + R + ": " + WRAP(pc.title)        + '\n' +
            "    " + B + "url                  " + R + ": " + WRAP(pc.url)          + '\n' +
            "    " + B + "description          " + R + ": " + WRAP(pc.description)  + '\n' +
    
            "    " + B + "webSocketDebuggerUrl " + R + ": " +
                WRAP(pc.webSocketDebuggerUrl)   + '\n' +

            "    " + B + "devtoolsFrontendUrl  " + R + ": " +
                WRAP(pc.devtoolsFrontendUrl) + '\n' +

            "    " + B + "faviconUrl           " + R + ": " +
                WRAP(pc.faviconUrl) + '\n' +
        "}";
    }

    // Performs field-by-field equality comparison for two PageConn instances.
    static boolean equals(PageConn a, Object o)
    {
        if (a == o)                     return true;
        if (!(o instanceof PageConn))   return false;

        final PageConn b = (PageConn) o;

        return Objects.equals(a.id,                     b.id)
            && Objects.equals(a.type,                   b.type)
            && Objects.equals(a.title,                  b.title)
            && Objects.equals(a.url,                    b.url)
            && Objects.equals(a.description,            b.description)
            && Objects.equals(a.webSocketDebuggerUrl,   b.webSocketDebuggerUrl)
            && Objects.equals(a.devtoolsFrontendUrl,    b.devtoolsFrontendUrl)
            && Objects.equals(a.faviconUrl,             b.faviconUrl);
    }

    // Computes a composite hashCode based on all internal fields.
    static int hashCode(PageConn pc)
    {
        return Objects.hash(
            pc.id, pc.type, pc.title, pc.url, pc.description,
            pc.webSocketDebuggerUrl, pc.devtoolsFrontendUrl, pc.faviconUrl
        );
    }

    // Performs a deep copy of a PageConn instance.
    static PageConn clone(PageConn pc)
    {
        return new PageConn(
            pc.id,
            pc.type,
            pc.title,
            pc.url,
            pc.description,
            pc.webSocketDebuggerUrl,
            pc.devtoolsFrontendUrl,
            pc.faviconUrl
        );
    }
}