• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

leeonky / test-charm-java / 156

20 Mar 2025 01:53PM UTC coverage: 74.243% (-0.2%) from 74.475%
156

push

circleci

leeonky
Refactor

14 of 15 new or added lines in 12 files covered. (93.33%)

126 existing lines in 29 files now uncovered.

7947 of 10704 relevant lines covered (74.24%)

0.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.81
/DAL-java/src/main/java/com/github/leeonky/dal/runtime/RuntimeContextBuilder.java
1
package com.github.leeonky.dal.runtime;
2

3
import com.github.leeonky.dal.ast.node.DALNode;
4
import com.github.leeonky.dal.ast.opt.DALOperator;
5
import com.github.leeonky.dal.format.Formatter;
6
import com.github.leeonky.dal.runtime.checker.Checker;
7
import com.github.leeonky.dal.runtime.checker.CheckerSet;
8
import com.github.leeonky.dal.runtime.inspector.Dumper;
9
import com.github.leeonky.dal.runtime.inspector.DumperFactory;
10
import com.github.leeonky.dal.runtime.schema.Expect;
11
import com.github.leeonky.dal.type.ExtensionName;
12
import com.github.leeonky.dal.type.InputCode;
13
import com.github.leeonky.dal.type.Schema;
14
import com.github.leeonky.interpreter.RuntimeContext;
15
import com.github.leeonky.interpreter.SyntaxException;
16
import com.github.leeonky.util.*;
17

18
import java.io.PrintStream;
19
import java.lang.reflect.Array;
20
import java.lang.reflect.Method;
21
import java.lang.reflect.Modifier;
22
import java.util.*;
23
import java.util.function.BiFunction;
24
import java.util.function.BiPredicate;
25
import java.util.function.Function;
26
import java.util.function.Supplier;
27
import java.util.stream.Collectors;
28
import java.util.stream.Stream;
29

30
import static com.github.leeonky.dal.runtime.CurryingMethod.createCurryingMethod;
31
import static com.github.leeonky.dal.runtime.ExpressionException.illegalOp2;
32
import static com.github.leeonky.dal.runtime.ExpressionException.illegalOperation;
33
import static com.github.leeonky.dal.runtime.schema.Actual.actual;
34
import static com.github.leeonky.dal.runtime.schema.Verification.expect;
35
import static com.github.leeonky.util.Classes.getClassName;
36
import static com.github.leeonky.util.Classes.named;
37
import static com.github.leeonky.util.CollectionHelper.toStream;
38
import static java.lang.String.format;
39
import static java.lang.reflect.Modifier.STATIC;
40
import static java.util.Arrays.stream;
41
import static java.util.Collections.emptySet;
42
import static java.util.Optional.of;
43
import static java.util.stream.Collectors.joining;
44
import static java.util.stream.Collectors.toList;
45

