// Path: src/main/java/de/agilecoders/wicket/jquery/WicketJquerySelectors.java
// public final class WicketJquerySelectors {
//     private static final Logger LOG = LoggerFactory.getLogger("wicket-jquery-selectors");
// 
//     /**
//      * The {@link org.apache.wicket.MetaDataKey} used to retrieve the {@link de.agilecoders.wicket.jquery.settings.IWicketJquerySelectorsSettings}
//      * from the Wicket {@link Appendable}.
//      */
//     private static final MetaDataKey<IWicketJquerySelectorsSettings> JQUERY_SELECTORS_SETTINGS_METADATA_KEY = new MetaDataKey<IWicketJquerySelectorsSettings>() {
//     };
// 
//     /**
//      * Checks whether this library support is already installed
//      *
//      * @param application the wicket application
//      * @return {@code true} if library is already installed, otherwise {@code false}
//      */
//     public static boolean isInstalled(Application application) {
//         return application != null && application.getMetaData(JQUERY_SELECTORS_SETTINGS_METADATA_KEY) != null;
//     }
//     /**
//      * installs the library to given application
//      *
//      * @param app the wicket application
//      */
//     public static void install(final Application app) {
//         install(app, null);
//     }
// 
//     /**
//      * installs the library settings to given app.
//      *
//      * @param app      the wicket application
//      * @param settings the settings to use
//      */
//     public static void install(Application app, IWicketJquerySelectorsSettings settings) {
//         final IWicketJquerySelectorsSettings existingSettings = settings(app);
// 
//         if (existingSettings == null) {
//             if (settings == null) {
//                 settings = new WicketJquerySelectorsSettings();
//             }
// 
//             app.setMetaData(JQUERY_SELECTORS_SETTINGS_METADATA_KEY, settings);
// 
//             LOG.info("initialize wicket jquery selectors with given settings: {}", settings);
//         }
//     }
// 
//     /**
//      * returns the {@link IWicketJquerySelectorsSettings} which are assigned to given application
//      *
//      * @param app The current application
//      * @return assigned {@link IWicketJquerySelectorsSettings}
//      */
//     public static IWicketJquerySelectorsSettings settings(final Application app) {
//         return app.getMetaData(JQUERY_SELECTORS_SETTINGS_METADATA_KEY);
//     }
// 
//     /**
//      * returns the {@link IWicketJquerySelectorsSettings} which are assigned to given application or a new default instance.
//      *
//      * This is an internal API method, please don't use it.
//      *
//      * @return assigned {@link IWicketJquerySelectorsSettings}
//      */
//     public static IWicketJquerySelectorsSettings assignedSettingsOrDefault() {
//         Application app = Application.exists() ? Application.get() : null;
// 
//         if (isInstalled(app)) {
//             return settings();
//         } else {
//             LOG.info("try to get settings, but WicketJquerySelectors wasn't installed to current application. Fallback to default settings.");
// 
//             return new WicketJquerySelectorsSettings();
//         }
//     }
// 
//     /**
//      * returns the {@link IWicketJquerySelectorsSettings} which are assigned to current application
//      *
//      * @return assigned {@link IWicketJquerySelectorsSettings}
//      */
//     public static IWicketJquerySelectorsSettings settings() {
//         if (Application.exists()) {
//             final IWicketJquerySelectorsSettings settings = Application.get().getMetaData(JQUERY_SELECTORS_SETTINGS_METADATA_KEY);
// 
//             if (settings != null) {
//                 return settings;
//             } else {
//                 throw new IllegalStateException("you have to call WicketJquerySelectors.install()");
//             }
//         }
// 
//         throw new IllegalStateException("there is no active application assigned to this thread.");
//     }
// 
//     /**
//      * private constructor.
//      */
//     private WicketJquerySelectors() {
//         throw new UnsupportedOperationException();
//     }
// }
// 
// Path: src/main/java/de/agilecoders/wicket/jquery/settings/ObjectMapperFactory.java
// public interface ObjectMapperFactory {
// 
//     /**
//      * @return new object mapper instance
//      */
//     ObjectMapper newObjectMapper();
// }


import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import de.agilecoders.wicket.jquery.WicketJquerySelectors;
import de.agilecoders.wicket.jquery.settings.ObjectMapperFactory;
import org.apache.wicket.util.io.IClusterable;
import org.apache.wicket.util.lang.Args;
import org.apache.wicket.util.string.Strings;
package de.agilecoders.wicket.jquery.util;


/**
 * Helper functions to handle JsonNode values.
 *
 * @author miha
 */
public final class Json {

