class PreferencesUtils {

  public static <T> void read(Property<? super T> property,
                              Preferences preferences,
                              Function<String, ? extends T> parser) {
    String name = property.getName();

    String saved = preferences.get(name, null);
    if (saved != null) {
      try {
        property.setValue(parser.apply(saved));
      } catch (Exception ignore) { // NOPMD empty catch block
        // The saved value probably wasn't the expected type
        // No need to bubble the exception up
      }
    }
  }

  private  PreferencesUtils();

}