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

leeonky / test-charm-java / 206

09 Apr 2025 01:43AM UTC coverage: 74.136% (+4.0%) from 70.149%
206

push

circleci

leeonky
Update log version

8003 of 10795 relevant lines covered (74.14%)

0.74 hits per line

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

95.58
/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.*;
24
import java.util.stream.Collectors;
25
import java.util.stream.Stream;
26

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

277
    @SuppressWarnings("unchecked")
278
    public <T> RuntimeContextBuilder registerCustomSorter(Class<T> type, Function<T, Comparable<?>> sorter) {
279
        customSorters.put(type, (Function<Object, Comparable<?>>) sorter);
1✔
280
        return this;
1✔
281
    }
282

283
    public BeanClass<?> schemaType(String schema) {
284
        BeanClass<?> type = schemas.get(schema);
1✔
285
        if (type != null)
1✔
286
            return type;
1✔
287
        throw new IllegalStateException(format("Unknown schema '%s'", schema));
×
288
    }
289

290
    public void setMaxDumpingObjectSize(int maxDumpingObjectSize) {
291
        this.maxDumpingObjectSize = maxDumpingObjectSize;
×
292
    }
×
293

294
    public RuntimeContextBuilder setWarningOutput(PrintStream printStream) {
295
        warning = printStream;
1✔
296
        return this;
1✔
297
    }
298

299
    public RuntimeContextBuilder registerReturnHook(Consumer<Data> hook) {
300
        returnHook = returnHook.andThen(hook);
1✔
301
        return this;
1✔
302
    }
303

304
    public Features features() {
305
        return features;
1✔
306
    }
307

308
    public class DALRuntimeContext implements RuntimeContext {
309
        private final LinkedList<Data> stack = new LinkedList<>();
1✔
310
        private final Map<Data, PartialPropertyStack> partialPropertyStacks;
311

312
        public Features features() {
313
            return features;
1✔
314
        }
315

316
        public DALRuntimeContext(InputCode<?> supplier, Class<?> schema) {
1✔
317
            BeanClass<?> rootSchema = null;
1✔
318
            if (schema != null)
1✔
319
                rootSchema = BeanClass.create(schema);
1✔
320
            stack.push(data(() -> {
1✔
321
                try {
322
                    return supplier.get();
1✔
323
                } catch (Exception e) {
1✔
324
                    throw new UserRuntimeException(e);
1✔
325
                }
326
            }, rootSchema));
327
            partialPropertyStacks = new HashMap<>();
1✔
328
        }
1✔
329

330
        public Data getThis() {
331
            return stack.getFirst();
1✔
332
        }
333

334
        public <T> T pushAndExecute(Data data, Supplier<T> supplier) {
335
            try {
336
                stack.push(data);
1✔
337
                return supplier.get();
1✔
338
            } finally {
339
                returnHook.accept(stack.pop());
1✔
340
            }
341
        }
342

343
        public Optional<ConstructorViaSchema> searchValueConstructor(String type) {
344
            return Optional.ofNullable(valueConstructors.get(type));
1✔
345
        }
346

347
        public Set<?> findPropertyReaderNames(Object instance) {
348
            return getObjectPropertyAccessor(instance).getPropertyNames(instance);
1✔
349
        }
350

351
        public PropertyAccessor<Object> getObjectPropertyAccessor(Object instance) {
352
            return propertyAccessors.tryGetData(instance)
1✔
353
                    .orElseGet(() -> new JavaClassPropertyAccessor<>(BeanClass.createFrom(instance)));
1✔
354
        }
355

356
        public Boolean isNull(Object instance) {
357
            return propertyAccessors.tryGetData(instance).map(f -> f.isNull(instance))
1✔
358
                    .orElseGet(() -> Objects.equals(instance, null));
1✔
359
        }
360

361
        public DALCollection<Object> createCollection(Object instance) {
362
            return dALCollectionFactories.tryGetData(instance).map(factory -> factory.create(instance))
1✔
363
                    .orElseGet(() -> new CollectionDALCollection<>(toStream(instance).collect(toList())));
1✔
364
        }
365

366
        public boolean isRegisteredList(Object instance) {
367
            return dALCollectionFactories.tryGetData(instance).map(f -> f.isList(instance)).orElse(false);
1✔
368
        }
369

370
        public Converter getConverter() {
371
            return converter;
1✔
372
        }
373

374
        public Data data(ThrowingSupplier<?> instance, String schema, boolean isList) {
375
            BeanClass<?> schemaType = schemas.get(schema);
1✔
376
            if (isList && schemaType != null)
1✔
377
                schemaType = BeanClass.create(Array.newInstance(schemaType.getType(), 0).getClass());
1✔
378
            return data(instance, schemaType);
1✔
379
        }
380

381
        public Data data(ThrowingSupplier<?> supplier, BeanClass<?> schemaType) {
382
            return new Data(supplier == null ? () -> null : supplier, this, SchemaType.create(schemaType));
1✔
383
        }
384

385
        public Data data(ThrowingSupplier<?> instance) {
386
            return data(instance, null);
1✔
387
        }
388

389
        public Data data(Object instance) {
390
            return data(() -> instance, null);
1✔
391
        }
392

393
        public Optional<Result> takeUserDefinedLiteral(String token) {
394
            return userDefinedLiterals.stream().map(userLiteralRule -> userLiteralRule.compile(token))
1✔
395
                    .filter(Result::hasResult)
1✔
396
                    .findFirst();
1✔
397
        }
398

399
        public void appendPartialPropertyReference(Data data, Object symbol) {
400
            fetchPartialProperties(data).map(partialProperties -> partialProperties.appendPartialProperties(symbol));
1✔
401
        }
1✔
402

403
        private Optional<PartialProperties> fetchPartialProperties(Data data) {
404
            return partialPropertyStacks.values().stream().map(partialPropertyStack ->
1✔
405
                    partialPropertyStack.fetchPartialProperties(data)).filter(Objects::nonNull).findFirst();
1✔
406
        }
407

408
        public void initPartialPropertyStack(Data instance, Object prefix, Data partial) {
409
            partialPropertyStacks.computeIfAbsent(instance, _key -> fetchPartialProperties(instance)
1✔
410
                    .map(partialProperties -> partialProperties.partialPropertyStack)
1✔
411
                    .orElseGet(PartialPropertyStack::new)).setupPartialProperties(prefix, partial);
1✔
412
        }
1✔
413

414
        public Set<String> collectPartialProperties(Data instance) {
415
            PartialPropertyStack partialPropertyStack = partialPropertyStacks.get(instance);
1✔
416
            if (partialPropertyStack != null)
1✔
417
                return partialPropertyStack.collectPartialProperties(instance);
1✔
418
            return fetchPartialProperties(instance).map(partialProperties ->
1✔
419
                    partialProperties.partialPropertyStack.collectPartialProperties(instance)).orElse(emptySet());
1✔
420
        }
421

422
        public NumberType getNumberType() {
423
            return numberType;
1✔
424
        }
425

426
        public Optional<Object> getImplicitObject(Object obj) {
427
            return objectImplicitMapper.tryGetData(obj).map(mapper -> mapper.apply(obj));
1✔
428
        }
429

430
        public Set<Method> methodToCurrying(Class<?> type, Object methodName) {
431
            return RuntimeContextBuilder.this.methodToCurrying(type, methodName);
1✔
432
        }
433

434
        public Function<MetaData, Object> fetchGlobalMetaFunction(MetaData metaData) {
435
            return metaProperties.computeIfAbsent(metaData.name(), k -> {
1✔
436
                throw illegalOp2(format("Meta property `%s` not found", metaData.name()));
1✔
437
            });
438
        }
439

440
        private Optional<Function<MetaData, Object>> fetchLocalMetaFunction(MetaData metaData) {
441
            return metaFunctionsByType(metaData).map(e -> {
1✔
442
                metaData.addCallType(e.getKey());
1✔
443
                return e.getValue().get(metaData.name());
1✔
444
            }).filter(Objects::nonNull).findFirst();
1✔
445
        }
446

447
        public Optional<Function<MetaData, Object>> fetchSuperMetaFunction(MetaData metaData) {
448
            return metaFunctionsByType(metaData)
1✔
449
                    .filter(e -> !metaData.calledBy(e.getKey()))
1✔
450
                    .map(e -> {
1✔
451
                        metaData.addCallType(e.getKey());
1✔
452
                        return e.getValue().get(metaData.name());
1✔
453
                    }).filter(Objects::nonNull).findFirst();
1✔
454
        }
455

456
        private Stream<Map.Entry<Class<?>, Map<Object, Function<MetaData, Object>>>> metaFunctionsByType(MetaData metaData) {
457
            return localMetaProperties.entrySet().stream().filter(e -> metaData.isInstance(e.getKey()));
1✔
458
        }
459

460
        @SuppressWarnings("unchecked")
461
        public <T> TextFormatter<String, T> fetchFormatter(String name, int position) {
462
            return (TextFormatter<String, T>) textFormatterMap.computeIfAbsent(name, attribute -> {
1✔
463
                throw new SyntaxException(format("Invalid text formatter `%s`, all supported formatters are:\n%s",
1✔
464
                        attribute, textFormatterMap.entrySet().stream().map(e -> format("  %s:\n    %s",
1✔
465
                                e.getKey(), e.getValue().fullDescription())).collect(joining("\n"))), position);
1✔
466
            });
467
        }
468

469
        public Checker fetchEqualsChecker(Data expected, Data actual) {
470
            return checkerSetForEqualing.fetch(expected, actual);
1✔
471
        }
472

473
        public Checker fetchMatchingChecker(Data expected, Data actual) {
474
            return checkerSetForMatching.fetch(expected, actual);
1✔
475
        }
476

477
        public Dumper fetchDumper(Data.Resolved data) {
478
            return dumperFactories.tryGetData(data.value()).map(factory -> factory.apply(data)).orElseGet(() -> {
1✔
479
                if (data.isNull())
1✔
480
                    return (_data, dumpingContext) -> dumpingContext.append("null");
1✔
481
                if (data.isList())
1✔
482
                    return Dumper.LIST_DUMPER;
1✔
483
                if (data.isEnum())
1✔
484
                    return Dumper.VALUE_DUMPER;
1✔
485
                return Dumper.MAP_DUMPER;
1✔
486
            });
487
        }
488

489
        public int maxDumpingLineCount() {
490
            return maxDumpingLineSize;
1✔
491
        }
492

493
        public int maxDumpingObjectSize() {
494
            return maxDumpingObjectSize;
1✔
495
        }
496

497
        public boolean hookError(String expression, Throwable error) {
498
            return errorHook.handle(getThis(), expression, error);
1✔
499
        }
500

501
        public Data invokeMetaProperty(DALNode inputNode, Data inputData, Object symbolName) {
502
            return data(() -> {
1✔
503
                MetaData metaData = new MetaData(inputNode, inputData, symbolName, this);
1✔
504
                return fetchLocalMetaFunction(metaData).orElseGet(() -> fetchGlobalMetaFunction(metaData)).apply(metaData);
1✔
505
            }).onError(DalException::buildUserRuntimeException);
1✔
506
        }
507

508
        public Object invokeDataRemark(RemarkData remarkData) {
509
            Object instance = remarkData.data().instance();
1✔
510
            return remarks.tryGetData(instance)
1✔
511
                    .orElseThrow(() -> illegalOperation("Not implement operator () of " + getClassName(instance)))
1✔
512
                    .apply(remarkData);
1✔
513
        }
514

515
        public Object invokeExclamations(ExclamationData exclamationData) {
516
            Object instance = exclamationData.data().instance();
1✔
517
            return exclamations.tryGetData(instance)
1✔
518
                    .orElseThrow(() -> illegalOp2(format("Not implement operator %s of %s",
1✔
519
                            exclamationData.label(), Classes.getClassName(instance))))
1✔
520
                    .apply(exclamationData);
1✔
521
        }
522

523
        public Data calculate(Data v1, DALOperator opt, Data v2) {
524
            return data(() -> {
1✔
525
                for (Operation operation : operations.get(opt.overrideType()))
1✔
526
                    if (operation.match(v1, opt, v2, this))
1✔
527
                        return operation.operate(v1, opt, v2, this);
1✔
528
                throw illegalOperation(format("No operation `%s` between '%s' and '%s'", opt.overrideType(),
1✔
529
                        getClassName(v1.instance()), getClassName(v2.instance())));
1✔
530
            });
531
        }
532

533
        public PrintStream warningOutput() {
534
            return warning;
1✔
535
        }
536

537
        public BiFunction<Object, List<Object>, List<Object>> fetchCurryingMethodArgRange(Method method) {
538
            return curryingMethodArgRanges.get(method);
1✔
539
        }
540

541
        public Optional<CurryingMethod> currying(Object instance, Object property) {
542
            List<InstanceCurryingMethod> methods = methodToCurrying(named(instance.getClass()), property).stream()
1✔
543
                    .map(method -> createCurryingMethod(instance, method, getConverter(), this)).collect(toList());
1✔
544
            if (!methods.isEmpty())
1✔
545
                return of(new CurryingMethodGroup(methods, null));
1✔
546
            return getImplicitObject(instance).flatMap(obj -> currying(obj, property));
1✔
547
        }
548

549
        @SuppressWarnings("unchecked")
550
        public Comparable<?> transformComparable(Object object) {
551
            return customSorters.tryGetData(object).map(f -> f.apply(object)).orElseGet(() -> (Comparable) object);
1✔
552
        }
553
    }
554
}
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