Class LocalizationHelper
- java.lang.Object
-
- com.martynenko.anton.university.i18n.LocalizationHelper
-
@Component public class LocalizationHelper extends java.lang.ObjectComponent to work with string resources . Current realization use only one source file but can be extended with Locale options and new files with messages-{locale}.properties files.- Since:
- 1.1
- Author:
- Martynenko Anton
-
-
Constructor Summary
Constructors Constructor Description LocalizationHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Optional<java.lang.String>extract(java.lang.String extractFrom, MessageCode messageCode)Get regex pattern string as resource by provided code, then extract value from provided text fragment .java.lang.StringgetMessage(MessageCode messageCode)Get string resource by provided code.
-
-
-
Method Detail
-
getMessage
@NotNull public java.lang.String getMessage(@NotNull MessageCode messageCode) throws org.springframework.context.NoSuchMessageExceptionGet string resource by provided code.- Parameters:
messageCode-MessageCodeenumeration- Returns:
- String resource
- Throws:
org.springframework.context.NoSuchMessageException- if no resource with provided code
-
extract
@NotNull public java.util.Optional<java.lang.String> extract(@NotNull java.lang.String extractFrom, @NotNull MessageCode messageCode) throws java.util.NoSuchElementExceptionGet regex pattern string as resource by provided code, then extract value from provided text fragment .- Parameters:
extractFrom- string fragment, containing value which could be extracted using patternmessageCode-MessageCodeenumeration- Returns:
- String value or null
- Throws:
java.util.NoSuchElementException
-
-