-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
182 additions
and
152 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
58 changes: 35 additions & 23 deletions
58
arc-core/src/main/java/fr/insee/arc/core/service/p4controle/bo/ControleTypeCode.java
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 |
---|---|---|
@@ -1,34 +1,46 @@ | ||
package fr.insee.arc.core.service.p4controle.bo; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import fr.insee.arc.utils.exception.ArcException; | ||
import fr.insee.arc.utils.exception.ArcExceptionMessage; | ||
|
||
/** | ||
* code des types de controle proposés par ARC | ||
* code des types de controle proposés par ARC | ||
* | ||
* @author FY2QEQ | ||
* | ||
*/ | ||
public enum ControleTypeCode { | ||
NUM, DATE, ALPHANUM, CARDINALITE, CONDITION, REGEXP, ENUM_BRUTE, ENUM_TABLE; | ||
|
||
public static ControleTypeCode getEnum(String code) { | ||
switch (code) { | ||
case "NUM": | ||
return NUM; | ||
case "DATE": | ||
return DATE; | ||
case "ALPHANUM": | ||
return ALPHANUM; | ||
case "CARDINALITE": | ||
return CARDINALITE; | ||
case "CONDITION": | ||
return CONDITION; | ||
case "REGEXP": | ||
return REGEXP; | ||
case "ENUM_BRUTE": | ||
return ENUM_BRUTE; | ||
case "ENUM_TABLE": | ||
return ENUM_TABLE; | ||
default: | ||
return null; | ||
NUM("NUM"), DATE("DATE"), ALPHANUM("ALPHANUM"), CARDINALITE("CARDINALITE"), CONDITION("CONDITION"), | ||
REGEXP("REGEXP"), ENUM_BRUTE("ENUM_BRUTE"), ENUM_TABLE("ENUM_TABLE"); | ||
|
||
private String nom; | ||
|
||
private ControleTypeCode(String nom) { | ||
this.nom = nom; | ||
} | ||
|
||
public String getNom() { | ||
return nom; | ||
} | ||
|
||
public void setNom(String nom) { | ||
this.nom = nom; | ||
} | ||
|
||
public static ControleTypeCode getEnum(String code) throws ArcException { | ||
|
||
List<ControleTypeCode> filtered = Arrays.asList(ControleTypeCode.values()).stream() | ||
.filter(t -> t.getNom().equals(code)).collect(Collectors.toList()); | ||
|
||
if (filtered.isEmpty()) { | ||
throw new ArcException(ArcExceptionMessage.CONTROLE_TYPE_NOT_FOUND, code); | ||
} | ||
|
||
return filtered.get(0); | ||
} | ||
|
||
} |
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
Oops, something went wrong.