Search in sources :

Example 1 with Year

use of org.finos.legend.pure.m4.coreinstance.primitive.date.Year in project legend-pure by finos.

the class CompiledSupport method newDate.

public static DateTime newDate(long year, long month, long day, long hour, long minute, Number second, SourceInformation sourceInformation) {
    int secondInt;
    String subsecond = null;
    if ((second instanceof Integer) || (second instanceof Long) || (second instanceof BigInteger)) {
        // TODO check if the number is too large for an int
        secondInt = second.intValue();
    } else if ((second instanceof Float) || (second instanceof Double)) {
        secondInt = second.intValue();
        String string = BigDecimal.valueOf(second.doubleValue()).toPlainString();
        int index = string.indexOf('.');
        subsecond = (index == -1) ? "0" : string.substring(index + 1);
    } else if (second instanceof BigDecimal) {
        secondInt = second.intValue();
        String string = ((BigDecimal) second).toPlainString();
        int index = string.indexOf('.');
        if (index != -1) {
            subsecond = string.substring(index + 1);
        }
    } else {
        throw new PureExecutionException(sourceInformation, "Unhandled number: " + second);
    }
    try {
        return (subsecond == null) ? DateFunctions.newPureDate((int) year, (int) month, (int) day, (int) hour, (int) minute, secondInt) : DateFunctions.newPureDate((int) year, (int) month, (int) day, (int) hour, (int) minute, secondInt, subsecond);
    } catch (Exception e) {
        throw new PureExecutionException(sourceInformation, e.getMessage());
    }
}
Also used : BigInteger(java.math.BigInteger) PureExecutionException(org.finos.legend.pure.m3.exception.PureExecutionException) BigInteger(java.math.BigInteger) BigDecimal(java.math.BigDecimal) PureAssertFailException(org.finos.legend.pure.m3.exception.PureAssertFailException) InvalidFunctionDescriptorException(org.finos.legend.pure.m3.navigation.function.InvalidFunctionDescriptorException) InvocationTargetException(java.lang.reflect.InvocationTargetException) PureJavaCompileException(org.finos.legend.pure.runtime.java.compiled.compiler.PureJavaCompileException) PureException(org.finos.legend.pure.m4.exception.PureException) PureExecutionException(org.finos.legend.pure.m3.exception.PureExecutionException) ParseException(org.json.simple.parser.ParseException) NoSuchElementException(java.util.NoSuchElementException)

Example 2 with Year

use of org.finos.legend.pure.m4.coreinstance.primitive.date.Year in project legend-pure by finos.

the class FromJson method execute.