    /**
     * lazy holder to give application the chance to install its own
     */
    private static final class Holder {
// Path: src/main/java/de/agilecoders/wicket/jquery/WicketJquerySelectors.java
// public final class WicketJquerySelectors {
//     private static final Logger LOG = LoggerFactory.getLogger("wicket-jquery-selectors");
// 
//     /**
//      * The {@link org.apache.wicket.MetaDataKey} used to retrieve the {@link de.agilecoders.wicket.jquery.settings.IWicketJquerySelectorsSettings}
//      * from the Wicket {@link Appendable}.
//      */
//     private static final MetaDataKey<IWicketJquerySelectorsSettings> JQUERY_SELECTORS_SETTINGS_METADATA_KEY = new MetaDataKey<IWicketJquerySelectorsSettings>() {
//     };
// 
//     /**
//      * Checks whether this library support is already installed
//      *
//      * @param application the wicket application
//      * @return {@code true} if library is already installed, otherwise {@code false}
//      */
//     public static boolean isInstalled(Application application) {
//         return application != null && application.getMetaData(JQUERY_SELECTORS_SETTINGS_METADATA_KEY) != null;
//     }
//     /**
//      * installs the library to given application
//      *
//      * @param app the wicket application
//      */
//     public static void install(final Application app) {
//         install(app, null);
//     }
// 
//     /**
//      * installs the library settings to given app.
//      *
//      * @param app      the wicket application
//      * @param settings the settings to use
//      */
//     public static void install(Application app, IWicketJquerySelectorsSettings settings) {
//         final IWicketJquerySelectorsSettings existingSettings = settings(app);
// 
//         if (existingSettings == null) {
//             if (settings == null) {
//                 settings = new WicketJquerySelectorsSettings();
//             }
// 
//             app.setMetaData(JQUERY_SELECTORS_SETTINGS_METADATA_KEY, settings);
// 
//             LOG.info("initialize wicket jquery selectors with given settings: {}", settings);
//         }
//     }
// 
//     /**
//      * returns the {@link IWicketJquerySelectorsSettings} which are assigned to given application
//      *
//      * @param app The current application
//      * @return assigned {@link IWicketJquerySelectorsSettings}
//      */
//     public static IWicketJquerySelectorsSettings settings(final Application app) {
//         return app.getMetaData(JQUERY_SELECTORS_SETTINGS_METADATA_KEY);
//     }
// 
//     /**
//      * returns the {@link IWicketJquerySelectorsSettings} which are assigned to given application or a new default instance.
//      *
//      * This is an internal API method, please don't use it.
//      *
//      * @return assigned {@link IWicketJquerySelectorsSettings}
//      */
//     public static IWicketJquerySelectorsSettings assignedSettingsOrDefault() {
//         Application app = Application.exists() ? Application.get() : null;
// 
//         if (isInstalled(app)) {
//             return settings();
//         } else {
//             LOG.info("try to get settings, but WicketJquerySelectors wasn't installed to current application. Fallback to default settings.");
// 
//             return new WicketJquerySelectorsSettings();
//         }
//     }
// 
//     /**
//      * returns the {@link IWicketJquerySelectorsSettings} which are assigned to current application
//      *
//      * @return assigned {@link IWicketJquerySelectorsSettings}
//      */
//     public static IWicketJquerySelectorsSettings settings() {
//         if (Application.exists()) {
//             final IWicketJquerySelectorsSettings settings = Application.get().getMetaData(JQUERY_SELECTORS_SETTINGS_METADATA_KEY);
// 
//             if (settings != null) {
//                 return settings;
//             } else {
//                 throw new IllegalStateException("you have to call WicketJquerySelectors.install()");
//             }
//         }
// 
//         throw new IllegalStateException("there is no active application assigned to this thread.");
//     }
// 
//     /**
//      * private constructor.
//      */
//     private WicketJquerySelectors() {
//         throw new UnsupportedOperationException();
//     }
// }
// 
// Path: src/main/java/de/agilecoders/wicket/jquery/settings/ObjectMapperFactory.java
// public interface ObjectMapperFactory {
// 
//     /**
//      * @return new object mapper instance
//      */
//     ObjectMapper newObjectMapper();
// }


// Path: src/main/java/de/agilecoders/wicket/jquery/util/Json.java
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import de.agilecoders.wicket.jquery.WicketJquerySelectors;
import de.agilecoders.wicket.jquery.settings.ObjectMapperFactory;
import org.apache.wicket.util.io.IClusterable;
import org.apache.wicket.util.lang.Args;
import org.apache.wicket.util.string.Strings;

package de.agilecoders.wicket.jquery.util;


/**
 * Helper functions to handle JsonNode values.
 *
 * @author miha
 */
public final class Json {

    /**
     * lazy holder to give application the chance to install its own
     */
    private static final class Holder {
        private static final ObjectMapperFactory factory = WicketJquerySelectors.assignedSettingsOrDefault().getObjectMapperFactory();