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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
package Torello.HTML.Tools.JavaDoc;

import java.util.regex.Pattern;
import java.util.function.Consumer;
import java.util.Optional;

import Torello.Java.StringParse;
import Torello.Java.StrCSV;

import static Torello.Java.Shell.C.*;
import static Torello.HTML.Tools.JavaDoc.PF.*;

import com.github.javaparser.Range;
import com.github.javaparser.Position;
import com.github.javaparser.ast.NodeList;
import com.github.javaparser.ast.Modifier;
import com.github.javaparser.ast.expr.AnnotationExpr;
import com.github.javaparser.ast.comments.JavadocComment;
import com.github.javaparser.printer.lexicalpreservation.LexicalPreservingPrinter;

/**
 * <B STYLE='color:darkred;'>Java Parser Bridge:</B>
 * 
 * Common-Root Ancestor Class of all Bridge Data-Classes.
 * 
 * <BR /><BR />
 * <EMBED CLASS="external-html" DATA-FILE-ID=JPB_DECLARATION>
 * <EMBED CLASS='external-html' DATA-FILE-ID=JPB_DIAGRAM>
 */
@JDHeaderBackgroundImg
public abstract class Declaration implements java.io.Serializable
{
    /** <EMBED CLASS="external-html" DATA-FILE-ID="SVUID"> */
    public static final long serialVersionUID = 1;

    /**
     * For the purposes of passing these around to different parts of the code, every one of
     * of these are given a unique ID.  This id is unique for a method, whether it was parsed 
     * from a detail or a summary section.  This id is (probably) not useful outside of the
     * HTML Processor Classes.
     * 
     * <BR /><BR /><B>NOTE:</B> If a subclass of {@code Declaration} is cloned, then this
     * {@code id} field is also cloned / copied.
     */
    public final int id;

    // The id is just created using this counter.
    private static int idCounter = 1;

    // Helper
    @SuppressWarnings("rawtypes")
    static final NodeList EMPTY_NL = new NodeList();
    // sub-classes use this ==> Package-Visibility

    private String codeHiLiteString = null;

    /**
     * This returns the {@code String} to send to the Syntax {@link HiLiter}.  This is what is
     * inserted into the HiLited Code Portion of a Details Entry (Method Details,
     * Field Declaration, etc...).  
     * 
     * <BR /><BR /><B>NOTE:</B> This will overloaded by the class {@code Callable}.
     * 
     * <BR /><BR /><UL CLASS=JDUL>
     * <LI>{@link Method} will override this, and return its {@link Callable#body} field.</LI>
     * <LI>{@link Constructor} will override this, returning its {@link Callable#body} field.</LI>
     * <LI>{@link Field} will return the {@link #signature} field, as declared here.</LI>
     * <LI>{@link EnumConstant} will return the {@link #signature} field, declared here.</LI>
     * <LI>{@link AnnotationElem} will return the {@link #signature} field, declared here.</LI>
     * </UL>
     * 
     * @return The {@code String} that is ultimately sent to the Syntax HiLiter, and inserted
     * into a Java Doc page.
     */
    String codeHiLiteString() { return codeHiLiteString; }


    // ********************************************************************************************
    // ********************************************************************************************
    // Basic String Fields
    // ********************************************************************************************
    // ********************************************************************************************


    /**
     * The <B>Name</B> of the java {@link Field}, {@link Method}, {@code Constructor},
     * {@link EnumConstant} or {@link AnnotationElem}.  This will be a <B>simple, standard</B>
     * 'Java Identifier'.
     * 
     * <BR /><BR />Note that the name of a {@code Constructor} (for-example) is always just the
     * name of the class.
     * 
     * <BR /><BR />This field will never be null.
     */
    public final String name;

    /**
     * The complete, declared <B>Signature</B> (as a {@code String}) of the {@link Method},
     * {@link Field}, {@link Constructor}, {@link EnumConstant} or {@link AnnotationElem}.
     * 
     * <BR /><BR />This field would never be null.
     */
    public final String signature;

    /**
     * The <B>Java Doc Comment</B> of this {@link Field}, {@link Method}, {@code Constructor},
     * {@link EnumConstant} or {@link AnnotationElem} as a {@code String} - if one exists.  The
     * Java Doc Comment is the one defined directly above the {@code Declaration}.
     * 
     * <BR /><BR />If this {@code Field, Method, Constructor} etc... did not have a Java Doc
     * Comment placed on it, <I>then this field {@code 'jdComment'} will be {@code null}.</I>
     */
    public final String jdComment;

