Skip to content

Commit

Permalink
[incubator-kie-issues#1344] Hiding constructors from functions, that …
Browse files Browse the repository at this point in the history
…are singleton by design
  • Loading branch information
Gabriele-Cardosi committed Jun 28, 2024
1 parent 5dfde0a commit 4029d40
Show file tree
Hide file tree
Showing 161 changed files with 1,103 additions and 1,173 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
public class DMNFeelExpressionEvaluator extends AbstractExpressionEvaluator {

private final ClassLoader classLoader;
private final CodeFunction codeFunction = new CodeFunction();
private final CodeFunction codeFunction = CodeFunction.INSTANCE;

public DMNFeelExpressionEvaluator(ClassLoader classLoader) {
this.classLoader = classLoader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,19 +182,19 @@ private Object getAsFEELBuiltinType(Object value, DMNType resultType) {
case UNKNOWN:
return value;
case DATE:
return new DateFunction().invoke((String) value).getOrElseThrow(FailedConversionException::new);
return DateFunction.INSTANCE.invoke((String) value).getOrElseThrow(FailedConversionException::new);
case TIME:
return new TimeFunction().invoke((String) value).getOrElseThrow(FailedConversionException::new);
return TimeFunction.INSTANCE.invoke((String) value).getOrElseThrow(FailedConversionException::new);
case DATE_TIME:
return new DateAndTimeFunction().invoke((String) value).getOrElseThrow(FailedConversionException::new);
return DateAndTimeFunction.INSTANCE.invoke((String) value).getOrElseThrow(FailedConversionException::new);
case BOOLEAN:
return value;
case NUMBER:
return NumberEvalHelper.getBigDecimalOrNull(value);
case STRING:
return value;
case DURATION:
return new DurationFunction().invoke((String) value).getOrElseThrow(FailedConversionException::new);
return DurationFunction.INSTANCE.invoke((String) value).getOrElseThrow(FailedConversionException::new);
default:
throw new IllegalArgumentException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class AbsFunction
extends BaseFEELFunction {
public static final AbsFunction INSTANCE = new AbsFunction();

AbsFunction() {
private AbsFunction() {
super( "abs" );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.util.Arrays;
import java.util.List;

import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity;
import org.kie.dmn.feel.runtime.events.InvalidParametersEvent;

Expand All @@ -28,7 +29,7 @@ public class AllFunction

public static final AllFunction INSTANCE = new AllFunction();

public AllFunction() {
private AllFunction() {
super( "all" );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.util.Arrays;
import java.util.List;

import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity;
import org.kie.dmn.feel.runtime.events.InvalidParametersEvent;

Expand All @@ -28,7 +29,7 @@ public class AnyFunction

public static final AnyFunction INSTANCE = new AnyFunction();

public AnyFunction() {
private AnyFunction() {
super( "any" );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.List;

import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity;
import org.kie.dmn.feel.runtime.events.InvalidParametersEvent;

Expand All @@ -30,7 +31,7 @@ public class AppendFunction

public static final AppendFunction INSTANCE = new AppendFunction();

public AppendFunction() {
private AppendFunction() {
super( "append" );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@

import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity;
import org.kie.dmn.feel.runtime.events.InvalidParametersEvent;
import org.kie.dmn.feel.runtime.functions.FEELFnResult;

public class CeilingFunction
extends BaseFEELFunction {

public static final CeilingFunction INSTANCE = new CeilingFunction();

public CeilingFunction() {
private CeilingFunction() {
super( "ceiling" );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity;
import org.kie.dmn.feel.runtime.events.InvalidParametersEvent;

Expand All @@ -29,7 +30,7 @@ public class ConcatenateFunction

public static final ConcatenateFunction INSTANCE = new ConcatenateFunction();

public ConcatenateFunction() {
private ConcatenateFunction() {
super( "concatenate" );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class ContainsFunction

public static final ContainsFunction INSTANCE = new ContainsFunction();

public ContainsFunction() {
private ContainsFunction() {
super( "contains" );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,12 @@
import org.kie.dmn.api.feel.runtime.events.FEELEvent;
import org.kie.dmn.feel.runtime.events.InvalidParametersEvent;

/**
* Proposal DMN14-187
* Experimental for DMN14-183, an inverse of `get entries()`
* See also: DMN14-181, DMN14-182
*/

public class ContextFunction extends BaseFEELFunction {

public static final ContextFunction INSTANCE = new ContextFunction();

public ContextFunction() {
private ContextFunction() {
super("context");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,11 @@
import org.kie.dmn.api.feel.runtime.events.FEELEvent;
import org.kie.dmn.feel.runtime.events.InvalidParametersEvent;

/**
* Proposal DMN14-187
* Experimental for DMN14-182
* See also: DMN14-181, DMN14-183
*/
public class ContextMergeFunction extends BaseFEELFunction {

public static final ContextMergeFunction INSTANCE = new ContextMergeFunction();

public ContextMergeFunction() {
private ContextMergeFunction() {
super("context merge");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,12 @@
import org.kie.dmn.feel.lang.types.impl.ImmutableFPAWrappingPOJO;
import org.kie.dmn.feel.runtime.events.InvalidParametersEvent;

/**
* Proposal DMN14-187
* Experimental for DMN14-181
* See also: DMN14-182, DMN14-183
*/

public class ContextPutFunction extends BaseFEELFunction {

public static final ContextPutFunction INSTANCE = new ContextPutFunction();

public ContextPutFunction() {
private ContextPutFunction() {
super("context put");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@

import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity;
import org.kie.dmn.feel.runtime.events.InvalidParametersEvent;
import org.kie.dmn.feel.runtime.functions.FEELFnResult;

public class CountFunction
extends BaseFEELFunction {

public static final CountFunction INSTANCE = new CountFunction();

public CountFunction() {
private CountFunction() {
super( "count" );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class DateAndTimeFunction
.toFormatter();
}

public DateAndTimeFunction() {
private DateAndTimeFunction() {
super(FEELConversionFunctionNames.DATE_AND_TIME);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class DateFunction
.withResolverStyle(ResolverStyle.STRICT);
}

public DateFunction() {
protected DateFunction() {
super(FEELConversionFunctionNames.DATE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
public class DayOfWeekFunction extends BaseFEELFunction {
public static final DayOfWeekFunction INSTANCE = new DayOfWeekFunction();

DayOfWeekFunction() {
private DayOfWeekFunction() {
super("day of week");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
public class DayOfYearFunction extends BaseFEELFunction {
public static final DayOfYearFunction INSTANCE = new DayOfYearFunction();

DayOfYearFunction() {
private DayOfYearFunction() {
super("day of year");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@

import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity;
import org.kie.dmn.feel.runtime.events.InvalidParametersEvent;
import org.kie.dmn.feel.runtime.functions.FEELFnResult;

public class DecimalFunction
extends BaseFEELFunction {

public static final DecimalFunction INSTANCE = new DecimalFunction();

public DecimalFunction() {
private DecimalFunction() {
super( "decimal" );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class DecisionTableFunction

private static final Logger LOG = LoggerFactory.getLogger( DecisionTableFunction.class );

public DecisionTableFunction() {
private DecisionTableFunction() {
super( "decision table" );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity;
import org.kie.dmn.feel.runtime.events.InvalidParametersEvent;

Expand All @@ -29,7 +30,7 @@ public class DistinctValuesFunction

public static final DistinctValuesFunction INSTANCE = new DistinctValuesFunction();

public DistinctValuesFunction() {
private DistinctValuesFunction() {
super( "distinct values" );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class DurationFunction

public static final DurationFunction INSTANCE = new DurationFunction();

public DurationFunction() {
private DurationFunction() {
super(FEELConversionFunctionNames.DURATION);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class EndsWithFunction

public static final EndsWithFunction INSTANCE = new EndsWithFunction();

public EndsWithFunction() {
private EndsWithFunction() {
super( "ends with" );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
*/
package org.kie.dmn.feel.runtime.functions;

import java.math.BigDecimal;

import org.kie.dmn.api.feel.runtime.events.FEELEvent;
import org.kie.dmn.feel.runtime.events.InvalidParametersEvent;

import java.math.BigDecimal;

public class EvenFunction
extends BaseFEELFunction {
public static final EvenFunction INSTANCE = new EvenFunction();

private static final BigDecimal TWO = BigDecimal.valueOf(2);

EvenFunction() {
private EvenFunction() {
super("even");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class ExpFunction
extends BaseFEELFunction {
public static final ExpFunction INSTANCE = new ExpFunction();

ExpFunction() {
private ExpFunction() {
super("exp");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity;
import org.kie.dmn.feel.runtime.events.InvalidParametersEvent;

Expand All @@ -29,7 +30,7 @@ public class FlattenFunction

public static final FlattenFunction INSTANCE = new FlattenFunction();

public FlattenFunction() {
private FlattenFunction() {
super( "flatten" );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class FloorFunction

public static final FloorFunction INSTANCE = new FloorFunction();

public FloorFunction() {
private FloorFunction() {
super( "floor" );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class GetEntriesFunction extends BaseFEELFunction {

public static final GetEntriesFunction INSTANCE = new GetEntriesFunction();

public GetEntriesFunction() {
private GetEntriesFunction() {
super("get entries");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class GetValueFunction extends BaseFEELFunction {

public static final GetValueFunction INSTANCE = new GetValueFunction();

public GetValueFunction() {
private GetValueFunction() {
super("get value");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import org.kie.dmn.api.feel.runtime.events.FEELEvent.Severity;
import org.kie.dmn.feel.runtime.events.InvalidParametersEvent;

Expand All @@ -29,7 +30,7 @@ public class IndexOfFunction

public static final IndexOfFunction INSTANCE = new IndexOfFunction();

public IndexOfFunction() {
private IndexOfFunction() {
super( "index of" );
}

Expand Down
Loading

0 comments on commit 4029d40

Please sign in to comment.