001package Torello.Browser.BrowserAPI;
002
003import java.util.*;
004import javax.json.*;
005import javax.json.stream.*;
006import java.io.*;
007
008import java.lang.reflect.Method;
009import java.lang.reflect.Parameter;
010import java.util.function.Function;
011
012import Torello.Browser.BrowserEvent;
013import Torello.Browser.JavaScriptAPI.*;
014import Torello.Browser.helper.*;
015
016import Torello.Java.Additional.*;
017import Torello.Java.JSON.*;
018
019import static Torello.Java.JSON.JFlag.*;
020
021import Torello.Java.StrCmpr;
022import Torello.JavaDoc.StaticFunctional;
023import Torello.JavaDoc.JDHeaderBackgroundImg;
024import Torello.JavaDoc.Excuse;
025
026/**
027 * <SPAN CLASS=COPIEDJDK><B>Defines commands and events for Autofill.</B></SPAN>
028 * 
029 * <EMBED CLASS='external-html' DATA-FILE-ID=CODE_GEN_NOTE>
030 */
031@StaticFunctional(Excused={"counter"}, Excuses={Excuse.CONFIGURATION})
032@JDHeaderBackgroundImg(EmbedTagFileID="WOOD_PLANK_NOTE")
033public class Autofill
034{
035    // ********************************************************************************************
036    // ********************************************************************************************
037    // Class Header Stuff
038    // ********************************************************************************************
039    // ********************************************************************************************
040
041
042    // No Pubic Constructors
043    private Autofill () { }
044
045    // These two Vector's are used by all the "Methods" exported by this class.  java.lang.reflect
046    // is used to generate the JSON String's.  It saves thousands of lines of Auto-Generated Code.
047    private static final Map<String, Vector<String>>    parameterNames = new HashMap<>();
048    private static final Map<String, Vector<Class<?>>>  parameterTypes = new HashMap<>();
049
050    // Some Methods do not take any parameters - for instance all the "enable()" and "disable()"
051    // I simply could not get ride of RAW-TYPES and UNCHECKED warnings... so there are now,
052    // offically, two empty-vectors.  One for String's, and the other for Classes.
053
054    private static final Vector<String>     EMPTY_VEC_STR = new Vector<>();
055    private static final Vector<Class<?>>   EMPTY_VEC_CLASS = new Vector<>();
056
057    static
058    {
059        for (Method m : Autofill.class.getMethods())
060        {
061            // This doesn't work!  The parameter names are all "arg0" ... "argN"
062            // It works for java.lang.reflect.Field, BUT NOT java.lang.reflect.Parameter!
063            //
064            // Vector<String> parameterNamesList = new Vector<>(); -- NOPE!
065
066            Vector<Class<?>> parameterTypesList = new Vector<>();
067        
068            for (Parameter p : m.getParameters()) parameterTypesList.add(p.getType());
069
070            parameterTypes.put(
071                m.getName(),
072                (parameterTypesList.size() > 0) ? parameterTypesList : EMPTY_VEC_CLASS
073            );
074        }
075    }
076
077    static
078    {
079        Vector<String> v = null;
080
081        v = new Vector<String>(3);
082        parameterNames.put("trigger", v);
083        Collections.addAll(v, new String[]
084        { "fieldId", "frameId", "card", });
085
086        v = new Vector<String>(1);
087        parameterNames.put("setAddresses", v);
088        Collections.addAll(v, new String[]
089        { "addresses", });
090
091        parameterNames.put("disable", EMPTY_VEC_STR);
092
093        parameterNames.put("enable", EMPTY_VEC_STR);
094    }
095
096
097    // ********************************************************************************************
098    // ********************************************************************************************
099    // Types - Static Inner Classes
100    // ********************************************************************************************
101    // ********************************************************************************************
102
103    /** Specified whether a filled field was done so by using the html autocomplete attribute or autofill heuristics. */
104    public static final String[] FillingStrategy =
105    { "autocompleteAttribute", "autofillInferred", };
106    
107    /** <CODE>[No Description Provided by Google]</CODE> */
108    public static class CreditCard
109        extends BaseType
110        implements java.io.Serializable
111    {
112        /** For Object Serialization.  java.io.Serializable */
113        protected static final long serialVersionUID = 1;
114        
115        public boolean[] optionals()
116        { return new boolean[] { false, false, false, false, false, }; }
117        
118        /** 16-digit credit card number. */
119        public final String number;
120        
121        /** Name of the credit card owner. */
122        public final String name;
123        
124        /** 2-digit expiry month. */
125        public final String expiryMonth;
126        
127        /** 4-digit expiry year. */
128        public final String expiryYear;
129        
130        /** 3-digit card verification code. */
131        public final String cvc;
132        
133        /**
134         * Constructor
135         *
136         * @param number 16-digit credit card number.
137         * 
138         * @param name Name of the credit card owner.
139         * 
140         * @param expiryMonth 2-digit expiry month.
141         * 
142         * @param expiryYear 4-digit expiry year.
143         * 
144         * @param cvc 3-digit card verification code.
145         */
146        public CreditCard
147            (String number, String name, String expiryMonth, String expiryYear, String cvc)
148        {
149            // Exception-Check(s) to ensure that if any parameters which are not declared as
150            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
151            
152            if (number == null)      THROWS.throwNPE("number");
153            if (name == null)        THROWS.throwNPE("name");
154            if (expiryMonth == null) THROWS.throwNPE("expiryMonth");
155            if (expiryYear == null)  THROWS.throwNPE("expiryYear");
156            if (cvc == null)         THROWS.throwNPE("cvc");
157            
158            this.number       = number;
159            this.name         = name;
160            this.expiryMonth  = expiryMonth;
161            this.expiryYear   = expiryYear;
162            this.cvc          = cvc;
163        }
164        
165        /**
166         * JSON Object Constructor
167         * @param jo A Json-Object having data about an instance of {@code 'CreditCard'}.
168         */
169        public CreditCard (JsonObject jo)
170        {
171            this.number       = ReadJSON.getString(jo, "number", false, true);
172            this.name         = ReadJSON.getString(jo, "name", false, true);
173            this.expiryMonth  = ReadJSON.getString(jo, "expiryMonth", false, true);
174            this.expiryYear   = ReadJSON.getString(jo, "expiryYear", false, true);
175            this.cvc          = ReadJSON.getString(jo, "cvc", false, true);
176        }
177        
178        
179        /** Checks whether {@code 'this'} equals an input Java-{@code Object} */
180        public boolean equals(Object other)
181        {
182            if (this == other)                       return true;
183            if (other == null)                       return false;
184            if (other.getClass() != this.getClass()) return false;
185        
186            CreditCard o = (CreditCard) other;
187        
188            return
189                    Objects.equals(this.number, o.number)
190                &&  Objects.equals(this.name, o.name)
191                &&  Objects.equals(this.expiryMonth, o.expiryMonth)
192                &&  Objects.equals(this.expiryYear, o.expiryYear)
193                &&  Objects.equals(this.cvc, o.cvc);
194        }
195        
196        /** Generates a Hash-Code for {@code 'this'} instance */
197        public int hashCode()
198        {
199            return
200                    Objects.hashCode(this.number)
201                +   Objects.hashCode(this.name)
202                +   Objects.hashCode(this.expiryMonth)
203                +   Objects.hashCode(this.expiryYear)
204                +   Objects.hashCode(this.cvc);
205        }
206    }
207    
208    /** <CODE>[No Description Provided by Google]</CODE> */
209    public static class AddressField
210        extends BaseType
211        implements java.io.Serializable
212    {
213        /** For Object Serialization.  java.io.Serializable */
214        protected static final long serialVersionUID = 1;
215        
216        public boolean[] optionals()
217        { return new boolean[] { false, false, }; }
218        
219        /** address field name, for example GIVEN_NAME. */
220        public final String name;
221        
222        /** address field value, for example Jon Doe. */
223        public final String value;
224        
225        /**
226         * Constructor
227         *
228         * @param name address field name, for example GIVEN_NAME.
229         * 
230         * @param value address field value, for example Jon Doe.
231         */
232        public AddressField(String name, String value)
233        {
234            // Exception-Check(s) to ensure that if any parameters which are not declared as
235            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
236            
237            if (name == null)  THROWS.throwNPE("name");
238            if (value == null) THROWS.throwNPE("value");
239            
240            this.name   = name;
241            this.value  = value;
242        }
243        
244        /**
245         * JSON Object Constructor
246         * @param jo A Json-Object having data about an instance of {@code 'AddressField'}.
247         */
248        public AddressField (JsonObject jo)
249        {
250            this.name   = ReadJSON.getString(jo, "name", false, true);
251            this.value  = ReadJSON.getString(jo, "value", false, true);
252        }
253        
254        
255        /** Checks whether {@code 'this'} equals an input Java-{@code Object} */
256        public boolean equals(Object other)
257        {
258            if (this == other)                       return true;
259            if (other == null)                       return false;
260            if (other.getClass() != this.getClass()) return false;
261        
262            AddressField o = (AddressField) other;
263        
264            return
265                    Objects.equals(this.name, o.name)
266                &&  Objects.equals(this.value, o.value);
267        }
268        
269        /** Generates a Hash-Code for {@code 'this'} instance */
270        public int hashCode()
271        {
272            return
273                    Objects.hashCode(this.name)
274                +   Objects.hashCode(this.value);
275        }
276    }
277    
278    /** A list of address fields. */
279    public static class AddressFields
280        extends BaseType
281        implements java.io.Serializable
282    {
283        /** For Object Serialization.  java.io.Serializable */
284        protected static final long serialVersionUID = 1;
285        
286        public boolean[] optionals()
287        { return new boolean[] { false, }; }
288        
289        /** <CODE>[No Description Provided by Google]</CODE> */
290        public final Autofill.AddressField[] fields;
291        
292        /**
293         * Constructor
294         *
295         * @param fields -
296         */
297        public AddressFields(Autofill.AddressField[] fields)
298        {
299            // Exception-Check(s) to ensure that if any parameters which are not declared as
300            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
301            
302            if (fields == null) THROWS.throwNPE("fields");
303            
304            this.fields  = fields;
305        }
306        
307        /**
308         * JSON Object Constructor
309         * @param jo A Json-Object having data about an instance of {@code 'AddressFields'}.
310         */
311        public AddressFields (JsonObject jo)
312        {
313            this.fields = (jo.getJsonArray("fields") == null)
314                ? null
315                : RJArrIntoStream.objArr(jo.getJsonArray("fields"), null, 0, Autofill.AddressField.class).toArray(Autofill.AddressField[]::new);
316        
317        }
318        
319        
320        /** Checks whether {@code 'this'} equals an input Java-{@code Object} */
321        public boolean equals(Object other)
322        {
323            if (this == other)                       return true;
324            if (other == null)                       return false;
325            if (other.getClass() != this.getClass()) return false;
326        
327            AddressFields o = (AddressFields) other;
328        
329            return
330                    Arrays.deepEquals(this.fields, o.fields);
331        }
332        
333        /** Generates a Hash-Code for {@code 'this'} instance */
334        public int hashCode()
335        {
336            return
337                    Arrays.deepHashCode(this.fields);
338        }
339    }
340    
341    /** <CODE>[No Description Provided by Google]</CODE> */
342    public static class Address
343        extends BaseType
344        implements java.io.Serializable
345    {
346        /** For Object Serialization.  java.io.Serializable */
347        protected static final long serialVersionUID = 1;
348        
349        public boolean[] optionals()
350        { return new boolean[] { false, }; }
351        
352        /** fields and values defining an address. */
353        public final Autofill.AddressField[] fields;
354        
355        /**
356         * Constructor
357         *
358         * @param fields fields and values defining an address.
359         */
360        public Address(Autofill.AddressField[] fields)
361        {
362            // Exception-Check(s) to ensure that if any parameters which are not declared as
363            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
364            
365            if (fields == null) THROWS.throwNPE("fields");
366            
367            this.fields  = fields;
368        }
369        
370        /**
371         * JSON Object Constructor
372         * @param jo A Json-Object having data about an instance of {@code 'Address'}.
373         */
374        public Address (JsonObject jo)
375        {
376            this.fields = (jo.getJsonArray("fields") == null)
377                ? null
378                : RJArrIntoStream.objArr(jo.getJsonArray("fields"), null, 0, Autofill.AddressField.class).toArray(Autofill.AddressField[]::new);
379        
380        }
381        
382        
383        /** Checks whether {@code 'this'} equals an input Java-{@code Object} */
384        public boolean equals(Object other)
385        {
386            if (this == other)                       return true;
387            if (other == null)                       return false;
388            if (other.getClass() != this.getClass()) return false;
389        
390            Address o = (Address) other;
391        
392            return
393                    Arrays.deepEquals(this.fields, o.fields);
394        }
395        
396        /** Generates a Hash-Code for {@code 'this'} instance */
397        public int hashCode()
398        {
399            return
400                    Arrays.deepHashCode(this.fields);
401        }
402    }
403    
404    /**
405     * Defines how an address can be displayed like in chrome://settings/addresses.
406     * Address UI is a two dimensional array, each inner array is an "address information line", and when rendered in a UI surface should be displayed as such.
407     * The following address UI for instance:
408     * [[{name: "GIVE_NAME", value: "Jon"}, {name: "FAMILY_NAME", value: "Doe"}], [{name: "CITY", value: "Munich"}, {name: "ZIP", value: "81456"}]]
409     * should allow the receiver to render:
410     * Jon Doe
411     * Munich 81456
412     */
413    public static class AddressUI
414        extends BaseType
415        implements java.io.Serializable
416    {
417        /** For Object Serialization.  java.io.Serializable */
418        protected static final long serialVersionUID = 1;
419        
420        public boolean[] optionals()
421        { return new boolean[] { false, }; }
422        
423        /** A two dimension array containing the representation of values from an address profile. */
424        public final Autofill.AddressFields[] addressFields;
425        
426        /**
427         * Constructor
428         *
429         * @param addressFields A two dimension array containing the representation of values from an address profile.
430         */
431        public AddressUI(Autofill.AddressFields[] addressFields)
432        {
433            // Exception-Check(s) to ensure that if any parameters which are not declared as
434            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
435            
436            if (addressFields == null) THROWS.throwNPE("addressFields");
437            
438            this.addressFields  = addressFields;
439        }
440        
441        /**
442         * JSON Object Constructor
443         * @param jo A Json-Object having data about an instance of {@code 'AddressUI'}.
444         */
445        public AddressUI (JsonObject jo)
446        {
447            this.addressFields = (jo.getJsonArray("addressFields") == null)
448                ? null
449                : RJArrIntoStream.objArr(jo.getJsonArray("addressFields"), null, 0, Autofill.AddressFields.class).toArray(Autofill.AddressFields[]::new);
450        
451        }
452        
453        
454        /** Checks whether {@code 'this'} equals an input Java-{@code Object} */
455        public boolean equals(Object other)
456        {
457            if (this == other)                       return true;
458            if (other == null)                       return false;
459            if (other.getClass() != this.getClass()) return false;
460        
461            AddressUI o = (AddressUI) other;
462        
463            return
464                    Arrays.deepEquals(this.addressFields, o.addressFields);
465        }
466        
467        /** Generates a Hash-Code for {@code 'this'} instance */
468        public int hashCode()
469        {
470            return
471                    Arrays.deepHashCode(this.addressFields);
472        }
473    }
474    
475    /** <CODE>[No Description Provided by Google]</CODE> */
476    public static class FilledField
477        extends BaseType
478        implements java.io.Serializable
479    {
480        /** For Object Serialization.  java.io.Serializable */
481        protected static final long serialVersionUID = 1;
482        
483        public boolean[] optionals()
484        { return new boolean[] { false, false, false, false, false, false, false, false, }; }
485        
486        /** The type of the field, e.g text, password etc. */
487        public final String htmlType;
488        
489        /** the html id */
490        public final String id;
491        
492        /** the html name */
493        public final String name;
494        
495        /** the field value */
496        public final String value;
497        
498        /** The actual field type, e.g FAMILY_NAME */
499        public final String autofillType;
500        
501        /** The filling strategy */
502        public final String fillingStrategy;
503        
504        /** The frame the field belongs to */
505        public final String frameId;
506        
507        /** The form field's DOM node */
508        public final int fieldId;
509        
510        /**
511         * Constructor
512         *
513         * @param htmlType The type of the field, e.g text, password etc.
514         * 
515         * @param id the html id
516         * 
517         * @param name the html name
518         * 
519         * @param value the field value
520         * 
521         * @param autofillType The actual field type, e.g FAMILY_NAME
522         * 
523         * @param fillingStrategy The filling strategy
524         * 
525         * @param frameId The frame the field belongs to
526         * 
527         * @param fieldId The form field's DOM node
528         */
529        public FilledField(
530                String htmlType, String id, String name, String value, String autofillType, 
531                String fillingStrategy, String frameId, int fieldId
532            )
533        {
534            // Exception-Check(s) to ensure that if any parameters which are not declared as
535            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
536            
537            if (htmlType == null)        THROWS.throwNPE("htmlType");
538            if (id == null)              THROWS.throwNPE("id");
539            if (name == null)            THROWS.throwNPE("name");
540            if (value == null)           THROWS.throwNPE("value");
541            if (autofillType == null)    THROWS.throwNPE("autofillType");
542            if (fillingStrategy == null) THROWS.throwNPE("fillingStrategy");
543            if (frameId == null)         THROWS.throwNPE("frameId");
544            
545            // Exception-Check(s) to ensure that if any parameters which must adhere to a
546            // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw.
547            
548            THROWS.checkIAE("fillingStrategy", fillingStrategy, "Autofill.FillingStrategy", Autofill.FillingStrategy);
549            
550            this.htmlType         = htmlType;
551            this.id               = id;
552            this.name             = name;
553            this.value            = value;
554            this.autofillType     = autofillType;
555            this.fillingStrategy  = fillingStrategy;
556            this.frameId          = frameId;
557            this.fieldId          = fieldId;
558        }
559        
560        /**
561         * JSON Object Constructor
562         * @param jo A Json-Object having data about an instance of {@code 'FilledField'}.
563         */
564        public FilledField (JsonObject jo)
565        {
566            this.htmlType         = ReadJSON.getString(jo, "htmlType", false, true);
567            this.id               = ReadJSON.getString(jo, "id", false, true);
568            this.name             = ReadJSON.getString(jo, "name", false, true);
569            this.value            = ReadJSON.getString(jo, "value", false, true);
570            this.autofillType     = ReadJSON.getString(jo, "autofillType", false, true);
571            this.fillingStrategy  = ReadJSON.getString(jo, "fillingStrategy", false, true);
572            this.frameId          = ReadJSON.getString(jo, "frameId", false, true);
573            this.fieldId          = ReadPrimJSON.getInt(jo, "fieldId");
574        }
575        
576        
577        /** Checks whether {@code 'this'} equals an input Java-{@code Object} */
578        public boolean equals(Object other)
579        {
580            if (this == other)                       return true;
581            if (other == null)                       return false;
582            if (other.getClass() != this.getClass()) return false;
583        
584            FilledField o = (FilledField) other;
585        
586            return
587                    Objects.equals(this.htmlType, o.htmlType)
588                &&  Objects.equals(this.id, o.id)
589                &&  Objects.equals(this.name, o.name)
590                &&  Objects.equals(this.value, o.value)
591                &&  Objects.equals(this.autofillType, o.autofillType)
592                &&  Objects.equals(this.fillingStrategy, o.fillingStrategy)
593                &&  Objects.equals(this.frameId, o.frameId)
594                &&  Objects.equals(this.fieldId, o.fieldId);
595        }
596        
597        /** Generates a Hash-Code for {@code 'this'} instance */
598        public int hashCode()
599        {
600            return
601                    Objects.hashCode(this.htmlType)
602                +   Objects.hashCode(this.id)
603                +   Objects.hashCode(this.name)
604                +   Objects.hashCode(this.value)
605                +   Objects.hashCode(this.autofillType)
606                +   Objects.hashCode(this.fillingStrategy)
607                +   Objects.hashCode(this.frameId)
608                +   this.fieldId;
609        }
610    }
611    
612    /** Emitted when an address form is filled. */
613    public static class addressFormFilled
614        extends BrowserEvent
615        implements java.io.Serializable
616    {
617        /** For Object Serialization.  java.io.Serializable */
618        protected static final long serialVersionUID = 1;
619        
620        public boolean[] optionals()
621        { return new boolean[] { false, false, }; }
622        
623        /** Information about the fields that were filled */
624        public final Autofill.FilledField[] filledFields;
625        
626        /**
627         * An UI representation of the address used to fill the form.
628         * Consists of a 2D array where each child represents an address/profile line.
629         */
630        public final Autofill.AddressUI addressUi;
631        
632        /**
633         * Constructor
634         *
635         * @param filledFields Information about the fields that were filled
636         * 
637         * @param addressUi 
638         * An UI representation of the address used to fill the form.
639         * Consists of a 2D array where each child represents an address/profile line.
640         */
641        public addressFormFilled
642            (Autofill.FilledField[] filledFields, Autofill.AddressUI addressUi)
643        {
644            super("Autofill", "addressFormFilled", 2);
645            
646            // Exception-Check(s) to ensure that if any parameters which are not declared as
647            // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
648            
649            if (filledFields == null) THROWS.throwNPE("filledFields");
650            if (addressUi == null)    THROWS.throwNPE("addressUi");
651            
652            this.filledFields  = filledFields;
653            this.addressUi     = addressUi;
654        }
655        
656        /**
657         * JSON Object Constructor
658         * @param jo A Json-Object having data about an instance of {@code 'addressFormFilled'}.
659         */
660        public addressFormFilled (JsonObject jo)
661        {
662            super("Autofill", "addressFormFilled", 2);
663        
664            this.filledFields = (jo.getJsonArray("filledFields") == null)
665                ? null
666                : RJArrIntoStream.objArr(jo.getJsonArray("filledFields"), null, 0, Autofill.FilledField.class).toArray(Autofill.FilledField[]::new);
667        
668            this.addressUi     = ReadJSON.getObject(jo, "addressUi", Autofill.AddressUI.class, false, true);
669        }
670        
671        
672        /** Checks whether {@code 'this'} equals an input Java-{@code Object} */
673        public boolean equals(Object other)
674        {
675            if (this == other)                       return true;
676            if (other == null)                       return false;
677            if (other.getClass() != this.getClass()) return false;
678        
679            addressFormFilled o = (addressFormFilled) other;
680        
681            return
682                    Arrays.deepEquals(this.filledFields, o.filledFields)
683                &&  Objects.equals(this.addressUi, o.addressUi);
684        }
685        
686        /** Generates a Hash-Code for {@code 'this'} instance */
687        public int hashCode()
688        {
689            return
690                    Arrays.deepHashCode(this.filledFields)
691                +   this.addressUi.hashCode();
692        }
693    }
694    
695    
696    // Counter for keeping the WebSocket Request ID's distinct.
697    private static int counter = 1;
698    
699    /**
700     * Trigger autofill on a form identified by the fieldId.
701     * If the field and related form cannot be autofilled, returns an error.
702     * 
703     * @param fieldId Identifies a field that serves as an anchor for autofill.
704     * 
705     * @param frameId Identifies the frame that field belongs to.
706     * <BR /><B CLASS=Opt>OPTIONAL</B>
707     * 
708     * @param card Credit card information to fill out the form. Credit card data is not saved.
709     * 
710     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
711     * {@link Ret0}&gt;</CODE>
712     *
713     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
714     * browser receives the invocation-request.
715     *
716     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
717     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
718     * {@code >} to ensure the Browser Function has run to completion.
719     */
720    public static Script<String, JsonObject, Ret0> trigger
721        (int fieldId, String frameId, Autofill.CreditCard card)
722    {
723        // Exception-Check(s) to ensure that if any parameters which are not declared as
724        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
725        
726        if (card == null) THROWS.throwNPE("card");
727        
728        final int       webSocketID = 11000000 + counter++;
729        final boolean[] optionals   = { false, true, false, };
730        
731        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
732        String requestJSON = WriteJSON.get(
733            parameterTypes.get("trigger"),
734            parameterNames.get("trigger"),
735            optionals, webSocketID,
736            "Autofill.trigger",
737            fieldId, frameId, card
738        );
739        
740        // This Remote Command does not have a Return-Value.
741        return new Script<>
742            (webSocketID, requestJSON, VOID_RETURN.NoReturnValues);
743    }
744    
745    /**
746     * Set addresses so that developers can verify their forms implementation.
747     * 
748     * @param addresses -
749     * 
750     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
751     * {@link Ret0}&gt;</CODE>
752     *
753     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
754     * browser receives the invocation-request.
755     *
756     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
757     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
758     * {@code >} to ensure the Browser Function has run to completion.
759     */
760    public static Script<String, JsonObject, Ret0> setAddresses(Autofill.Address[] addresses)
761    {
762        // Exception-Check(s) to ensure that if any parameters which are not declared as
763        // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw.
764        
765        if (addresses == null) THROWS.throwNPE("addresses");
766        
767        final int       webSocketID = 11001000 + counter++;
768        final boolean[] optionals   = { false, };
769        
770        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
771        String requestJSON = WriteJSON.get(
772            parameterTypes.get("setAddresses"),
773            parameterNames.get("setAddresses"),
774            optionals, webSocketID,
775            "Autofill.setAddresses",
776            (Object) addresses
777        );
778        
779        // This Remote Command does not have a Return-Value.
780        return new Script<>
781            (webSocketID, requestJSON, VOID_RETURN.NoReturnValues);
782    }
783    
784    /**
785     * Disables autofill domain notifications.
786     * 
787     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
788     * {@link Ret0}&gt;</CODE>
789     *
790     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
791     * browser receives the invocation-request.
792     *
793     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
794     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
795     * {@code >} to ensure the Browser Function has run to completion.
796     */
797    public static Script<String, JsonObject, Ret0> disable()
798    {
799        final int          webSocketID = 11002000 + counter++;
800        final boolean[]    optionals   = new boolean[0];
801        
802        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
803        String requestJSON = WriteJSON.get(
804            parameterTypes.get("disable"),
805            parameterNames.get("disable"),
806            optionals, webSocketID,
807            "Autofill.disable"
808        );
809        
810        // This Remote Command does not have a Return-Value.
811        return new Script<>
812            (webSocketID, requestJSON, VOID_RETURN.NoReturnValues);
813    }
814    
815    /**
816     * Enables autofill domain notifications.
817     * 
818     * @return An instance of <CODE>{@link Script}&lt;String, {@link JsonObject},
819     * {@link Ret0}&gt;</CODE>
820     *
821     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
822     * browser receives the invocation-request.
823     *
824     * <BR /><BR />This Browser-Function <I>does not have</I> a return-value.  You may choose to
825     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0}
826     * {@code >} to ensure the Browser Function has run to completion.
827     */
828    public static Script<String, JsonObject, Ret0> enable()
829    {
830        final int          webSocketID = 11003000 + counter++;
831        final boolean[]    optionals   = new boolean[0];
832        
833        // Convert Method Parameters into JSON.  Build the JSON Request-Object (as a String)
834        String requestJSON = WriteJSON.get(
835            parameterTypes.get("enable"),
836            parameterNames.get("enable"),
837            optionals, webSocketID,
838            "Autofill.enable"
839        );
840        
841        // This Remote Command does not have a Return-Value.
842        return new Script<>
843            (webSocketID, requestJSON, VOID_RETURN.NoReturnValues);
844    }
845    
846}