How the preferences is implemented?

Hello everyone.
I am trying to implement a infrastructure program for missing parts in groovy programs to make them work without any hardware or… Therefore, I can compile them and generate the groovy byte code for some further needs.
I am just not sure how the preferences method is implemented? Is it implemented as a method with closure as it input? How it is going to work? Is there any access to the implementation of the methods like preferences? Can anyone help?

This is a example of preferences method in good-night-house.groovy program:

preferences {
section(“When I touch the app turn these lights off…”){
input “switchesoff”, “capability.switch”, multiple: true, required:true
section(“When I touch the app turn these lights on…”){
input “switcheson”, “capability.switch”, multiple: true, required:false
section(“Lock theses locks…”) {
input “lock1”,“capability.lock”, multiple: true
section(“And change to this mode…”) {
input “newMode”, “mode”, title: “Mode?”
section(“After so many seconds (optional)”){
input “waitfor”, “number”, title: “Off after (default 120)”, required: true