Skip to content

Content of file PreferencesHandler.java.html

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>PreferencesHandler.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">SteelBlue - JavaFX Bindings</a> &gt; <a href="index.source.html" class="el_package">it.tidalwave.util</a> &gt; <span class="el_source">PreferencesHandler.java</span></div><h1>PreferencesHandler.java</h1><pre class="source lang-java linenums">/*
 * *********************************************************************************************************************
 *
 * SteelBlue: DCI User Interfaces
 * http://tidalwave.it/projects/steelblue
 *
 * Copyright (C) 2015 - 2021 by Tidalwave s.a.s. (http://tidalwave.it)
 *
 * *********************************************************************************************************************
 *
 * Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations under the License.
 *
 * *********************************************************************************************************************
 *
 * git clone https://bitbucket.org/tidalwave/steelblue-src
 * git clone https://github.com/tidalwave-it/steelblue-src
 *
 * *********************************************************************************************************************
 */
package it.tidalwave.util;

import javax.annotation.Nonnull;
import java.nio.file.Path;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicReference;
import it.tidalwave.util.impl.DefaultPreferencesHandler;

/***********************************************************************************************************************
 *
 * @author  Fabrizio Giudici
 *
 **********************************************************************************************************************/
public interface PreferencesHandler
  {
<span class="nc" id="L42">    public static final String PROP_APP_NAME = PreferencesHandler.class.getPackage().getName() + &quot;.appName&quot;;</span>

    // FIXME: make private as soon as the right Java version is required
make private as soon as the right Java version is required
public static final String __BASE_NAME = &quot;it.tidalwave.javafx&quot;; <span class="nc" id="L46"> public static AtomicReference&lt;PreferencesHandler&gt; __INSTANCE = new AtomicReference&lt;&gt;();</span> /** A property representing the initial main window size as a percentual of the screen size. */ <span class="nc" id="L49"> public static final Key&lt;Double&gt; KEY_INITIAL_SIZE = Key.of(__BASE_NAME + &quot;.initialSize&quot;, Double.class);</span> /** Whether the application should start at full screen. */ <span class="nc" id="L52"> public static final Key&lt;Boolean&gt; KEY_FULL_SCREEN = Key.of(__BASE_NAME + &quot;.fullScreen&quot;, Boolean.class);</span> @Nonnull public Path getAppFolder(); @Nonnull public Path getLogFolder(); /******************************************************************************************************************* * * Sets the application name. This method must be called at boot from the {@code main} method before doing * anything else. * * @param name the property name * ******************************************************************************************************************/ public static void setAppName (@Nonnull final String name) { <span class="nc" id="L70"> System.setProperty(PROP_APP_NAME, name);</span> <span class="nc" id="L71"> }</span> /******************************************************************************************************************* * * Gets a property. * * @param &lt;T&gt; the property type * @param name the property name * @return the property value * ******************************************************************************************************************/ @Nonnull public &lt;T&gt; Optional&lt;T&gt; getProperty (@Nonnull Key&lt;T&gt; name); /******************************************************************************************************************* * * Sets a property, overriding the current value. * * @param &lt;T&gt; the property type * @param name the property name * @param value the property value * @return the property value * ******************************************************************************************************************/ public &lt;T&gt; void setProperty (@Nonnull final Key&lt;T&gt; name, @Nonnull final T value); /** * * Sets a property, unless it has been already set. * * @param &lt;T&gt; the property type * @param name the property name * @param value the property value * @return the property value * ******************************************************************************************************************/ public &lt;T&gt; void setDefaultProperty (@Nonnull final Key&lt;T&gt; name, @Nonnull final T value); /******************************************************************************************************************* * * main() probably needs it and dI has not booted yet, so this class can be accessed also by this factory * method. Note that Spring instantiates the bean by calling this method, so we really have a singleton. * ******************************************************************************************************************/ @Nonnull public static PreferencesHandler getInstance() { <span class="nc" id="L118"> synchronized (PreferencesHandler.class)</span> { <span class="nc bnc" id="L120" title="All 2 branches missed."> if (__INSTANCE.get() == null)</span> { <span class="nc" id="L122"> __INSTANCE.set(new DefaultPreferencesHandler());</span> } <span class="nc" id="L125"> return __INSTANCE.get();</span> } } } </pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.7.202105040129</span></div></body></html>