All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.phloc.json.impl.JSONSettings Maven / Gradle / Ivy

There is a newer version: 4.2.2
Show newest version
package com.phloc.json.impl;

/**
 * JSONSettings let you steer certain behavior globally
 * 
 * @author Boris Gregorcic
 */
public class JSONSettings
{
  private static final class SingletonHolder
  {
    /**
     * The singleton instance
     */
    public static final JSONSettings INSTANCE = new JSONSettings ();
  }

  public static final boolean DEFAULT_PARSE_NULL_VALUES = false;
  public static final boolean DEFAULT_CLONE_PROPERTIES = true;

  private boolean m_bParseNullValues;
  private boolean m_bCloneProperties = DEFAULT_CLONE_PROPERTIES;

  /**
   * Ctor for singleton creation
   */
  protected JSONSettings ()
  {
    this.m_bParseNullValues = DEFAULT_PARSE_NULL_VALUES;
  }

  /**
   * Ctor
   * 
   * @return the singleton instance
   */
  public static JSONSettings getInstance ()
  {
    return SingletonHolder.INSTANCE;
  }

  public void setParseNullValues (final boolean bParseNull)
  {
    this.m_bParseNullValues = bParseNull;
  }

  public boolean isParseNullValues ()
  {
    return this.m_bParseNullValues;
  }

  /**
   * Defines whether or not cloning is used when assigning properties and values
   * in order to avoid side effects between read and set values
   * 
   * @param bCloneProperties
   *        true if cloning is used or false
   *        otherwise. The default is true
   */
  public void setCloneProperties (final boolean bCloneProperties)
  {
    this.m_bCloneProperties = bCloneProperties;
  }

  /**
   * This tells you whether or not cloning is used when assigning properties and
   * values in order to avoid side effects between read and set values
   * 
   * @return true if cloning is used or false
   *         otherwise. The default is true but this can be changed
   *         at runtime
   */
  public boolean isCloneProperties ()
  {
    return this.m_bCloneProperties;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy