-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactorings
- Loading branch information
Showing
30 changed files
with
428 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/main/kotlin/com/eny/i18n/plugin/key/parser/KeyParserBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.eny.i18n.plugin.key.parser | ||
|
||
import com.eny.i18n.plugin.key.lexer.NoTokenizer | ||
import com.eny.i18n.plugin.key.lexer.NormalizingTokenizer | ||
import com.eny.i18n.plugin.key.lexer.NsKeyTokenizer | ||
import com.eny.i18n.plugin.key.lexer.Tokenizer | ||
import com.eny.i18n.plugin.parser.DummyTextNormalizer | ||
import com.eny.i18n.plugin.parser.ExpressionNormalizer | ||
import com.eny.i18n.plugin.parser.KeyNormalizer | ||
|
||
/** | ||
* Builds Key parser by given options | ||
*/ | ||
class KeyParserBuilder private constructor (private val tokenizer: Tokenizer, private val normalizers: List<KeyNormalizer>) { | ||
|
||
/** | ||
* Builds one more step to KeyParser: adds dummy text normalizer | ||
*/ | ||
fun withDummyNormalizer(): KeyParserBuilder { | ||
return KeyParserBuilder(tokenizer, normalizers + DummyTextNormalizer()) | ||
} | ||
|
||
/** | ||
* Builds one more step to KeyParser: adds dummy text normalizer | ||
*/ | ||
fun withTemplateNormalizer(): KeyParserBuilder { | ||
return KeyParserBuilder(tokenizer, normalizers + ExpressionNormalizer()) | ||
} | ||
|
||
/** | ||
* Builds final KeyParser | ||
*/ | ||
fun build(): KeyParser = KeyParser(NormalizingTokenizer(tokenizer, normalizers)) | ||
|
||
companion object { | ||
/** | ||
* Builds one step of key parser: sets tokenizer with ns and key separators | ||
*/ | ||
fun withSeparators(ns: String, key: String): KeyParserBuilder { | ||
return KeyParserBuilder(NsKeyTokenizer(ns, key), listOf()) | ||
} | ||
|
||
/** | ||
* Builds one step of key parser: sets NoTokenizer | ||
*/ | ||
fun withoutTokenizer(): KeyParserBuilder { | ||
return KeyParserBuilder(NoTokenizer(), listOf()) | ||
} | ||
} | ||
} |
Oops, something went wrong.