Skip to content

Commit

Permalink
Create VtlTypes.java
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoLaval committed Nov 5, 2024
1 parent 4037462 commit 4356e48
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions vtl-prov/src/main/java/fr/insee/vtl/prov/utils/VtlTypes.java
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");
}
}

0 comments on commit 4356e48

Please sign in to comment.