class PreferencesUtils {

  public static <T> void save(Property<? extends T> property,
                              Preferences preferences,
                              Function<? super T, String> serializer) {
    T value = property.getValue();

    if (value == null) {
      throw new IllegalArgumentException("The property must have a value");
    }

    preferences.put(property.getName(), serializer.apply(value));
  }

  private  PreferencesUtils();

}