forked from InseeFr/Trevas
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
vtl-prov/src/main/java/fr/insee/vtl/prov/utils/VtlTypes.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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package fr.insee.vtl.prov.utils; | ||
|
||
import org.threeten.extra.Interval; | ||
import org.threeten.extra.PeriodDuration; | ||
|
||
import java.time.Instant; | ||
|
||
public class VtlTypes { | ||
|
||
/** | ||
* Method to map Java classes and VTL basic scalar types. | ||
* | ||
* @param clazz Java type. | ||
* @return Basic scalar type | ||
*/ | ||
public static String getVtlType(Class<?> clazz) { | ||
if (clazz.equals(String.class)) { | ||
return "STRING"; | ||
} else if (clazz.equals(Long.class)) { | ||
return "INTEGER"; | ||
} else if (clazz.equals(Double.class)) { | ||
return "NUMBER"; | ||
} else if (clazz.equals(Boolean.class)) { | ||
return "BOOLEAN"; | ||
} else if (clazz.equals(Instant.class)) { | ||
return "DATE"; | ||
} else if (clazz.equals(PeriodDuration.class)) { | ||
return "DURATION"; | ||
} else if (clazz.equals(Interval.class)) { | ||
return "TIME_PERIOD"; | ||
} | ||
throw new UnsupportedOperationException("class " + clazz + " unsupported"); | ||
} | ||
} |