    /**
     * This just stores the type of {@link Entity} this is.  For sub-classes instances of
     * {@link Declaration} which are {@link Method}, this field will be equal to
     * {@link Entity#METHOD}.  For instances of the {@link Field} sub-class, this will equal
     * {@link Entity#FIELD}, and so on and so forth.
     * 
     * <BR /><BR />Mostly, this makes code easier to read when used along-side <B>if-statements</B>
     * or <B>switch-statements</B> than something akin to {@code Declaration.getClass()}
     * (when retrieving the specific {@code Declaration} sub-class type).
     * 
     * <BR /><BR /><B>NOTE:</B> Both this class, and sub-class {@code Callable} are declared
     * {@code abstract}, and only instances of Method, Field, Constructor, etc... can be
     * instantiated.
     */
    public final Entity entity;


    // ********************************************************************************************
    // ********************************************************************************************
    // Line Numbers
    // ********************************************************************************************
    // ********************************************************************************************


    /**
     * This contains the source-code file line-number where the signature for this
     * {@code Declaration}.
     */
    public final int signatureLineNumber;

    /**
     * This contains the source-code file line-number for the <B STYLE='color: red'>last</B>
     * line of the Java Doc Comment, if present.  If there were no JavaDoc Comment, this shall
     * contain {@code -1}.
     */
    public final int jdStartLineNumber;

    /**
     * This contains the source-code file line-number for the <B STYLE='color: red'>last</B>
     * line of the Java Doc Comment, if present.  If there were no JavaDoc Comment, this shall
     * contain {@code -1}.
     */
    public final int jdEndLineNumber;


    // ********************************************************************************************
    // ********************************************************************************************
    // Modifiers: public, private, protected, static, default, final, volatile, ...
    // ********************************************************************************************
    // ********************************************************************************************


    /**
     * The {@code 'modifiers'} placed on this {@code Declaration}.  This includes {@code String's}
     * such as: {@code public, static, final} etc...  Note that this field is kept
     * {@code protected} so that it cannot be changed, but it's contents can be retrieved with
     * the getter methods provided, below.
     * 
     * <EMBED CLASS='external-html' DATA-FILE-ID=JPB_PI_ARR_NOTE>
     * 
     * @see #getModifiers()
     * @see #getModifiers(Consumer)
     * @see #hasModifier(String)
     * @see #hasModifiers()
     * @see #numModifiers()
     */
    protected final String[] modifiers;

    /**
     * Retrieves the list of {@code 'modifiers'} as {@code String}-array.  The {@code modifiers}
     * are just the words that come before a {@link Field}, {@link Constructor}, {@link Method},
     * {@link EnumConstant} or {@link AnnotationElem} such as: {@code public, private, protected,
     * final} - among others.
     * 
     * <EMBED CLASS='external-html' DATA-FILE-ID=JPB_PI_ARR_NOTE>
     * 
     * @return An instance of {@code String[]}, which was built using Java's {@code clone()}
     * method, <I>thereby protecting its contents.</I>
     * 
     * @see #modifiers
     */
    public String[] getModifiers()
    { return modifiers.clone(); }

    /**
     * Retrieves the list of {@code 'modifiers'}.  User provides an insertion function of their
     * choice.  The {@code 'modifiers'} are just the words that come before a {@link Field},
     * {@link Constructor}, {@link Method}, etc... - including (for-example): {@code public,
     * private, protected, final, volatile} (of which there are quite a few).
     * 
     * <EMBED CLASS='external-html' DATA-FILE-ID=JPB_PI_ARR_NOTE>
     * 
     * @param acceptModifiersAsStringConsumer
     * <EMBED CLASS='external-html' DATA-FILE-ID=JPB_CONSUM DATA-P1=getModifiers DATA-P2=modifiers>
     * 
     * @see #modifiers
     */
    public void getModifiers(Consumer<String> acceptModifiersAsStringConsumer)
    { for (String modifier : modifiers) acceptModifiersAsStringConsumer.accept(modifier); }

    /**
     * The user may pass any of the standard Java Modifiers for Declarations to ask whether this
     * {@code Declaration} was defined using that {@code modifier}.
     * 
     * @param modifier a (lower-case) {@code String} such as: {@code 'public', 'static', 'final'}
     * etc...
     * 
     * @return {@code TRUE} if the provided {@code 'modifier'} is, actually, one of the modifiers
     * listed within this {@code Declaration's} internal {@code 'modifiers'} array.
     * 
     * @see #modifiers
     */
    public boolean hasModifier(String modifier)
    { for (String m : modifiers) if (m.equals(modifier)) return true; return false; }