46
public class RuntimeContextBuilder {
1✔
47
    private final ClassKeyMap<PropertyAccessor<Object>> propertyAccessors = new ClassKeyMap<>();
1✔
48
    private final ClassKeyMap<DALCollectionFactory<Object, Object>> dALCollectionFactories = new ClassKeyMap<>();
1✔
49
    private final ClassKeyMap<Function<Object, Object>> objectImplicitMapper = new ClassKeyMap<>();
1✔
50
    private final Map<String, ConstructorViaSchema> valueConstructors = new LinkedHashMap<>();
1✔
51
    private final Map<String, BeanClass<?>> schemas = new HashMap<>();
1✔
52
    private final Set<Method> extensionMethods = new HashSet<>();
1✔
53
    private final Map<Object, Function<MetaData, Object>> metaProperties = new HashMap<>();
1✔
54
    private final ClassKeyMap<Function<RemarkData, Data>> remarks = new ClassKeyMap<>();
1✔
55
    private final ClassKeyMap<Function<RuntimeData, Data>> exclamations = new ClassKeyMap<>();
1✔
56
    private final List<UserLiteralRule> userDefinedLiterals = new ArrayList<>();
1✔
57
    private final NumberType numberType = new NumberType();
1✔
58
    private final Map<Method, BiFunction<Object, List<Object>, List<Object>>> curryingMethodArgRanges = new HashMap<>();
1✔
59
    private final Map<String, TextFormatter<?, ?>> textFormatterMap = new LinkedHashMap<>();
1✔
60
    private final Map<Operators, LinkedList<Operation>> operations = new HashMap<>();
1✔
61
    private Converter converter = Converter.getInstance();
1✔
62
    private final ClassKeyMap<DumperFactory> dumperFactories = new ClassKeyMap<>();
1✔
63
    private final CheckerSet checkerSetForMatching = new CheckerSet(CheckerSet::defaultMatching);
1✔
64
    private final CheckerSet checkerSetForEqualing = new CheckerSet(CheckerSet::defaultEqualing);
1✔
65
    //    private final
66
    private int maxDumpingLineSize = 2000;
1✔
67
    private int maxDumpingObjectSize = 255;
1✔
68
    private ErrorHook errorHook = (i, code, e) -> false;
1✔
69
    private final Map<Class<?>, Map<Object, Function<MetaData, Object>>> localMetaProperties
1✔
70
            = new TreeMap<>(Classes::compareByExtends);
71
    private PrintStream warning = System.err;
1✔
72
    private final Features features = new Features();
1✔
73

74
    public RuntimeContextBuilder registerMetaProperty(Object property, Function<MetaData, Object> function) {
75
        metaProperties.put(property, function);
1✔
76
        return this;
1✔
77
    }
78

79
    public RuntimeContextBuilder registerTextFormatter(String name, TextFormatter<?, ?> formatter) {
80
        textFormatterMap.put(name, formatter);
1✔
81
        return this;
1✔
82
    }
83

84
    public DALRuntimeContext build(Object inputValue) {
85
        return build(() -> inputValue, null);
1✔
86
    }
87

88
    public DALRuntimeContext build(InputCode<?> inputSupplier) {
89
        return build(inputSupplier, null);
1✔
90
    }
91

92
    public DALRuntimeContext build(InputCode<?> inputSupplier, Class<?> rootSchema) {
93
        if (inputSupplier == null)
1✔
94
            return new DALRuntimeContext(() -> null, rootSchema);
1✔
95
        return new DALRuntimeContext(inputSupplier, rootSchema);
1✔
96
    }
97

98
    public RuntimeContextBuilder registerValueFormat(Formatter<?, ?> formatter) {
99
        return registerValueFormat(formatter.getFormatterName(), formatter);
1✔
100
    }
101

102
    @SuppressWarnings("unchecked")
103
    public RuntimeContextBuilder registerValueFormat(String name, Formatter<?, ?> formatter) {
104
        valueConstructors.put(name, (o, c) -> ((Formatter<Object, ?>) formatter).transform(o.instance()));
1✔
105
        return this;
1✔
106
    }
107

108
    public RuntimeContextBuilder registerSchema(Class<? extends Schema> schema) {
109
        return registerSchema(NameStrategy.SIMPLE_NAME, schema);
1✔
110
    }
111

112
    @SuppressWarnings("unchecked")
113
    public RuntimeContextBuilder registerSchema(String name, Class<? extends Schema> schema) {
114
        schemas.put(name, BeanClass.create(schema));
1✔
115
        return registerSchema(name, (data, context) ->
1✔
116
                expect(new Expect(BeanClass.create((Class) schema), null)).verify(context, actual(data)));
1✔
117
    }
118

119
    public RuntimeContextBuilder registerSchema(String name, BiFunction<Data, DALRuntimeContext, Boolean> predicate) {
120
        valueConstructors.put(name, (o, context) -> {
1✔
121
            if (predicate.apply(o, context))
1✔
122
                return o.instance();
1✔
UNCOV
123
            throw new IllegalTypeException();
×
124
        });
125
        return this;
1✔
126
    }
127

128
    @SuppressWarnings("unchecked")
129
    public <T> RuntimeContextBuilder registerPropertyAccessor(Class<T> type, PropertyAccessor<? extends T> propertyAccessor) {
130
        propertyAccessors.put(type, (PropertyAccessor<Object>) propertyAccessor);
1✔
131
        return this;
1✔
132
    }
133

134
    @SuppressWarnings("unchecked")
135
    public <T, E> RuntimeContextBuilder registerDALCollectionFactory(Class<T> type, DALCollectionFactory<T, E> DALCollectionFactory) {
136
        dALCollectionFactories.put(type, (DALCollectionFactory<Object, Object>) DALCollectionFactory);
1✔
137
        return this;
1✔
138
    }
139

140
    public RuntimeContextBuilder registerSchema(NameStrategy nameStrategy, Class<? extends Schema> schema) {
141
        return registerSchema(nameStrategy.toName(schema), schema);
1✔
142
    }
143

144
    public RuntimeContextBuilder registerStaticMethodExtension(Class<?> staticMethodExtensionClass) {
145
        Stream.of(staticMethodExtensionClass.getMethods()).filter(method -> method.getParameterCount() >= 1
1✔
146
                && (STATIC & method.getModifiers()) != 0).forEach(extensionMethods::add);
1✔
147
        return this;
1✔
148
    }
149

150
    @SuppressWarnings("unchecked")
151
    public <T> RuntimeContextBuilder registerImplicitData(Class<T> type, Function<T, Object> mapper) {
152
        objectImplicitMapper.put(type, (Function) mapper);
1✔
153
        return this;
1✔
154
    }
155

156
    public Converter getConverter() {
157
        return converter;
×
158
    }
159

160
    public RuntimeContextBuilder setConverter(Converter converter) {
UNCOV
161
        this.converter = converter;
×
UNCOV
162
        return this;
×
163
    }
164

165
    public RuntimeContextBuilder registerUserDefinedLiterals(UserLiteralRule rule) {
166
        userDefinedLiterals.add(rule);
1✔
167
        return this;
1✔
168
    }
169

170
    public RuntimeContextBuilder registerCurryingMethodAvailableParameters(Method method, BiFunction<Object,
171
            List<Object>, List<Object>> range) {
172
        curryingMethodArgRanges.put(method, range);
1✔
173
        return this;
1✔
174
    }
175

176
    private Set<Method> methodToCurrying(Class<?> type, Object methodName) {
177
        return Stream.of(stream(type.getMethods()).filter(method -> !Modifier.isStatic(method.getModifiers()))
1✔
178
                                .filter(method -> method.getName().equals(methodName)),
1✔
179
                        staticMethodsToCurrying(type, methodName, Object::equals),
1✔
180
                        staticMethodsToCurrying(type, methodName, Class::isAssignableFrom))
1✔
181
                .flatMap(Function.identity()).collect(Collectors.toCollection(LinkedHashSet::new));
1✔
182
    }
183

184
    private Stream<Method> staticMethodsToCurrying(Class<?> type, Object property,
185
                                                   BiPredicate<Class<?>, Class<?>> condition) {
186
        return extensionMethods.stream()
1✔
187
                .filter(method -> staticExtensionMethodName(method).equals(property))
1✔
188
                .filter(method -> condition.test(method.getParameters()[0].getType(), type));
1✔
189
    }
190

191
    private static String staticExtensionMethodName(Method method) {
192
        ExtensionName extensionName = method.getAnnotation(ExtensionName.class);
1✔
193
        return extensionName != null ? extensionName.value() : method.getName();
1✔
194
    }
195

196
    BiFunction<Object, List<Object>, List<Object>> fetchCurryingMethodArgRange(Method method) {
UNCOV
197
        return curryingMethodArgRanges.get(method);
×
198
    }
199

200
    public CheckerSet checkerSetForMatching() {
201
        return checkerSetForMatching;
1✔
202
    }
203

204
    public CheckerSet checkerSetForEqualing() {
205
        return checkerSetForEqualing;
1✔
206
    }
207

208
    public RuntimeContextBuilder registerDumper(Class<?> type, DumperFactory factory) {
209
        dumperFactories.put(type, factory);
1✔
210
        return this;
1✔
211
    }
212

213
    public void setMaxDumpingLineSize(int size) {
214
        maxDumpingLineSize = size;
1✔
215
    }
1✔
216

217
    public <T> RuntimeContextBuilder registerErrorHook(ErrorHook hook) {
218
        errorHook = Objects.requireNonNull(hook);
1✔
219
        return this;
1✔
220
    }
221

222
    public void mergeTextFormatter(String name, String other, String... others) {
223
        TextFormatter formatter = textFormatterMap.get(other);
1✔
224
        for (String o : others)
1✔
225
            formatter = formatter.merge(textFormatterMap.get(o));
1✔
226
        registerTextFormatter(name, delegateFormatter(formatter, "Merged from " + other + " " + String.join(" ", others)));
1✔
227
    }
1✔
228

229
    private TextFormatter delegateFormatter(TextFormatter formatter, final String description) {
230
        return new TextFormatter() {
1✔
231
            @Override
232
            protected Object format(Object content, TextAttribute attribute, DALRuntimeContext context) {
UNCOV
233
                return formatter.format(content, attribute, context);
×
234
            }
235

236
            @Override
237
            protected TextAttribute attribute(TextAttribute attribute) {
UNCOV
238
                return formatter.attribute(attribute);
×
239
            }
240

241
            @Override
242
            public Class<?> returnType() {
243
                return formatter.returnType();
1✔
244
            }
245

246
            @Override
247
            public Class<?> acceptType() {
248
                return formatter.acceptType();
1✔
249
            }
250

251
            @Override
252
            public String description() {
253
                return description;
1✔
254
            }
255
        };
256
    }
257

258
    public RuntimeContextBuilder registerMetaProperty(Class<?> type, Object name, Function<MetaData, Object> function) {
259
        localMetaProperties.computeIfAbsent(type, k -> new HashMap<>()).put(name, function);
1✔
260
        return this;
1✔
261
    }
262

263
    public RuntimeContextBuilder registerDataRemark(Class<?> type, Function<RemarkData, Data> action) {
264
        remarks.put(type, action);
1✔
265
        return this;
1✔
266
    }
267

268
    public RuntimeContextBuilder registerExclamation(Class<?> type, Function<RuntimeData, Data> action) {
269
        exclamations.put(type, action);
1✔
270
        return this;
1✔
271
    }
272

273
    public RuntimeContextBuilder registerOperator(Operators operator, Operation operation) {
274
        operations.computeIfAbsent(operator, o -> new LinkedList<>()).addFirst(operation);
1✔
275
        return this;
1✔
276
    }
277

278
    public BeanClass<?> schemaType(String schema) {
279
        BeanClass<?> type = schemas.get(schema);
1✔
280
        if (type != null)
1✔
281
            return type;
1✔
282
        throw new IllegalStateException(format("Unknown schema '%s'", schema));
×
283
    }
284

285
    public void setMaxDumpingObjectSize(int maxDumpingObjectSize) {
UNCOV
286
        this.maxDumpingObjectSize = maxDumpingObjectSize;
×
UNCOV
287
    }
×
288

289
    public RuntimeContextBuilder setWarningOutput(PrintStream printStream) {
290
        warning = printStream;
1✔
291
        return this;
1✔
292
    }
293

294
    public Features features() {
295
        return features;
1✔
296
    }
297

298
    public class DALRuntimeContext implements RuntimeContext {
299
        private final LinkedList<Data> stack = new LinkedList<>();
1✔
300
        private final Map<Data, PartialPropertyStack> partialPropertyStacks;
301

302
        public Features features() {
303
            return features;
1✔
304
        }
305

306
        public DALRuntimeContext(InputCode<?> supplier, Class<?> schema) {
1✔
307
            BeanClass<?> rootSchema = null;
1✔
308
            if (schema != null)
1✔
309
                rootSchema = BeanClass.create(schema);
1✔
310
            stack.push(wrap(() -> {
1✔
311
                try {
312
                    return supplier.get();
1✔
313
                } catch (Exception e) {
1✔
314
                    throw new UserRuntimeException(e);
1✔
315
                }
316
            }, rootSchema));
317
            partialPropertyStacks = new HashMap<>();
1✔
318
        }
1✔
319

320
        public Data getThis() {
321
            return stack.getFirst();
1✔
322
        }
323

324
        public <T> T pushAndExecute(Data data, Supplier<T> supplier) {
325
            try {
326
                stack.push(data);
1✔
327
                return supplier.get();
1✔
328
            } finally {
329
                stack.pop();
1✔
330
            }
331
        }
332

333
        public Optional<ConstructorViaSchema> searchValueConstructor(String type) {
334
            return Optional.ofNullable(valueConstructors.get(type));
1✔
335
        }
336

337
        public Set<?> findPropertyReaderNames(Object instance) {
338
            return getObjectPropertyAccessor(instance).getPropertyNames(instance);
1✔
339
        }
340

341
        public PropertyAccessor<Object> getObjectPropertyAccessor(Object instance) {
342
            return propertyAccessors.tryGetData(instance)
1✔
343
                    .orElseGet(() -> new JavaClassPropertyAccessor<>(BeanClass.createFrom(instance)));
1✔
344
        }
345

346
        public Boolean isNull(Object instance) {
347
            return propertyAccessors.tryGetData(instance).map(f -> f.isNull(instance))
1✔
348
                    .orElseGet(() -> Objects.equals(instance, null));
1✔
349
        }
350

351
        public DALCollection<Object> createCollection(Object instance) {
352
            return dALCollectionFactories.tryGetData(instance).map(factory -> factory.create(instance))
1✔
353
                    .orElseGet(() -> new CollectionDALCollection<>(toStream(instance).collect(toList())));
1✔
354
        }
355

356
        public boolean isRegisteredList(Object instance) {
357
            return dALCollectionFactories.tryGetData(instance).map(f -> f.isList(instance)).orElse(false);
1✔
358
        }
359

360
        public Converter getConverter() {
361
            return converter;
1✔
362
        }
363

364
        //        TODO check use supplier
365
        @Deprecated
366
        public Data wrap(Object instance) {
367
            return wrap(instance, null);
1✔
368
        }
369

370
        @Deprecated
371
        public Data wrap(Object instance, String schema, boolean isList) {
UNCOV
372
            BeanClass<?> schemaType = schemas.get(schema);
×
UNCOV
373
            if (isList && schemaType != null)
×
UNCOV
374
                schemaType = BeanClass.create(Array.newInstance(schemaType.getType(), 0).getClass());
×
UNCOV
375
            return wrap(instance, schemaType);
×
376
        }
377

378
        @Deprecated
379
        public Data wrap(ThrowingSupplier<?> instance, String schema, boolean isList) {
380
            BeanClass<?> schemaType = schemas.get(schema);
1✔
381
            if (isList && schemaType != null)
1✔
382
                schemaType = BeanClass.create(Array.newInstance(schemaType.getType(), 0).getClass());
1✔
383
            return wrap(instance, schemaType);
1✔
384
        }
385

386
        @Deprecated
387
        public Data wrap(Object instance, BeanClass<?> schemaType) {
388
            return new Data(() -> instance, this, SchemaType.create(schemaType));
1✔
389
        }
390

391
        public Data wrap(ThrowingSupplier<?> supplier, BeanClass<?> schemaType) {
392
            return new Data(supplier, this, SchemaType.create(schemaType));
1✔
393
        }
394

395
        public Data wrap(ThrowingSupplier<?> instance) {
396
            return wrap(instance, null);
1✔
397
        }
398

399
        public Data data(Object instance) {
400
            return wrap(() -> instance, null);
1✔
401
        }
402

403
        public Optional<Result> takeUserDefinedLiteral(String token) {
404
            return userDefinedLiterals.stream().map(userLiteralRule -> userLiteralRule.compile(token))
1✔
405
                    .filter(Result::hasResult)
1✔
406
                    .findFirst();
1✔
407
        }
408

409
        public void appendPartialPropertyReference(Data data, Object symbol) {
410
            fetchPartialProperties(data).map(partialProperties -> partialProperties.appendPartialProperties(symbol));
1✔
411
        }
1✔
412

413
        private Optional<PartialProperties> fetchPartialProperties(Data data) {
414
            return partialPropertyStacks.values().stream().map(partialPropertyStack ->
1✔
415
                    partialPropertyStack.fetchPartialProperties(data)).filter(Objects::nonNull).findFirst();
1✔
416
        }
417

418
        public void initPartialPropertyStack(Data instance, Object prefix, Data partial) {
419
            partialPropertyStacks.computeIfAbsent(instance, _key -> fetchPartialProperties(instance)
1✔
420
                    .map(partialProperties -> partialProperties.partialPropertyStack)
1✔
421
                    .orElseGet(PartialPropertyStack::new)).setupPartialProperties(prefix, partial);
1✔
422
        }
1✔
423

424
        public Set<String> collectPartialProperties(Data instance) {
425
            PartialPropertyStack partialPropertyStack = partialPropertyStacks.get(instance);
1✔
426
            if (partialPropertyStack != null)
1✔
427
                return partialPropertyStack.collectPartialProperties(instance);
1✔
428
            return fetchPartialProperties(instance).map(partialProperties ->
1✔
429
                    partialProperties.partialPropertyStack.collectPartialProperties(instance)).orElse(emptySet());
1✔
430
        }
431

432
        public NumberType getNumberType() {
433
            return numberType;
1✔
434
        }
435

436
        public Optional<Object> getImplicitObject(Object obj) {
437
            return objectImplicitMapper.tryGetData(obj).map(mapper -> mapper.apply(obj));
1✔
438
        }
439

440
        public Set<Method> methodToCurrying(Class<?> type, Object methodName) {
441
            return RuntimeContextBuilder.this.methodToCurrying(type, methodName);
1✔
442
        }
443

444
        public Function<MetaData, Object> fetchGlobalMetaFunction(MetaData metaData) {
445
            return metaProperties.computeIfAbsent(metaData.name(), k -> {
1✔
446
                throw illegalOp2(format("Meta property `%s` not found", metaData.name()));
1✔
447
            });
448
        }
449

450
        private Optional<Function<MetaData, Object>> fetchLocalMetaFunction(MetaData metaData) {
451
            return metaFunctionsByType(metaData).map(e -> {
1✔
452
                metaData.addCallType(e.getKey());
1✔
453
                return e.getValue().get(metaData.name());
1✔
454
            }).filter(Objects::nonNull).findFirst();
1✔
455
        }
456

457
        public Optional<Function<MetaData, Object>> fetchSuperMetaFunction(MetaData metaData) {
458
            return metaFunctionsByType(metaData)
1✔
459
                    .filter(e -> !metaData.calledBy(e.getKey()))
1✔
460
                    .map(e -> {
1✔
461
                        metaData.addCallType(e.getKey());
1✔
462
                        return e.getValue().get(metaData.name());
1✔
463
                    }).filter(Objects::nonNull).findFirst();
1✔
464
        }
465

466
        private Stream<Map.Entry<Class<?>, Map<Object, Function<MetaData, Object>>>> metaFunctionsByType(MetaData metaData) {
467
            return localMetaProperties.entrySet().stream().filter(e -> metaData.isInstance(e.getKey()));
1✔
468
        }
469

470
        @SuppressWarnings("unchecked")
471
        public <T> TextFormatter<String, T> fetchFormatter(String name, int position) {
472
            return (TextFormatter<String, T>) textFormatterMap.computeIfAbsent(name, attribute -> {
1✔
473
                throw new SyntaxException(format("Invalid text formatter `%s`, all supported formatters are:\n%s",
1✔
474
                        attribute, textFormatterMap.entrySet().stream().map(e -> format("  %s:\n    %s",
1✔
475
                                e.getKey(), e.getValue().fullDescription())).collect(joining("\n"))), position);
1✔
476
            });
477
        }
478

479
        public Checker fetchEqualsChecker(Data expected, Data actual) {
480
            return checkerSetForEqualing.fetch(expected, actual);
1✔
481
        }
482

483
        public Checker fetchMatchingChecker(Data expected, Data actual) {
484
            return checkerSetForMatching.fetch(expected, actual);
1✔
485
        }
486

487
        public Dumper fetchDumper(Data.Resolved data) {
488
            return dumperFactories.tryGetData(data.value()).map(factory -> factory.apply(data)).orElseGet(() -> {
1✔
489
                if (data.isNull())
1✔
490
                    return (_data, dumpingContext) -> dumpingContext.append("null");
1✔
491
                if (data.isList())
1✔
492
                    return Dumper.LIST_DUMPER;
1✔
493
                if (data.isEnum())
1✔
494
                    return Dumper.VALUE_DUMPER;
1✔
495
                return Dumper.MAP_DUMPER;
1✔
496
            });
497
        }
498

499
        public int maxDumpingLineCount() {
500
            return maxDumpingLineSize;
1✔
501
        }
502

503
        public int maxDumpingObjectSize() {
504
            return maxDumpingObjectSize;
1✔
505
        }
506

507
        public boolean hookError(String expression, Throwable error) {
508
            return errorHook.handle(getThis(), expression, error);
1✔
509
        }
510

511
        public Data invokeMetaProperty(DALNode inputNode, Data inputData, Object symbolName) {
512
            return wrap(() -> {
1✔
513
                MetaData metaData = new MetaData(inputNode, inputData, symbolName, this);
1✔
514
                return fetchLocalMetaFunction(metaData).orElseGet(() -> fetchGlobalMetaFunction(metaData)).apply(metaData);
1✔
515
            }).onError(DalException::buildUserRuntimeException);
1✔
516
        }
517

518
        public Data invokeDataRemark(RemarkData remarkData) {
519
            return wrap(() -> {
1✔
520
                Object instance = remarkData.data().instance();
1✔
521
                return remarks.tryGetData(instance)
1✔
522
                        .orElseThrow(() -> illegalOperation("Not implement operator () of " + getClassName(instance)))
1✔
523
                        .apply(remarkData).instance();
1✔
524
            });
525
        }
526

527
        public Data invokeExclamations(ExclamationData exclamationData) {
528
            return wrap(() -> {
1✔
529
                Object instance = exclamationData.data().instance();
1✔
530
                return exclamations.tryGetData(instance)
1✔
531
                        .orElseThrow(() -> illegalOp2(format("Not implement operator %s of %s",
1✔
532
                                exclamationData.label(), Classes.getClassName(instance))))
1✔
533
                        .apply(exclamationData).instance();
1✔
534
            });
535
        }
536

537
        public Data calculate(Data v1, DALOperator opt, Data v2) {
538
            return wrap(() -> {
1✔
539
                for (Operation operation : operations.get(opt.overrideType()))
1✔
540
                    if (operation.match(v1, opt, v2, this))
1✔
541
                        return operation.operate(v1, opt, v2, this).instance();
1✔
542
                throw illegalOperation(format("No operation `%s` between '%s' and '%s'", opt.overrideType(),
1✔
543
                        getClassName(v1.instance()), getClassName(v2.instance())));
1✔
544
            });
545
        }
546

547
        public PrintStream warningOutput() {
548
            return warning;
1✔
549
        }
550

551
        public BiFunction<Object, List<Object>, List<Object>> fetchCurryingMethodArgRange(Method method) {
552
            return curryingMethodArgRanges.get(method);
1✔
553
        }
554

555
        public Optional<CurryingMethod> currying(Object instance, Object property) {
556
            List<InstanceCurryingMethod> methods = methodToCurrying(named(instance.getClass()), property).stream()
1✔
557
                    .map(method -> createCurryingMethod(instance, method, getConverter(), this)).collect(toList());
1✔
558
            if (!methods.isEmpty())
1✔
559
                return of(new CurryingMethodGroup(methods, null));
1✔
560
            return getImplicitObject(instance).flatMap(obj -> currying(obj, property));
1✔
561
        }
562
    }
563
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc