Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Number instead of BigDecimal in JavaTime dialects #680

Merged
merged 3 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,4 @@ public interface DMNDialectDefinition<NUMBER, DATE, TIME, DATE_TIME, DURATION, T
FEELLib<NUMBER, DATE, TIME, DATE_TIME, DURATION> createFEELLib();

String getDecisionBaseClass();

//
// Types
//
String getNativeNumberType();

String getNativeDateType();

String getNativeTimeType();

String getNativeDateAndTimeType();

String getNativeDurationType();
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,29 +72,4 @@ public FEELLib<Double, LocalDate, OffsetTime, ZonedDateTime, Duration> createFEE
public String getDecisionBaseClass() {
return DoubleMixedJavaTimeDMNBaseDecision.class.getName();
}

@Override
public String getNativeNumberType() {
return Double.class.getName();
}

@Override
public String getNativeDateType() {
return LocalDate.class.getName();
}

@Override
public String getNativeTimeType() {
return OffsetTime.class.getName();
}

@Override
public String getNativeDateAndTimeType() {
return ZonedDateTime.class.getName();
}

@Override
public String getNativeDurationType() {
return Duration.class.getName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,29 +73,4 @@ public FEELLib<Double, LocalDate, OffsetTime, ZonedDateTime, Duration> createFEE
public String getDecisionBaseClass() {
return DoubleMixedJavaTimeDMNBaseDecision.class.getName();
}

@Override
public String getNativeNumberType() {
return Double.class.getName();
}

@Override
public String getNativeDateType() {
return LocalDate.class.getName();
}

@Override
public String getNativeTimeType() {
return OffsetTime.class.getName();
}

@Override
public String getNativeDateAndTimeType() {
return ZonedDateTime.class.getName();
}

@Override
public String getNativeDurationType() {
return Duration.class.getName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,11 @@
import com.gs.dmn.transformation.template.TemplateProvider;
import com.gs.dmn.validation.DMNValidator;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.temporal.Temporal;
import java.time.temporal.TemporalAccessor;
import java.time.temporal.TemporalAmount;

public class JavaTimeDMNDialectDefinition extends AbstractStandardDMNDialectDefinition<BigDecimal, LocalDate, TemporalAccessor, TemporalAccessor, TemporalAmount> {
public class JavaTimeDMNDialectDefinition extends AbstractStandardDMNDialectDefinition<Number, LocalDate, TemporalAccessor, TemporalAccessor, TemporalAmount> {
//
// DMN Processors
//
Expand All @@ -61,37 +59,12 @@ public NativeTypeFactory createNativeTypeFactory() {
}

@Override
public FEELLib<BigDecimal, LocalDate, TemporalAccessor, TemporalAccessor, TemporalAmount> createFEELLib() {
public FEELLib<Number, LocalDate, TemporalAccessor, TemporalAccessor, TemporalAmount> createFEELLib() {
return new JavaTimeFEELLib();
}

@Override
public String getDecisionBaseClass() {
return JavaTimeDMNBaseDecision.class.getName();
}

@Override
public String getNativeNumberType() {
return BigDecimal.class.getName();
}

@Override
public String getNativeDateType() {
return LocalDate.class.getName();
}

@Override
public String getNativeTimeType() {
return TemporalAccessor.class.getName();
}

@Override
public String getNativeDateAndTimeType() {
return TemporalAccessor.class.getName();
}

@Override
public String getNativeDurationType() {
return TemporalAmount.class.getName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,11 @@
import com.gs.dmn.transformation.template.TemplateProvider;
import com.gs.dmn.validation.DMNValidator;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.OffsetTime;
import java.time.ZonedDateTime;
import java.time.temporal.TemporalAccessor;
import java.time.temporal.TemporalAmount;

public class JavaTimeKotlinStandardDMNDialectDefinition extends AbstractStandardDMNDialectDefinition<BigDecimal, LocalDate, TemporalAccessor, TemporalAccessor, TemporalAmount> {
public class JavaTimeKotlinStandardDMNDialectDefinition extends AbstractStandardDMNDialectDefinition<Number, LocalDate, TemporalAccessor, TemporalAccessor, TemporalAmount> {
//
// DMN Processors
//
Expand All @@ -63,37 +60,12 @@ public NativeTypeFactory createNativeTypeFactory() {
}

@Override
public FEELLib<BigDecimal, LocalDate, TemporalAccessor, TemporalAccessor, TemporalAmount> createFEELLib() {
public FEELLib<Number, LocalDate, TemporalAccessor, TemporalAccessor, TemporalAmount> createFEELLib() {
return new JavaTimeFEELLib();
}

@Override
public String getDecisionBaseClass() {
return JavaTimeDMNBaseDecision.class.getName();
}

@Override
public String getNativeNumberType() {
return BigDecimal.class.getName();
}

@Override
public String getNativeDateType() {
return LocalDate.class.getName();
}

@Override
public String getNativeTimeType() {
return TemporalAccessor.class.getName();
}

@Override
public String getNativeDateAndTimeType() {
return TemporalAccessor.class.getName();
}

@Override
public String getNativeDurationType() {
return TemporalAmount.class.getName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@
import com.gs.dmn.transformation.template.TemplateProvider;
import com.gs.dmn.validation.DMNValidator;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.temporal.TemporalAccessor;
import java.time.temporal.TemporalAmount;

public class JavaTimePythonStandardDMNDialectDefinition extends AbstractStandardDMNDialectDefinition<BigDecimal, LocalDate, TemporalAccessor, TemporalAccessor, TemporalAmount> {
public class JavaTimePythonStandardDMNDialectDefinition extends AbstractStandardDMNDialectDefinition<Number, LocalDate, TemporalAccessor, TemporalAccessor, TemporalAmount> {
//
// DMN Processors
//
Expand All @@ -61,7 +60,7 @@ public NativeTypeFactory createNativeTypeFactory() {
}

@Override
public FEELLib<BigDecimal, LocalDate, TemporalAccessor, TemporalAccessor, TemporalAmount> createFEELLib() {
public FEELLib<Number, LocalDate, TemporalAccessor, TemporalAccessor, TemporalAmount> createFEELLib() {
return new JavaTimeFEELLib();
}

Expand All @@ -74,29 +73,4 @@ protected String qualifiedName(Class<?> cls) {
String qName = String.format("%s.%s", cls.getName(), cls.getSimpleName());
return qName.replace("com.gs.dmn", "jdmn");
}

@Override
public String getNativeNumberType() {
return "decimal.Decimal";
}

@Override
public String getNativeDateType() {
return "datetime.date";
}

@Override
public String getNativeTimeType() {
return "datetime.time";
}

@Override
public String getNativeDateAndTimeType() {
return "datetime.datetime";
}

@Override
public String getNativeDurationType() {
return "isodate.Duration";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,29 +72,4 @@ public FEELLib<BigDecimal, XMLGregorianCalendar, XMLGregorianCalendar, XMLGregor
public String getDecisionBaseClass() {
return DefaultDMNBaseDecision.class.getName();
}

@Override
public String getNativeNumberType() {
return BigDecimal.class.getName();
}

@Override
public String getNativeDateType() {
return XMLGregorianCalendar.class.getName();
}

@Override
public String getNativeTimeType() {
return XMLGregorianCalendar.class.getName();
}

@Override
public String getNativeDateAndTimeType() {
return XMLGregorianCalendar.class.getName();
}

@Override
public String getNativeDurationType() {
return Duration.class.getName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,29 +73,4 @@ public FEELLib<BigDecimal, LocalDate, OffsetTime, ZonedDateTime, Duration> creat
public String getDecisionBaseClass() {
return MixedJavaTimeDMNBaseDecision.class.getName();
}

@Override
public String getNativeNumberType() {
return BigDecimal.class.getName();
}

@Override
public String getNativeDateType() {
return LocalDate.class.getName();
}

@Override
public String getNativeTimeType() {
return OffsetTime.class.getName();
}

@Override
public String getNativeDateAndTimeType() {
return ZonedDateTime.class.getName();
}

@Override
public String getNativeDurationType() {
return Duration.class.getName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,29 +74,4 @@ public FEELLib<BigDecimal, LocalDate, OffsetTime, ZonedDateTime, Duration> creat
public String getDecisionBaseClass() {
return MixedJavaTimeDMNBaseDecision.class.getName();
}

@Override
public String getNativeNumberType() {
return BigDecimal.class.getName();
}

@Override
public String getNativeDateType() {
return LocalDate.class.getName();
}

@Override
public String getNativeTimeType() {
return OffsetTime.class.getName();
}

@Override
public String getNativeDateAndTimeType() {
return ZonedDateTime.class.getName();
}

@Override
public String getNativeDurationType() {
return Duration.class.getName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,29 +71,4 @@ public FEELLib<BigDecimal, XMLGregorianCalendar, XMLGregorianCalendar, XMLGregor
public String getDecisionBaseClass() {
return DefaultDMNBaseDecision.class.getName();
}

@Override
public String getNativeNumberType() {
return BigDecimal.class.getName();
}

@Override
public String getNativeDateType() {
return XMLGregorianCalendar.class.getName();
}

@Override
public String getNativeTimeType() {
return XMLGregorianCalendar.class.getName();
}

@Override
public String getNativeDateAndTimeType() {
return XMLGregorianCalendar.class.getName();
}

@Override
public String getNativeDurationType() {
return Duration.class.getName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,9 @@ public String toNativeType(String feelType) {
public String toQualifiedNativeType(String feelType) {
return FEEL_TYPE_TO_QUALIFIED_JAVA_TYPE.get(feelType);
}

@Override
public String getNativeNumberConcreteType() {
return Double.class.getName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,9 @@ public String toNativeType(String feelType) {
public String toQualifiedNativeType(String feelType) {
return FEEL_TYPE_TO_QUALIFIED_JAVA_TYPE.get(feelType);
}

@Override
public String getNativeNumberConcreteType() {
return Double.class.getName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class JavaTimeNativeTypeFactory extends JavaTypeFactory {
FEEL_TYPE_TO_JAVA_TYPE.put(DATE.getName(), java.time.LocalDate.class.getName());
FEEL_TYPE_TO_JAVA_TYPE.put(STRING.getName(), String.class.getSimpleName());
FEEL_TYPE_TO_JAVA_TYPE.put(BOOLEAN.getName(), Boolean.class.getSimpleName());
FEEL_TYPE_TO_JAVA_TYPE.put(NUMBER.getName(), java.math.BigDecimal.class.getName());
FEEL_TYPE_TO_JAVA_TYPE.put(NUMBER.getName(), java.lang.Number.class.getName());
FEEL_TYPE_TO_JAVA_TYPE.put(ANY.getName(), Object.class.getSimpleName());
FEEL_TYPE_TO_JAVA_TYPE.put(NULL.getName(), Object.class.getSimpleName());
}
Expand All @@ -53,7 +53,7 @@ public class JavaTimeNativeTypeFactory extends JavaTypeFactory {
FEEL_TYPE_TO_QUALIFIED_JAVA_TYPE.put(DATE.getName(), java.time.LocalDate.class.getName());
FEEL_TYPE_TO_QUALIFIED_JAVA_TYPE.put(STRING.getName(), String.class.getName());
FEEL_TYPE_TO_QUALIFIED_JAVA_TYPE.put(BOOLEAN.getName(), Boolean.class.getName());
FEEL_TYPE_TO_QUALIFIED_JAVA_TYPE.put(NUMBER.getName(), java.math.BigDecimal.class.getName());
FEEL_TYPE_TO_QUALIFIED_JAVA_TYPE.put(NUMBER.getName(), java.lang.Number.class.getName());
FEEL_TYPE_TO_QUALIFIED_JAVA_TYPE.put(ANY.getName(), Object.class.getName());
FEEL_TYPE_TO_QUALIFIED_JAVA_TYPE.put(NULL.getName(), Object.class.getName());
}
Expand Down
Loading
Loading