    /**
     * Reports whether this instance of {@code Declaration} has any modifiers attached to it.
     * It simply returns whether or not the internal {@code 'modifiers'} array has length bigger
     * than zero.
     * 
     * @return Returns {@code TRUE} if there were any modifiers - <I>{@code public, static, final}
     * etc...</I> - that were specified in this declaration.
     * 
     * @see #modifiers
     */
    public boolean hasModifiers() { return modifiers.length > 0; }

    /**
     * Returns the number of {@code 'modifiers'} - <I><CODE>public, static, final</CODE> etc...</I>
     * - that were specified by 'this' {@code Declaration}
     * 
     * @return Returns the length of the <CODE>protected</CODE> (internal) {@code 'modifiers'}
     * array.
     * 
     * @see #modifiers
     */
    public int numModifiers() { return modifiers.length; }


    // ********************************************************************************************
    // ********************************************************************************************
    // Annotations (The annotations attached to a declaration)
    // ********************************************************************************************
    // ********************************************************************************************


    /**
     * <EMBED CLASS='external-html' DATA-FILE-ID=JPB_DECL_ANNOT>
     * <EMBED CLASS='external-html' DATA-FILE-ID=JPB_PI_ARR_NOTE>
     * 
     * @see #getAnnotations()
     * @see #getAnnotations(Consumer)
     * @see #hasAnnotations()
     * @see #numAnnotations()
     */
    protected final String[] annotations;

    /**
     * Retrieves the list of {@code 'annotations'} as {@code String}-array.  The
     * {@code annotations} are the {@code String's} that begin with the {@code '@'} symbol, and
     * are, occasionally, placed before a {@link Method}, {@link Constructor}, {@link Field},
     * {@link EnumConstant} or {@link AnnotationElem}.
     * 
     * <EMBED CLASS='external-html' DATA-FILE-ID=JPB_PI_ARR_NOTE>
     * 
     * @return An instance of {@code String[]}, which was built using Java's {@code clone()}
     * method, <I>thereby protecting its contents.</I>
     * 
     * @see #annotations
     */
    public String[] getAnnotations()
    { return annotations.clone(); }

    /**
     * Retrieves the list of {@code 'annotations'}.  User provides an insertion function of their
     * choice.
     * 
     * <EMBED CLASS='external-html' DATA-FILE-ID=JPB_PI_ARR_NOTE>
     * 
     * @param acceptAnnotationsAsStringConsumer
     * <EMBED CLASS='external-html' DATA-FILE-ID=JPB_CONSUM
     *  DATA-P1=getAnnotations DATA-P2=annotations>
     * 
     * @see #annotations
     */
    public void getAnnotations(Consumer<String> acceptAnnotationsAsStringConsumer)
    { for (String annotation : annotations) acceptAnnotationsAsStringConsumer.accept(annotation); }

    /**
     * Reports whether this instance of {@code Declaration} has any annotations attached to it.
     * It simply returns whether or not the internal {@code 'modifiers'} array has length bigger
     * than zero.
     * 
     * @return Returns {@code TRUE} if there were any modifiers - <I>{@code public, static, final}
     * etc...</I> - that were specified in this declaration.
     * 
     * @see #annotations
     */
    public boolean hasAnnotations() { return annotations.length > 0; }

    /**
     * This returns the number of {@code 'annotations'} that may or may not have placed on
     * {@code 'this' Declaration}.  If this {@link Method}, {@link Constructor}, {@code Field},
     * {@code EnumConstant} or {@code AnnotationElem} was not annotated with anything, then the
     * return-value of this method is, simply, zero.
     * 
     * @return Returns the length of the {@code protected} (internal) {@code 'annotations'} array.
     * 
     * @see #annotations
     */
    public int numAnnotations() { return annotations.length; }


    // ********************************************************************************************
    // ********************************************************************************************
    // Constructor for this class Declaration
    // ********************************************************************************************
    // ********************************************************************************************


    // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    // Used internally in this package, by subclasses
    // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