@Override
public CoreInstance execute(ListIterable<? extends CoreInstance> params, final Stack<MutableMap<String, CoreInstance>> resolvedTypeParameters, final Stack<MutableMap<String, CoreInstance>> resolvedMultiplicityParameters, final VariableContext variableContext, final CoreInstance functionExpressionToUseInStack, final Profiler profiler, final InstantiationContext instantiationContext, final ExecutionSupport executionSupport, final Context context, final ProcessorSupport processorSupport) throws PureExecutionException {
    final SourceInformation si = functionExpressionToUseInStack.getSourceInformation();
    Class startingClass = (Class) Instance.getValueForMetaPropertyToOneResolved(params.get(1), M3Properties.values, processorSupport);
    CoreInstance config = Instance.getValueForMetaPropertyToOneResolved(params.get(2), M3Properties.values, processorSupport);
    String typeKeyName = ((StringCoreInstance) config.getValueForMetaPropertyToOne("typeKeyName")).getValue();
    Map<String, Class> keyLookup = new UnifiedMap<String, Class>();
    for (CoreInstance o : config.getValueForMetaPropertyToMany("typeLookup")) {
        keyLookup.put(o.getValueForMetaPropertyToOne("first").getName(), (Class) _Package.getByUserPath(o.getValueForMetaPropertyToOne("second").getName(), functionExecution.getProcessorSupport()));
    }
    Boolean failOnUnknownProperties = ((BooleanCoreInstance) config.getValueForMetaPropertyToOne("failOnUnknownProperties")).getValue();
    final ConstraintsOverride constraintsOverride = (ConstraintsOverride) config.getValueForMetaPropertyToOne("constraintsHandler");
    String jsonText = PrimitiveUtilities.getStringValue(Instance.getValueForMetaPropertyToOneResolved(params.get(0), M3Properties.values, processorSupport));
    return JsonDeserializer.fromJson(jsonText, startingClass, new JsonDeserializationContext(new JsonDeserializationCache(), si, processorSupport, typeKeyName, keyLookup, failOnUnknownProperties, new ObjectFactory() {

        @Override
        public <T extends Any> T newObject(Class<T> clazz, Map<String, RichIterable<?>> properties) {
            CoreInstance instance = FromJson.this.repository.newEphemeralAnonymousCoreInstance(functionExpressionToUseInStack.getSourceInformation(), clazz);
            for (Entry<String, RichIterable<?>> eachKeyValue : properties.entrySet()) {
                FastList<CoreInstance> values = new FastList<>();
                for (Object eachValue : eachKeyValue.getValue()) {
                    if (eachValue instanceof String) {
                        values.add(FromJson.this.repository.newStringCoreInstance((String) eachValue));
                    } else if (eachValue instanceof Boolean) {
                        values.add(FromJson.this.repository.newBooleanCoreInstance((Boolean) eachValue));
                    } else if (eachValue instanceof Integer) {
                        values.add(FromJson.this.repository.newIntegerCoreInstance((int) eachValue));
                    } else if (eachValue instanceof Long) {
                        values.add(FromJson.this.repository.newIntegerCoreInstance((long) eachValue));
                    } else if (eachValue instanceof BigDecimal) {
                        values.add(FromJson.this.repository.newDecimalCoreInstance((BigDecimal) eachValue));
                    } else if (eachValue instanceof Double || eachValue instanceof Number) {
                        values.add(FromJson.this.repository.newFloatCoreInstance(BigDecimal.valueOf((Double) eachValue)));
                    } else if (eachValue instanceof Year || eachValue instanceof YearMonth) {
                        values.add(FromJson.this.repository.newDateCoreInstance((PureDate) eachValue));
                    } else if (eachValue instanceof StrictDate) {
                        values.add(FromJson.this.repository.newStrictDateCoreInstance((PureDate) eachValue));
                    } else if (eachValue instanceof DateTime || eachValue instanceof LatestDate || eachValue instanceof PureDate) {
                        values.add(FromJson.this.repository.newDateTimeCoreInstance((PureDate) eachValue));
                    } else if (eachValue instanceof InstanceValue) {
                        InstanceValue asInstanceValue = (InstanceValue) eachValue;
                        if (Measure.isUnitOrMeasureInstance(asInstanceValue, processorSupport)) {
                            values.add(asInstanceValue);
                        } else {
                            values.add((CoreInstance) asInstanceValue._values().getFirst());
                        }
                    } else if (eachValue instanceof EnumInstance) {
                        values.add((CoreInstance) eachValue);
                    } else {
                        throw new PureExecutionException(si, "Unknown type from output of JsonDeserializer for property: " + eachKeyValue.getKey());
                    }
                }
                Instance.setValuesForProperty(instance, eachKeyValue.getKey(), values, processorSupport);
            }
            DeserializationUtils.replaceReverseProperties(instance, processorSupport, si);
            CoreInstance override = processorSupport.newAnonymousCoreInstance(si, M3Paths.ConstraintsGetterOverride);
            if (constraintsOverride != null) {
                Instance.addValueToProperty(override, M3Properties.constraintsManager, constraintsOverride._constraintsManager(), processorSupport);
                Instance.addValueToProperty(instance, M3Properties.elementOverride, override, processorSupport);
            }
            CoreInstance value = ValueSpecificationBootstrap.wrapValueSpecification(instance, true, processorSupport);
            return (T) DefaultConstraintHandler.handleConstraints(clazz, value, si, functionExecution, resolvedTypeParameters, resolvedMultiplicityParameters, variableContext, functionExpressionToUseInStack, profiler, instantiationContext, executionSupport);
        }

        public <T extends Any> T newUnitInstance(CoreInstance propertyType, String unitTypeString, Number unitValue) {
            CoreInstance retrievedUnit = processorSupport.package_getByUserPath(unitTypeString);
            if (!processorSupport.type_subTypeOf(retrievedUnit, propertyType)) {
                throw new PureExecutionException("Cannot match unit type: " + unitTypeString + " as subtype of type: " + PackageableElement.getUserPathForPackageableElement(propertyType));
            }
            FastList<CoreInstance> params = new FastList<>();
            params.add(ValueSpecificationBootstrap.wrapValueSpecification(retrievedUnit, false, processorSupport));
            params.add(NumericUtilities.toPureNumberValueExpression(unitValue, false, repository, processorSupport));
            return (T) new NewUnit(repository, functionExecution).execute(params, resolvedTypeParameters, resolvedMultiplicityParameters, variableContext, functionExpressionToUseInStack, profiler, instantiationContext, executionSupport, context, processorSupport);
        }
    }));
}
Also used : UnifiedMap(org.eclipse.collections.impl.map.mutable.UnifiedMap) ConstraintsOverride(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.ConstraintsOverride) InstanceValue(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.InstanceValue) Any(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Any) StrictDate(org.finos.legend.pure.m4.coreinstance.primitive.date.StrictDate) DateTime(org.finos.legend.pure.m4.coreinstance.primitive.date.DateTime) NewUnit(org.finos.legend.pure.runtime.java.interpreted.natives.core.lang.NewUnit) JsonDeserializationContext(org.finos.legend.pure.runtime.java.extension.external.json.shared.JsonDeserializationContext) ObjectFactory(org.finos.legend.pure.runtime.java.extension.external.shared.conversion.ObjectFactory) EnumInstance(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.EnumInstance) PureExecutionException(org.finos.legend.pure.m3.exception.PureExecutionException) FastList(org.eclipse.collections.impl.list.mutable.FastList) PureDate(org.finos.legend.pure.m4.coreinstance.primitive.date.PureDate) StringCoreInstance(org.finos.legend.pure.m4.coreinstance.primitive.StringCoreInstance) LatestDate(org.finos.legend.pure.m4.coreinstance.primitive.date.LatestDate) SourceInformation(org.finos.legend.pure.m4.coreinstance.SourceInformation) BigDecimal(java.math.BigDecimal) BooleanCoreInstance(org.finos.legend.pure.m4.coreinstance.primitive.BooleanCoreInstance) RichIterable(org.eclipse.collections.api.RichIterable) JsonDeserializationCache(org.finos.legend.pure.runtime.java.extension.external.json.shared.JsonDeserializationCache) Year(org.finos.legend.pure.m4.coreinstance.primitive.date.Year) YearMonth(org.finos.legend.pure.m4.coreinstance.primitive.date.YearMonth) StringCoreInstance(org.finos.legend.pure.m4.coreinstance.primitive.StringCoreInstance) BooleanCoreInstance(org.finos.legend.pure.m4.coreinstance.primitive.BooleanCoreInstance) CoreInstance(org.finos.legend.pure.m4.coreinstance.CoreInstance) Class(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class) Map(java.util.Map) UnifiedMap(org.eclipse.collections.impl.map.mutable.UnifiedMap) MutableMap(org.eclipse.collections.api.map.MutableMap) ConstraintsOverride(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.ConstraintsOverride)

