Package io.jmix.ui.settings
Class SettingsHelper
java.lang.Object
io.jmix.ui.settings.SettingsHelper
Utility class for working with component settings.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends ComponentSettings>
TcreateSettings
(Class<T> settingsClass) Creates instance of settings class.static <T extends ComponentSettings>
TcreateSettings
(Class<T> settingsClass, String id) Creates instance of settings class with provided id.static <T extends ComponentSettings>
TtoComponentSettings
(String settings, Class<T> settingsClass) Converts JSON string representation of settings to POJO.static String
toSettingsString
(ComponentSettings settings) Converts settings from POJO to JSON string representation.
-
Field Details
-
gson
protected static final com.google.gson.Gson gson
-
-
Method Details
-
createSettings
Creates instance of settings class.- Type Parameters:
T
- any settings class that extendsComponentSettings
- Parameters:
settingsClass
- class of component settings- Returns:
- instance of component settings
-
createSettings
public static <T extends ComponentSettings> T createSettings(Class<T> settingsClass, @Nullable String id) Creates instance of settings class with provided id.- Type Parameters:
T
- any settings class that extendsComponentSettings
- Parameters:
settingsClass
- class of component settingsid
- component id- Returns:
- instance of component settings
-
toComponentSettings
@Nullable public static <T extends ComponentSettings> T toComponentSettings(String settings, Class<T> settingsClass) Converts JSON string representation of settings to POJO.- Type Parameters:
T
- any settings class that extendsComponentSettings
- Parameters:
settings
- JSON string representation of settingssettingsClass
- POJO class of settings- Returns:
- instance of component settings
-
toSettingsString
Converts settings from POJO to JSON string representation.- Parameters:
settings
- component settings- Returns:
- JSON string representation of component settings
-