    Declaration(
            NodeList<AnnotationExpr>    annotations,
            NodeList<Modifier>          modifiers,
            String                      name,
            String                      signature,
            Optional<JavadocComment>    jdComment,
            Entity                      entity,
            Optional<Position>          signatureLineNumber
        )
    {
        this.id                 = idCounter++;
        this.name               = name.trim();
        this.signature          = signature.trim();
        this.entity             = entity;
        this.codeHiLiteString   = signature;

        if ((signatureLineNumber == null) || (! signatureLineNumber.isPresent()))
            this.signatureLineNumber = -1;
        else
        {
            // This *IS NOT* a *HACK* - BUT....
            //
            // This is necessitated since a Declaration can *ALSO* be built from the Java Doc
            // HTML Signature - which, *RIGHT NOW* always is Line #1 of the String passed to the
            // Java Parser parseXXX(String sig) method - so if that changed for some odd reason
            // this would break.  It has a sig.trim() line, so this should never break...
            //
            // NOTE: The point is that "Synthetic Methods" and the "Auto-Generated Constructor"
            //       do not have line numbers because they are not in the source-file
            //
            // ALSO: There is no class, interface, enum or any TYPE/CIET where a Declaration would
            //       be on Line#1 - it is impossible!  JP is returning Line#1 because in
            //       JavaDocHTMLFile, the HTML-Signature is used to do the parsing for these
            //       Java "Auto-Generated" entities.

            int line = signatureLineNumber.get().line;
            this.signatureLineNumber = (line != 1) ? line : -1;
        }


        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        // JavaDocHTML passes null to this parameter for AnnotationElem and for EnumConstant.
        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        //
        // It doesn't build a JavaParser class

        if ((jdComment == null) || (! jdComment.isPresent()))
        {
            this.jdComment          = null;
            this.jdStartLineNumber  = -1;
            this.jdEndLineNumber    = -1;
        }
        else
        {
            JavadocComment jdCommentJP = jdComment.get();

            this.jdComment = jdCommentJP.toString();

            Optional<Range> jdRangeOPT = jdCommentJP.getRange();

            // This is "doubt" in the JavaParser stuff.  I cannot see why this would ever return
            // null, but I don't know JP that well, so I'm leaving this here.  It seems extremely
            // supefluous to question whether the "Optional" itself might be null.

            Range range = (jdRangeOPT == null)
                ? null
                : (jdRangeOPT.isPresent() ? jdRangeOPT.get() : null);

            this.jdStartLineNumber  = (range == null) ? -1 : range.begin.line;
            this.jdEndLineNumber    = (range == null) ? -1 : range.end.line;

            /*
            // The Constructor.equals(other) wasn't working, now it is.  Leave this here, since
            // adding the line-numbers is a relatively new thing.

            if (entity == Entity.CONSTRUCTOR)
            {
                System.out.println("jdComment: " + range.toString());
                System.out.println("jdstart: " + this.jdStartLineNumber + ",\tjdend: " +
                    this.jdEndLineNumber + ",\tsigLine: " + this.signatureLineNumber);
            }
            */
        }


        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        // Build String-Arrays
        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

        this.annotations = (annotations.size() > 0)
            ? new String[annotations.size()]
            : StringParse.EMPTY_STR_ARRAY;

        this.modifiers = (modifiers.size() > 0)
            ? new String[modifiers.size()]
            : StringParse.EMPTY_STR_ARRAY;

        int i;


        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        // Fill the String-Arrays
        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

        i=0;
        for (AnnotationExpr ae : annotations)
            this.annotations[i++] =
                LexicalPreservingPrinter.print(LexicalPreservingPrinter.setup(ae)).trim();

        i=0;
        for (Modifier m : modifiers) this.modifiers[i++] = m.toString().trim();
    }


    // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    // private constructor, used by subclasses' clone method
    // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

    Declaration(Declaration other)
    {
        this.id                     = other.id;
        this.annotations            = other.annotations.clone();
        this.modifiers              = other.modifiers.clone();
        this.name                   = other.name;
        this.signature              = other.signature;
        this.jdComment              = other.jdComment;
        this.entity                 = other.entity;
        this.signatureLineNumber    = other.signatureLineNumber;
        this.jdStartLineNumber      = other.jdStartLineNumber;
        this.jdEndLineNumber        = other.jdEndLineNumber;
        this.codeHiLiteString       = other.codeHiLiteString;
    }


    // ********************************************************************************************
    // ********************************************************************************************
    // HELPERS - toString(int flags)
    // ********************************************************************************************
    // ********************************************************************************************


    Torello.Java.Additional.Ret2<Boolean, Boolean> jowFlags(int flags)
    {
        boolean onlyJOW         = (flags & JOW_INSTEAD) > 0;
        boolean addJOW          = (flags & JOW_ALSO) > 0;

        // "onlyJOW" has a higher FLAG-PRECEDENCY
        if (onlyJOW && addJOW) addJOW = false;

        return new Torello.Java.Additional.Ret2<>(addJOW, onlyJOW);
    }