Example 3 with Year

use of org.finos.legend.pure.m4.coreinstance.primitive.date.Year in project legend-pure by finos.

the class FunctionExecutionInterpreted method init.

@Override
public void init(PureRuntime runtime, Message message) {
    this.runtime = runtime;
    this.nativeFunctions = UnifiedMap.newMap();
    ModelRepository repository = runtime.getModelRepository();
    this.storage = runtime.getCodeStorage();
    this.message = message;
    this.nativeFunctions.put("replaceTreeNode_TreeNode_1__TreeNode_1__TreeNode_1__TreeNode_1_", new ReplaceTreeNode(repository));
    this.nativeFunctions.put("letFunction_String_1__T_m__T_m_", new Let());
    this.nativeFunctions.put("extractEnumValue_Enumeration_1__String_1__T_1_", new ExtractEnumValue());
    this.nativeFunctions.put("new_Class_1__String_1__KeyExpression_MANY__T_1_", new New(repository, this));
    this.nativeFunctions.put("new_Class_1__String_1__T_1_", new New(repository, this));
    this.nativeFunctions.put("newUnit_Unit_1__Number_1__Any_1_", new NewUnit(repository, this));
    this.nativeFunctions.put("getUnitValue_Any_1__Number_1_", new GetUnitValue(repository, this));
    this.nativeFunctions.put("dynamicNew_Class_1__KeyValue_MANY__Any_1_", new DynamicNew(repository, false, this));
    this.nativeFunctions.put("dynamicNew_GenericType_1__KeyValue_MANY__Any_1_", new DynamicNew(repository, true, this));
    this.nativeFunctions.put("dynamicNew_Class_1__KeyValue_MANY__Function_$0_1$__Function_$0_1$__Any_$0_1$__Any_1_", new DynamicNew(repository, false, this));
    this.nativeFunctions.put("dynamicNew_GenericType_1__KeyValue_MANY__Function_$0_1$__Function_$0_1$__Any_$0_1$__Any_1_", new DynamicNew(repository, true, this));
    this.nativeFunctions.put("dynamicNew_Class_1__KeyValue_MANY__Function_$0_1$__Function_$0_1$__Any_$0_1$__Function_$0_1$__Any_1_", new DynamicNew(repository, false, this));
    this.nativeFunctions.put("dynamicNew_GenericType_1__KeyValue_MANY__Function_$0_1$__Function_$0_1$__Any_$0_1$__Function_$0_1$__Any_1_", new DynamicNew(repository, true, this));
    this.nativeFunctions.put("removeOverride_T_1__T_1_", new RemoveOverride());
    this.nativeFunctions.put("get_T_MANY__String_1__T_$0_1$_", new Get());
    this.nativeFunctions.put("at_T_MANY__Integer_1__T_1_", new At());
    this.nativeFunctions.put("filter_T_MANY__Function_1__T_MANY_", new Filter(this));
    Map c = new Map(this);
    this.nativeFunctions.put("map_T_m__Function_1__V_m_", c);
    this.nativeFunctions.put("map_T_MANY__Function_1__V_MANY_", c);
    this.nativeFunctions.put("map_T_$0_1$__Function_1__V_$0_1$_", c);
    this.nativeFunctions.put("exists_T_MANY__Function_1__Boolean_1_", new Exists(repository, this));
    this.nativeFunctions.put("forAll_T_MANY__Function_1__Boolean_1_", new ForAll(repository, this));
    this.nativeFunctions.put("isEmpty_Any_MANY__Boolean_1_", new IsEmpty(repository));
    this.nativeFunctions.put("fold_T_MANY__Function_1__V_m__V_m_", new Fold(this));
    this.nativeFunctions.put("getAll_Class_1__T_MANY_", new GetAll());
    this.nativeFunctions.put("getAllVersions_Class_1__T_MANY_", new GetAll());
    this.nativeFunctions.put("getAllVersionsInRange_Class_1__Date_1__Date_1__T_MANY_", new GetAll());
    this.nativeFunctions.put("getAll_Class_1__Date_1__T_MANY_", new GetAll());
    this.nativeFunctions.put("getAll_Class_1__Date_1__Date_1__T_MANY_", new GetAll());
    this.nativeFunctions.put("deepFetchGetAll_Class_1__DeepFetchTempTable_1__T_MANY_", new GetAll());
    this.nativeFunctions.put("indexOf_T_MANY__T_1__Integer_1_", new IndexOf(repository));
    this.nativeFunctions.put("add_T_MANY__T_1__T_$1_MANY$_", new Add());
    this.nativeFunctions.put("add_T_MANY__Integer_1__T_1__T_$1_MANY$_", new Add());
    this.nativeFunctions.put("concatenate_T_MANY__T_MANY__T_MANY_", new Concatenate());
    this.nativeFunctions.put("repeat_T_1__Integer_1__T_MANY_", new Repeat());
    this.nativeFunctions.put("first_T_MANY__T_$0_1$_", new First());
    this.nativeFunctions.put("last_T_MANY__T_$0_1$_", new Last());
    this.nativeFunctions.put("init_T_MANY__T_MANY_", new Init());
    this.nativeFunctions.put("tail_T_MANY__T_MANY_", new Tail());
    this.nativeFunctions.put("chunk_String_1__Integer_1__String_MANY_", new Chunk(repository));
    this.nativeFunctions.put("take_T_MANY__Integer_1__T_MANY_", new Take());
    this.nativeFunctions.put("drop_T_MANY__Integer_1__T_MANY_", new Drop());
    this.nativeFunctions.put("slice_T_MANY__Integer_1__Integer_1__T_MANY_", new Slice());
    this.nativeFunctions.put("zip_T_MANY__U_MANY__Pair_MANY_", new Zip(repository));
    Print p = new Print(repository);
    this.nativeFunctions.put("print_Any_MANY__Integer_1__Nil_0_", p);
    this.nativeFunctions.put("executeHTTPRaw_URL_1__HTTPMethod_1__String_$0_1$__String_$0_1$__HTTPResponse_1_", new Http(repository));
    TraceSpan traceSpan = new TraceSpan(this);
    this.nativeFunctions.put("traceSpan_Function_1__String_1__V_m_", traceSpan);
    this.nativeFunctions.put("traceSpan_Function_1__String_1__Function_1__V_m_", traceSpan);
    this.nativeFunctions.put("traceSpan_Function_1__String_1__Function_1__Boolean_1__V_m_", traceSpan);
    Plus plus = new Plus(repository);
    this.nativeFunctions.put("plus_Integer_MANY__Integer_1_", plus);
    this.nativeFunctions.put("plus_Float_MANY__Float_1_", plus);
    this.nativeFunctions.put("plus_Decimal_MANY__Decimal_1_", plus);
    this.nativeFunctions.put("plus_Number_MANY__Number_1_", plus);
    Abs abs = new Abs(repository);
    this.nativeFunctions.put("abs_Integer_1__Integer_1_", abs);
    this.nativeFunctions.put("abs_Float_1__Float_1_", abs);
    this.nativeFunctions.put("abs_Decimal_1__Decimal_1_", abs);
    this.nativeFunctions.put("abs_Number_1__Number_1_", abs);
    Minus minus = new Minus(repository);
    this.nativeFunctions.put("minus_Integer_MANY__Integer_1_", minus);
    this.nativeFunctions.put("minus_Float_MANY__Float_1_", minus);
    this.nativeFunctions.put("minus_Decimal_MANY__Decimal_1_", minus);
    this.nativeFunctions.put("minus_Number_MANY__Number_1_", minus);
    Times times = new Times(repository);
    this.nativeFunctions.put("times_Integer_MANY__Integer_1_", times);
    this.nativeFunctions.put("times_Float_MANY__Float_1_", times);
    this.nativeFunctions.put("times_Decimal_MANY__Decimal_1_", times);
    this.nativeFunctions.put("times_Number_MANY__Number_1_", times);
    this.nativeFunctions.put("floor_Number_1__Integer_1_", new Floor(repository));
    this.nativeFunctions.put("ceiling_Number_1__Integer_1_", new Ceiling(repository));
    this.nativeFunctions.put("round_Number_1__Integer_1_", new Round(repository));
    this.nativeFunctions.put("round_Decimal_1__Integer_1__Decimal_1_", new RoundWithScale(repository));
    this.nativeFunctions.put("round_Float_1__Integer_1__Float_1_", new RoundWithScale(repository));
    this.nativeFunctions.put("stdDev_Number_$1_MANY$__Boolean_1__Number_1_", new StdDev(repository));
    this.nativeFunctions.put("divide_Number_1__Number_1__Float_1_", new Divide(repository));
    this.nativeFunctions.put("divide_Decimal_1__Decimal_1__Integer_1__Decimal_1_", new DivideDecimal(repository));
    this.nativeFunctions.put("pow_Number_1__Number_1__Number_1_", new Power(repository));
    this.nativeFunctions.put("exp_Number_1__Float_1_", new Exp(repository));
    this.nativeFunctions.put("log_Number_1__Float_1_", new Log(repository));
    this.nativeFunctions.put("rem_Number_1__Number_1__Number_1_", new Rem(repository));
    this.nativeFunctions.put("mod_Integer_1__Integer_1__Integer_1_", new Mod(repository));
    this.nativeFunctions.put("sin_Number_1__Float_1_", new Sine(repository));
    this.nativeFunctions.put("asin_Number_1__Float_1_", new ArcSine(repository));
    this.nativeFunctions.put("cos_Number_1__Float_1_", new Cosine(repository));
    this.nativeFunctions.put("acos_Number_1__Float_1_", new ArcCosine(repository));
    this.nativeFunctions.put("tan_Number_1__Float_1_", new Tangent(repository));
    this.nativeFunctions.put("atan_Number_1__Float_1_", new ArcTangent(repository));
    this.nativeFunctions.put("atan2_Number_1__Number_1__Float_1_", new ArcTangent2(repository));
    this.nativeFunctions.put("sqrt_Number_1__Float_1_", new Sqrt(repository));
    this.nativeFunctions.put("lessThan_Number_1__Number_1__Boolean_1_", new LessThan(repository));
    this.nativeFunctions.put("lessThanEqual_Number_1__Number_1__Boolean_1_", new LessThanOrEqualTo(repository));
    this.nativeFunctions.put("toDecimal_Number_1__Decimal_1_", new ToDecimal(repository));
    this.nativeFunctions.put("toFloat_Number_1__Float_1_", new ToFloat(repository));
    this.nativeFunctions.put("is_Any_1__Any_1__Boolean_1_", new Is(repository));
    this.nativeFunctions.put("eq_Any_1__Any_1__Boolean_1_", new Eq(repository));
    this.nativeFunctions.put("equal_Any_MANY__Any_MANY__Boolean_1_", new Equal(repository));
    this.nativeFunctions.put("joinStrings_String_MANY__String_1__String_1__String_1__String_1_", new JoinStrings(repository));
    this.nativeFunctions.put("compileValueSpecification_String_m__CompilationResult_m_", new CompileValueSpecification(this.runtime));
    this.nativeFunctions.put("cast_Any_m__T_1__T_m_", new Cast(repository));
    this.nativeFunctions.put("evaluate_Function_1__List_MANY__Any_MANY_", new EvaluateAny(this));
    this.nativeFunctions.put("rawEvalProperty_Property_1__Any_1__V_m_", new RawEvalProperty(this));
    this.nativeFunctions.put("eval_Function_1__V_m_", new Evaluate(this));
    this.nativeFunctions.put("eval_Function_1__T_n__V_m_", new Evaluate(this));
    this.nativeFunctions.put("eval_Function_1__T_n__U_p__V_m_", new Evaluate(this));
    this.nativeFunctions.put("eval_Function_1__T_n__U_p__W_q__V_m_", new Evaluate(this));
    this.nativeFunctions.put("eval_Function_1__T_n__U_p__W_q__X_r__V_m_", new Evaluate(this));
    this.nativeFunctions.put("eval_Function_1__T_n__U_p__W_q__X_r__Y_s__V_m_", new Evaluate(this));
    this.nativeFunctions.put("eval_Function_1__T_n__U_p__W_q__X_r__Y_s__Z_t__V_m_", new Evaluate(this));
    this.nativeFunctions.put("eval_Function_1__S_n__T_o__U_p__W_q__X_r__Y_s__Z_t__V_m_", new Evaluate(this));
    this.nativeFunctions.put("genericType_Any_MANY__GenericType_1_", new GenericType());
    this.nativeFunctions.put("genericTypeClass_GenericType_1__Class_1_", new GenericTypeClass(repository));
    this.nativeFunctions.put("generalizations_Type_1__Type_$1_MANY$_", new Generalizations());
    this.nativeFunctions.put("sourceInformation_Any_1__SourceInformation_$0_1$_", new SourceInformation(repository));
    this.nativeFunctions.put("match_Any_MANY__Function_$1_MANY$__T_m_", new Match(this));
    this.nativeFunctions.put("match_Any_MANY__Function_$1_MANY$__P_o__T_m_", new Match(this));
    this.nativeFunctions.put("id_Any_1__String_1_", new Id(repository));
    this.nativeFunctions.put("if_Boolean_1__Function_1__Function_1__T_m_", new If(this));
    this.nativeFunctions.put("copy_T_1__String_1__KeyExpression_MANY__T_1_", new Copy(repository, this));
    this.nativeFunctions.put("copy_T_1__String_1__T_1_", new Copy(repository, this));
    this.nativeFunctions.put("size_Any_MANY__Integer_1_", new Size(repository));
    this.nativeFunctions.put("length_String_1__Integer_1_", new Length(repository));
    this.nativeFunctions.put("split_String_1__String_1__String_MANY_", new Split(repository));
    this.nativeFunctions.put("trim_String_1__String_1_", new Trim(repository));
    this.nativeFunctions.put("and_Boolean_1__Boolean_1__Boolean_1_", new And(repository, this));
    this.nativeFunctions.put("or_Boolean_1__Boolean_1__Boolean_1_", new Or(repository, this));
    this.nativeFunctions.put("not_Boolean_1__Boolean_1_", new Not(repository));
    this.nativeFunctions.put("profile_T_m__Boolean_1__ProfileResult_1_", new Profile(repository, p, this));
    this.nativeFunctions.put("sort_T_m__Function_$0_1$__Function_$0_1$__T_m_", new Sort(this));
    this.nativeFunctions.put("removeDuplicates_T_MANY__Function_$0_1$__Function_$0_1$__T_MANY_", new RemoveDuplicates(this));
    this.nativeFunctions.put("removeAllOptimized_T_MANY__T_MANY__T_MANY_", new RemoveAllOptimized(this));
    this.nativeFunctions.put("range_Integer_1__Integer_1__Integer_1__Integer_MANY_", new Range(repository));
    this.nativeFunctions.put("compare_T_1__T_1__Integer_1_", new Compare(repository));
    this.nativeFunctions.put("instanceOf_Any_1__Type_1__Boolean_1_", new InstanceOf(repository));
    this.nativeFunctions.put("subTypeOf_Type_1__Type_1__Boolean_1_", new SubTypeOf(repository));
    this.nativeFunctions.put("deactivate_Any_MANY__ValueSpecification_1_", new Deactivate());
    this.nativeFunctions.put("reactivate_ValueSpecification_1__Map_1__Any_MANY_", new Reactivate(this));
    this.nativeFunctions.put("canReactivateDynamically_ValueSpecification_1__Boolean_1_", new CanReactivateDynamically(repository));
    this.nativeFunctions.put("evaluateAndDeactivate_T_m__T_m_", new EvaluateAndDeactivate());
    this.nativeFunctions.put("toString_Any_1__String_1_", new ToString(repository, this));
    this.nativeFunctions.put("mutateAdd_T_1__String_1__Any_MANY__T_1_", new MutateAdd());
    this.nativeFunctions.put("enumName_Enumeration_1__String_1_", new EnumName(repository));
    this.nativeFunctions.put("enumValues_Enumeration_1__T_MANY_", new EnumValues());
    this.nativeFunctions.put("newClass_String_1__Class_1_", new NewClass(repository));
    this.nativeFunctions.put("newAssociation_String_1__Property_1__Property_1__Association_1_", new NewAssociation(repository));
    this.nativeFunctions.put("newProperty_String_1__GenericType_1__GenericType_1__Multiplicity_1__Property_1_", new NewProperty(repository));
    this.nativeFunctions.put("newLambdaFunction_FunctionType_1__LambdaFunction_1_", new NewLambdaFunction(repository));
    this.nativeFunctions.put("openVariableValues_Function_1__Map_1_", new OpenVariableValues(repository));
    this.nativeFunctions.put("newEnumeration_String_1__String_MANY__Enumeration_1_", new NewEnumeration(repository));
    this.nativeFunctions.put("stereotype_Profile_1__String_1__Stereotype_1_", new Stereotype());
    this.nativeFunctions.put("tag_Profile_1__String_1__Tag_1_", new Tag());
    this.nativeFunctions.put("replace_String_1__String_1__String_1__String_1_", new Replace(repository));
    SubString substring = new SubString(repository);
    this.nativeFunctions.put("substring_String_1__Integer_1__String_1_", substring);
    this.nativeFunctions.put("substring_String_1__Integer_1__Integer_1__String_1_", substring);
    this.nativeFunctions.put("contains_String_1__String_1__Boolean_1_", new Contains(repository));
    this.nativeFunctions.put("startsWith_String_1__String_1__Boolean_1_", new StartsWith(repository));
    this.nativeFunctions.put("endsWith_String_1__String_1__Boolean_1_", new EndsWith(repository));
    this.nativeFunctions.put("matches_String_1__String_1__Boolean_1_", new Matches(repository));
    IndexOfString indexOf = new IndexOfString(repository);
    this.nativeFunctions.put("indexOf_String_1__String_1__Integer_1_", indexOf);
    this.nativeFunctions.put("indexOf_String_1__String_1__Integer_1__Integer_1_", indexOf);
    this.nativeFunctions.put("toOne_T_MANY__T_1_", new ToOne(repository));
    this.nativeFunctions.put("toOneMany_T_MANY__T_$1_MANY$_", new ToOneMany(repository));
    this.nativeFunctions.put("readFile_String_1__String_$0_1$_", new ReadFile(repository, storage));
    this.nativeFunctions.put("reverse_T_m__T_m_", new Reverse());
    this.nativeFunctions.put("parseBoolean_String_1__Boolean_1_", new ParsePrimitive(repository, ModelRepository.BOOLEAN_TYPE_NAME));
    this.nativeFunctions.put("parseDate_String_1__Date_1_", new ParsePrimitive(repository, ModelRepository.DATE_TYPE_NAME));
    this.nativeFunctions.put("parseFloat_String_1__Float_1_", new ParsePrimitive(repository, ModelRepository.FLOAT_TYPE_NAME));
    this.nativeFunctions.put("parseDecimal_String_1__Decimal_1_", new ParsePrimitive(repository, ModelRepository.DECIMAL_TYPE_NAME));
    this.nativeFunctions.put("parseInteger_String_1__Integer_1_", new ParsePrimitive(repository, ModelRepository.INTEGER_TYPE_NAME));
    this.nativeFunctions.put("toInteger_String_1__Integer_1_", new ToInteger(repository));
    this.nativeFunctions.put("encodeBase64_String_1__String_1_", new EncodeBase64(repository));
    this.nativeFunctions.put("decodeBase64_String_1__String_1_", new DecodeBase64(repository));
    this.nativeFunctions.put("today__StrictDate_1_", new Today(repository));
    this.nativeFunctions.put("now__DateTime_1_", new Now(repository));
    this.nativeFunctions.put("hasSubsecond_Date_1__Boolean_1_", new HasSubsecond(repository));
    this.nativeFunctions.put("hasSubsecondWithAtLeastPrecision_Date_1__Integer_1__Boolean_1_", new HasSubsecondWithAtLeastPrecision(repository));
    this.nativeFunctions.put("hasSecond_Date_1__Boolean_1_", new HasSecond(repository));
    this.nativeFunctions.put("hasMinute_Date_1__Boolean_1_", new HasMinute(repository));
    this.nativeFunctions.put("hasHour_Date_1__Boolean_1_", new HasHour(repository));
    this.nativeFunctions.put("hasDay_Date_1__Boolean_1_", new HasDay(repository));
    this.nativeFunctions.put("hasMonth_Date_1__Boolean_1_", new HasMonth(repository));
    this.nativeFunctions.put("second_Date_1__Integer_1_", new Second(repository));
    this.nativeFunctions.put("minute_Date_1__Integer_1_", new Minute(repository));
    this.nativeFunctions.put("hour_Date_1__Integer_1_", new Hour(repository));
    this.nativeFunctions.put("dayOfMonth_Date_1__Integer_1_", new DayOfMonth(repository));
    this.nativeFunctions.put("dayOfWeekNumber_Date_1__Integer_1_", new DayOfWeekNumber(repository));
    this.nativeFunctions.put("weekOfYear_Date_1__Integer_1_", new WeekOfYear(repository));
    this.nativeFunctions.put("monthNumber_Date_1__Integer_1_", new MonthNumber(repository));
    this.nativeFunctions.put("year_Date_1__Integer_1_", new Year(repository));
    this.nativeFunctions.put("datePart_Date_1__Date_1_", new DatePart(repository));
    this.nativeFunctions.put("adjust_Date_1__Integer_1__DurationUnit_1__Date_1_", new AdjustDate(repository));
    this.nativeFunctions.put("dateDiff_Date_1__Date_1__DurationUnit_1__Integer_1_", new DateDiff(repository));
    this.nativeFunctions.put("mayExecuteLegendTest_Function_1__Function_1__X_k_", new LegendTest(repository, this));
    this.nativeFunctions.put("mayExecuteAlloyTest_Function_1__Function_1__X_k_", new AlloyTest(repository, this));
    NewDate newDate = new NewDate(repository);
    this.nativeFunctions.put("date_Integer_1__Date_1_", newDate);
    this.nativeFunctions.put("date_Integer_1__Integer_1__Date_1_", newDate);
    this.nativeFunctions.put("date_Integer_1__Integer_1__Integer_1__StrictDate_1_", newDate);
    this.nativeFunctions.put("date_Integer_1__Integer_1__Integer_1__Integer_1__DateTime_1_", newDate);
    this.nativeFunctions.put("date_Integer_1__Integer_1__Integer_1__Integer_1__Integer_1__DateTime_1_", newDate);
    this.nativeFunctions.put("date_Integer_1__Integer_1__Integer_1__Integer_1__Integer_1__Number_1__DateTime_1_", newDate);
    this.nativeFunctions.put("assert_Boolean_1__Function_1__Boolean_1_", new Assert(this));
    this.nativeFunctions.put("format_String_1__Any_MANY__String_1_", new Format(repository, this));
    this.nativeFunctions.put("toLower_String_1__String_1_", new ToLower(repository));
    this.nativeFunctions.put("toUpper_String_1__String_1_", new ToUpper(repository));
    this.nativeFunctions.put("isSourceReadOnly_String_1__Boolean_1_", new IsSourceReadOnly(this.runtime));
    this.nativeFunctions.put("currentUserId__String_1_", new CurrentUserId(repository));
    this.nativeFunctions.put("isOptionSet_String_1__Boolean_1_", new IsOptionSet(this));
    this.nativeFunctions.put("generateGuid__String_1_", new Guid(repository));
    this.nativeFunctions.put("newMap_Pair_MANY__Map_1_", new ConstructorForPairList(repository));
    this.nativeFunctions.put("newMap_Pair_MANY__Property_MANY__Map_1_", new ConstructorForPairList(repository));
    this.nativeFunctions.put("get_Map_1__U_1__V_$0_1$_", new org.finos.legend.pure.runtime.java.interpreted.natives.core.collection.map.Get());
    this.nativeFunctions.put("getIfAbsentPutWithKey_Map_1__U_1__Function_1__V_$0_1$_", new GetIfAbsentPutWithKey(this));
    this.nativeFunctions.put("getMapStats_Map_1__MapStats_$0_1$_", new GetMapStats(repository));
    this.nativeFunctions.put("put_Map_1__U_1__V_1__Map_1_", new Put());
    this.nativeFunctions.put("putAll_Map_1__Pair_MANY__Map_1_", new PutAllPairs());
    this.nativeFunctions.put("putAll_Map_1__Map_1__Map_1_", new PutAllMaps());
    this.nativeFunctions.put("keys_Map_1__U_MANY_", new Keys());
    this.nativeFunctions.put("keyValues_Map_1__Pair_MANY_", new KeyValues(repository));
    this.nativeFunctions.put("values_Map_1__V_MANY_", new Values());
    this.nativeFunctions.put("replaceAll_Map_1__Pair_MANY__Map_1_", new ReplaceAll());
    this.nativeFunctions.put("groupBy_X_MANY__Function_1__Map_1_", new GroupBy(this));
    this.nativeFunctions.put("functionDescriptorToId_String_1__String_1_", new FunctionDescriptorToId(repository));
    this.nativeFunctions.put("isValidFunctionDescriptor_String_1__Boolean_1_", new IsValidFunctionDescriptor(repository));
    Cipher cipher = new Cipher(repository);
    this.nativeFunctions.put("encrypt_String_1__String_1__String_1_", cipher);
    this.nativeFunctions.put("encrypt_Number_1__String_1__String_1_", cipher);
    this.nativeFunctions.put("encrypt_Boolean_1__String_1__String_1_", cipher);
    this.nativeFunctions.put("decrypt_String_1__String_1__String_1_", new Decipher(repository));
    this.nativeFunctions.put("hash_String_1__HashType_1__String_1_", new Hash(repository));
    for (Pair<String, Function2<FunctionExecutionInterpreted, ModelRepository, NativeFunction>> extraNative : extensions.flatCollect(e -> e.getExtraNatives())) {
        this.nativeFunctions.put(extraNative.getOne(), extraNative.getTwo().value(this, repository));
    }
}
Also used : Hash(org.finos.legend.pure.runtime.java.interpreted.natives.core.hash.Hash) Print(org.finos.legend.pure.runtime.java.interpreted.natives.core.io.Print) Assert(org.finos.legend.pure.runtime.java.interpreted.natives.core.asserts.Assert) Equal(org.finos.legend.pure.runtime.java.interpreted.natives.core._boolean.Equal) IsOptionSet(org.finos.legend.pure.runtime.java.interpreted.natives.runtime.IsOptionSet) CheckedFunction2(org.eclipse.collections.impl.block.function.checked.CheckedFunction2) Function2(org.eclipse.collections.api.block.function.Function2) ModelRepository(org.finos.legend.pure.m4.ModelRepository) Get(org.finos.legend.pure.runtime.java.interpreted.natives.core.collection.Get) CurrentUserId(org.finos.legend.pure.runtime.java.interpreted.natives.runtime.CurrentUserId) UnifiedMap(org.eclipse.collections.impl.map.mutable.UnifiedMap) MutableMap(org.eclipse.collections.api.map.MutableMap) Is(org.finos.legend.pure.runtime.java.interpreted.natives.core._boolean.Is) ReadFile(org.finos.legend.pure.runtime.java.interpreted.natives.core.io.ReadFile) Profile(org.finos.legend.pure.runtime.java.interpreted.natives.core.tools.Profile) CurrentUserId(org.finos.legend.pure.runtime.java.interpreted.natives.runtime.CurrentUserId) org.finos.legend.pure.runtime.java.interpreted.natives.core.collection.map(org.finos.legend.pure.runtime.java.interpreted.natives.core.collection.map) Cipher(org.finos.legend.pure.runtime.java.interpreted.natives.core.cipher.Cipher) Decipher(org.finos.legend.pure.runtime.java.interpreted.natives.core.cipher.Decipher) Http(org.finos.legend.pure.runtime.java.interpreted.natives.core.io.Http) Guid(org.finos.legend.pure.runtime.java.interpreted.natives.runtime.Guid) TraceSpan(org.finos.legend.pure.runtime.java.interpreted.natives.core.tracing.TraceSpan) LegendTest(org.finos.legend.pure.runtime.java.interpreted.natives.legend.LegendTest) Eq(org.finos.legend.pure.runtime.java.interpreted.natives.core._boolean.Eq) AlloyTest(org.finos.legend.pure.runtime.java.interpreted.natives.legend.AlloyTest)

Aggregations

BigDecimal (java.math.BigDecimal)2 MutableMap (org.eclipse.collections.api.map.MutableMap)2 UnifiedMap (org.eclipse.collections.impl.map.mutable.UnifiedMap)2 PureExecutionException (org.finos.legend.pure.m3.exception.PureExecutionException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 BigInteger (java.math.BigInteger)1 Map (java.util.Map)1 NoSuchElementException (java.util.NoSuchElementException)1 RichIterable (org.eclipse.collections.api.RichIterable)1 Function2 (org.eclipse.collections.api.block.function.Function2)1 CheckedFunction2 (org.eclipse.collections.impl.block.function.checked.CheckedFunction2)1 FastList (org.eclipse.collections.impl.list.mutable.FastList)1 Any (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Any)1 Class (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class)1 ConstraintsOverride (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.ConstraintsOverride)1 EnumInstance (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.EnumInstance)1 InstanceValue (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.InstanceValue)1 PureAssertFailException (org.finos.legend.pure.m3.exception.PureAssertFailException)1 InvalidFunctionDescriptorException (org.finos.legend.pure.m3.navigation.function.InvalidFunctionDescriptorException)1 ModelRepository (org.finos.legend.pure.m4.ModelRepository)1