From ce913c18075fa3d97bff737ecb5b51d7c8f7631e Mon Sep 17 00:00:00 2001 From: Jakub Stejskal Date: Tue, 16 Jul 2024 15:15:05 +0200 Subject: [PATCH] Allow users to get ETemplateType based on String input (#22) ## Description Adds method that returns ETemplateType based on String value. ## Type of Change * New feature (non-breaking change which adds functionality) ## Checklist - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] My changes generate no new warnings Signed-off-by: Jakub Stejskal --- .../datagenerator/enums/ETemplateType.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/io/skodjob/datagenerator/enums/ETemplateType.java b/src/main/java/io/skodjob/datagenerator/enums/ETemplateType.java index 869f078..96e78bd 100644 --- a/src/main/java/io/skodjob/datagenerator/enums/ETemplateType.java +++ b/src/main/java/io/skodjob/datagenerator/enums/ETemplateType.java @@ -64,4 +64,19 @@ public enum ETemplateType { public String getTemplateName() { return templateName; } + + /** + * Gets the name of the template based on String name + * + * @param value string representation of template name + * @return specific template + */ + public static ETemplateType getFromString(String value) { + for (ETemplateType type : values()) { + if (type.toString().equalsIgnoreCase(value)) { + return type; + } + } + return null; + } }