    String printedName(String entity, int numSpaces, boolean color)
    {
        return
            StringParse.rightSpacePad(entity + " Name:", numSpaces) +
            "[" + (color ? BCYAN : "") + name + (color ? RESET : "") + "]\n";
    }

    String printedSignature(int numSpaces, boolean color)
    {
        return
            StringParse.rightSpacePad("Signature:", numSpaces) +
            "[" + (color ? BYELLOW : "") +
            StringParse.abbrevEndRDSF(signature, MAX_STR_LEN, true) +
            (color ? RESET : "") + "]\n";
    }

    String printedDeclaration(int numSpaces, boolean color)
    {
        return
            StringParse.rightSpacePad("Declaration:", numSpaces) +
            "[" + (color ? BYELLOW : "") +
            StringParse.abbrevEndRDSF(signature, MAX_STR_LEN, true) +
            (color ? RESET : "") + "]\n";
    }

    String printedModifiers(int numSpaces)
    {
        return
            StringParse.rightSpacePad("Modifiers:", numSpaces) +
            "[" + StrCSV.toCSV(modifiers, true, true, null) + "]\n";
    }

    String printedLineNumbers(int numSpaces, boolean color)
    {
        return 
            StringParse.rightSpacePad("Line Numbers:", numSpaces) + "[" +

            "sig=" +        (color ? BRED : "") + signatureLineNumber +
                (color ? RESET : "") + ", " +
            "jdStart=" +    (color ? BRED : "") + jdStartLineNumber +
                (color ? RESET : "") + ", " +
            "jdEnd=" +      (color ? BRED : "") + jdEndLineNumber +
                (color ? RESET : "") + "]";
    }

    String printedComments(int numSpaces, boolean color, boolean comments)
    {
        if (! comments)
            return "";

        else if (jdComment == null) return
            "\n" +
            StringParse.rightSpacePad("JD Comments:", numSpaces) +
            (color ? BRED : "") + "None Available / Not Included" + (color ? RESET : "");

        else return
            "\n" +
            StringParse.rightSpacePad("JD Comments:", numSpaces) +
            "[" +
            (color ? BGREEN : "") +
            StringParse.abbrevEndRDSF(jdComment, MAX_STR_LEN, true) +
            (color ? RESET : "") +
            "]";
    }

    /**
     * Dummy Method.  Overriden by Concrete Sub-Classes.
     * @see Method#toString()
     * @see Field#toString()
     * @see Constructor#toString()
     */
    public String toString()
    { return "Declaration is Abstract, all Concrete Sub-Classes Override this method."; }

    /**
     * Dummy Method.  Overriden by Concrete Sub-Classes.
     * @see Method#toString(int)
     * @see Field#toString(int)
     * @see Constructor#toString(int)
     */
    public String toString(int flags)
    { return "Declaration is Abstract, all Concrete Sub-Classes Override this method."; }


    // ********************************************************************************************
    // ********************************************************************************************
    // HELPERS
    // ********************************************************************************************
    // ********************************************************************************************


    /**
     * This removes the package information from a {@code String[]} array of class-names or
     * interface-names.
     * 
     * @param types This input {@code String[]} array should be a list of the input-parameter
     * 'types' to a {@code method} or {@code constructor}.  It may be any list of class/interface
     * {@code String's}.
     * 
     * @return This will return a parallel array that contains the same classes or interfaces, but
     * any of the input {@code String's} that contained full-package names will have had the
     * package part of the name stripped out.  For parameter-types in the original array that did
     * not have package-information the original {@code String} will be returned.
     */
    static String[] REMOVE_PACKAGE_INFORMATION(String[] types)
    {
        String[] ret = new String[types.length];

        for (int i=0; i < types.length; i++)

            ret[i] = types[i].contains(".")
                ? StringParse.PACKAGE_NAME.matcher(types[i]).replaceAll("")
                : types[i];

        return ret;
    }

    /**
     * This removes the package information from a single class or interface name.
     *
     * @param type This lone input {@code String}-parameter should contain a single class or
     * interface name that includes the full package name.
     *
     * @return This will return a single {@code String} that is identical to the input-type, but
     * has had the full package-name removed - if it had full-package details in the first place.
     * If there were no package-name {@code String's} as substrings of the input, the original
     * {@code String} will be returned.
     */
    static String REMOVE_PACKAGE_INFORMATION(String type)
    { return type.contains(".") ? StringParse.PACKAGE_NAME.matcher(type).replaceAll("") : type; }
}