org.finos.legend.pure.generated.FunctionsGen Maven / Gradle / Ivy
The newest version!
package org.finos.legend.pure.generated;
import org.eclipse.collections.api.RichIterable;
import org.eclipse.collections.api.block.function.Function0;
import org.eclipse.collections.api.factory.Lists;
import org.eclipse.collections.api.list.ListIterable;
import org.eclipse.collections.api.list.MutableList;
import org.eclipse.collections.impl.list.mutable.FastList;
import org.finos.legend.pure.m3.coreinstance.Package;
import org.finos.legend.pure.m3.coreinstance.meta.pure.functions.collection.Pair;
import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.ConcreteFunctionDefinition;
import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.Property;
import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Any;
import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Enum;
import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification;
import org.finos.legend.pure.m3.exception.PureExecutionException;
import org.finos.legend.pure.m3.execution.ExecutionSupport;
import org.finos.legend.pure.m3.navigation.PackageableElement.PackageableElement;
import org.finos.legend.pure.m4.coreinstance.SourceInformation;
import org.finos.legend.pure.runtime.java.compiled.delta.CodeBlockDeltaCompiler;
import org.finos.legend.pure.runtime.java.compiled.execution.CompiledExecutionSupport;
import org.finos.legend.pure.runtime.java.compiled.generation.processors.support.Bridge;
import org.finos.legend.pure.runtime.java.compiled.generation.processors.support.Pure;
import org.finos.legend.pure.runtime.java.compiled.generation.processors.support.function.defended.DefendedFunction;
import org.finos.legend.pure.runtime.java.compiled.generation.processors.support.function.defended.DefendedFunction0;
import org.finos.legend.pure.runtime.java.compiled.generation.processors.support.map.PureMap;
import org.finos.legend.pure.runtime.java.compiled.metadata.MetadataAccessor;
import org.finos.legend.pure.runtime.java.shared.http.HttpMethod;
import org.finos.legend.pure.runtime.java.shared.http.HttpRawHelper;
import org.finos.legend.pure.runtime.java.shared.http.URLScheme;
public class FunctionsGen extends org.finos.legend.pure.runtime.java.extension.functions.compiled.FunctionsHelper
{
public static Root_meta_pure_functions_io_http_HTTPResponse executeHttpRaw(Root_meta_pure_functions_io_http_URL url, Object method, String mimeType, String body, ExecutionSupport executionSupport)
{
URLScheme scheme = URLScheme.http;
if (url._scheme() != null)
{
scheme = URLScheme.valueOf(url._scheme()._name());
}
return (Root_meta_pure_functions_io_http_HTTPResponse) HttpRawHelper.toHttpResponseInstance(HttpRawHelper.executeHttpService(scheme, url._host(), (int) url._port(), url._path(), HttpMethod.valueOf(((Enum) method)._name()), mimeType, body), ((CompiledExecutionSupport) executionSupport).getProcessorSupport());
}
public static Root_meta_pure_functions_meta_CompilationResult compileCodeBlock(String source, ExecutionSupport es)
{
Root_meta_pure_functions_meta_CompilationResult result = null;
if (source != null)
{
CodeBlockDeltaCompiler.CompilationResult compilationResult = CodeBlockDeltaCompiler.compileCodeBlock(source, ((CompiledExecutionSupport) es));
result = convertCompilationResult(compilationResult);
}
return result;
}
public static RichIterable compileCodeBlocks(RichIterable extends String> sources, ExecutionSupport es)
{
RichIterable compilationResults = CodeBlockDeltaCompiler.compileCodeBlocks(sources, ((CompiledExecutionSupport) es));
MutableList results = FastList.newList(sources.size());
for (CodeBlockDeltaCompiler.CompilationResult compilationResult : compilationResults)
{
results.add(convertCompilationResult(compilationResult));
}
return results;
}
private static Root_meta_pure_functions_meta_CompilationResult convertCompilationResult(CodeBlockDeltaCompiler.CompilationResult compilationResult)
{
Root_meta_pure_functions_meta_CompilationResult result = new Root_meta_pure_functions_meta_CompilationResult_Impl("");
if (compilationResult.getFailureMessage() != null)
{
Root_meta_pure_functions_meta_CompilationFailure failure = new Root_meta_pure_functions_meta_CompilationFailure_Impl("");
failure._message(compilationResult.getFailureMessage());
SourceInformation si = compilationResult.getFailureSourceInformation();
if (si != null)
{
Root_meta_pure_functions_meta_SourceInformation sourceInformation = new Root_meta_pure_functions_meta_SourceInformation_Impl("");
sourceInformation._column(si.getColumn());
sourceInformation._line(si.getLine());
sourceInformation._endColumn(si.getEndColumn());
sourceInformation._endLine(si.getEndLine());
sourceInformation._startColumn(si.getStartColumn());
sourceInformation._startLine(si.getStartLine());
failure._sourceInformation(sourceInformation);
}
result._failure(failure);
}
else
{
ConcreteFunctionDefinition> cfd = (ConcreteFunctionDefinition>) compilationResult.getResult();
result._result(cfd._expressionSequence().getFirst());
}
return result;
}
public static Object alloyTest(ExecutionSupport es, org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.Function alloyTest, org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.Function regular)
{
return alloyTest(es, alloyTest, regular, CoreGen.bridge);
}
public static Object legendTest(ExecutionSupport es, org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.Function alloyTest, org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.Function regular)
{
return legendTest(es, alloyTest, regular, CoreGen.bridge);
}
public static PureMap newMap(RichIterable extends org.finos.legend.pure.m3.coreinstance.meta.pure.functions.collection.Pair, ?>> pairs, RichIterable extends Property, ?>> properties, ExecutionSupport es)
{
return newMap(pairs, properties, CoreGen.bridge, es);
}
public static RichIterable> zip(Object l1, Object l2)
{
return zip(l1, l2, new DefendedFunction0>()
{
@Override
public org.finos.legend.pure.m3.coreinstance.meta.pure.functions.collection.Pair value()
{
return new Root_meta_pure_functions_collection_Pair_Impl("");
}
});
}
public static RichIterable> zip(RichIterable extends U> l1, RichIterable extends V> l2)
{
return zip(l1, l2, new DefendedFunction0>()
{
@Override
public org.finos.legend.pure.m3.coreinstance.meta.pure.functions.collection.Pair value()
{
return new Root_meta_pure_functions_collection_Pair_Impl("");
}
});
}
public static RichIterable> zip(Object l1, Object l2, Function0 extends Pair> pairBuilder)
{
return zipImpl((RichIterable extends U>) l1, (RichIterable extends V>) l2, pairBuilder);
}
public static RichIterable> zip(RichIterable extends U> l1, RichIterable extends V> l2, final Function0 extends org.finos.legend.pure.m3.coreinstance.meta.pure.functions.collection.Pair> pairBuilder)
{
return zipImpl(l1, l2, pairBuilder);
}
private static RichIterable> zipImpl(RichIterable extends U> l1, RichIterable extends V> l2, final Function0 extends org.finos.legend.pure.m3.coreinstance.meta.pure.functions.collection.Pair> pairBuilder)
{
return l1 == null || l2 == null ? FastList.>newList() : l1.zip(l2).collect(new DefendedFunction, Pair>()
{
@Override
public org.finos.legend.pure.m3.coreinstance.meta.pure.functions.collection.Pair valueOf(org.eclipse.collections.api.tuple.Pair extends U, ? extends V> pair)
{
return pairBuilder.value()._first(pair.getOne())._second(pair.getTwo());
}
});
}
public static Object dynamicMatchWith(Object obj, RichIterable> funcs, Object var, ExecutionSupport es)
{
return FunctionsGen.dynamicMatchWith(obj, funcs, var, CoreGen.bridge, es);
}
public static org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class newClass(String fullPathString, MetadataAccessor ma, SourceInformation si)
{
ListIterable fullPath = PackageableElement.splitUserPath(fullPathString);
if (fullPath.isEmpty())
{
throw new PureExecutionException(null, "Cannot create a new Class: '" + fullPathString + "'");
}
String name = fullPath.getLast();
org.finos.legend.pure.m3.coreinstance.Package _package = Pure.buildPackageIfNonExistent(new Package_Impl("Root")._name("Root"), fullPath.subList(0, fullPath.size() - 1), si, new DefendedFunction()
{
@Override
public Package valueOf(String s)
{
return new Package_Impl(s);
}
});
org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class _class = new Root_meta_pure_metamodel_type_Class_Impl(name)._name(name)._package(_package);
return _class._classifierGenericType(
new Root_meta_pure_metamodel_type_generics_GenericType_Impl("Anonymous_StripedId")
._rawType(ma.getClass("Root::meta::pure::metamodel::type::Class"))
._typeArguments(Lists.immutable.of(new Root_meta_pure_metamodel_type_generics_GenericType_Impl("Anonymous_StripedId")._rawType(_class))))
._generalizations(Lists.immutable.of(
new Root_meta_pure_metamodel_relationship_Generalization_Impl("Anonymous_StripedId")
._general(new Root_meta_pure_metamodel_type_generics_GenericType_Impl("Anonymous_StripedId")._rawType(ma.getTopType()))
._specific(_class)));
}
public static org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relationship.Association newAssociation(String fullPathString, Property p1, Property p2, MetadataAccessor ma, SourceInformation si)
{
ListIterable fullPath = PackageableElement.splitUserPath(fullPathString);
if (fullPath.isEmpty())
{
throw new PureExecutionException(null, "Cannot create a new Association: '" + fullPathString + "'");
}
String name = fullPath.getLast();
org.finos.legend.pure.m3.coreinstance.Package _package = Pure.buildPackageIfNonExistent(new Package_Impl("Root")._name("Root"), fullPath.subList(0, fullPath.size() - 1), si, new DefendedFunction()
{
@Override
public Package valueOf(String s)
{
return new Package_Impl(s);
}
});
org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relationship.Association _association = new Root_meta_pure_metamodel_relationship_Association_Impl(name)._name(name)._package(_package);
return _association._propertiesAdd(p1)._propertiesAdd(p2)._classifierGenericType(
new Root_meta_pure_metamodel_type_generics_GenericType_Impl("Anonymous_StripedId")
._rawType(ma.getClass("Root::meta::pure::metamodel::relationship::Association")));
}
public static org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Enumeration newEnumeration(final String fullPathString, RichIterable values, MetadataAccessor ma, SourceInformation si)
{
ListIterable fullPath = PackageableElement.splitUserPath(fullPathString);
if (fullPath.isEmpty())
{
throw new PureExecutionException(null, "Cannot create a new Enumeration: '" + fullPathString + "'");
}
String name = fullPath.getLast();
String packageName = fullPath.subList(0, fullPath.size() - 1).makeString("::");
org.finos.legend.pure.m3.coreinstance.Package _package = Pure.buildPackageIfNonExistent(new Package_Impl("Root")._name("Root"), fullPath.subList(0, fullPath.size() - 1), si, new DefendedFunction()
{
@Override
public Package valueOf(String s)
{
return new Package_Impl(s);
}
});
org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Enumeration _enumeration = new Root_meta_pure_metamodel_type_Enumeration_Impl(name)._name(name)._package(_package);
return _enumeration._classifierGenericType(
new Root_meta_pure_metamodel_type_generics_GenericType_Impl("Anonymous_StripedId")
._rawType(ma.getClass("Root::meta::pure::metamodel::type::Enumeration"))
._typeArguments(Lists.immutable.of(new Root_meta_pure_metamodel_type_generics_GenericType_Impl("Anonymous_StripedId")._rawType(_enumeration))))
._generalizations(Lists.immutable.of(
new Root_meta_pure_metamodel_relationship_Generalization_Impl("Anonymous_StripedId")
._general(new Root_meta_pure_metamodel_type_generics_GenericType_Impl("Anonymous_StripedId")._rawType(ma.getClass("Root::meta::pure::metamodel::type::Enum")))
._specific(_enumeration)))
._values(values.collect(new DefendedFunction()
{
public PureEnum valueOf(String valueName)
{
return new PureEnum(valueName, fullPathString);
}
}));
}
public static PureMap getOpenVariables(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.Function> func)
{
return Pure.getOpenVariables(func, CoreGen.bridge);
}
public static Object reactivate(ValueSpecification valueSpecification, PureMap lambdaOpenVariablesMap, ExecutionSupport es)
{
return Pure.reactivate(valueSpecification, lambdaOpenVariablesMap, true, CoreGen.bridge, es);
}
public static Object reactivate(ValueSpecification valueSpecification, PureMap lambdaOpenVariablesMap, boolean allowJavaCompilation, ExecutionSupport es)
{
return Pure.reactivate(valueSpecification, lambdaOpenVariablesMap, allowJavaCompilation, CoreGen.bridge, es);
}
public static Object traceSpan(ExecutionSupport es, org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.Function function, String operationName, org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.Function funcToGetTags, boolean tagsCritical)
{
return FunctionsGen.traceSpan(es, function, operationName, funcToGetTags, tagsCritical, CoreGen.bridge);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy