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

leeonky / test-charm-java / 165

22 Mar 2025 11:09AM UTC coverage: 71.321% (-2.9%) from 74.248%
165

push

circleci

leeonky
update version

6809 of 9547 relevant lines covered (71.32%)

0.71 hits per line

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

95.5
/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 ClassKeyMap<Function<Object, Comparable<?>>> customSorters = new ClassKeyMap<>();
1✔
51
    private final Map<String, ConstructorViaSchema> valueConstructors = new LinkedHashMap<>();
1✔
52
    private final Map<String, BeanClass<?>> schemas = new HashMap<>();
1✔
53
    private final Set<Method> extensionMethods = new HashSet<>();
1✔
54
    private final Map<Object, Function<MetaData, Object>> metaProperties = new HashMap<>();
1✔
55
    private final ClassKeyMap<Function<RemarkData, Object>> remarks = new ClassKeyMap<>();
1✔
56
    private final ClassKeyMap<Function<RuntimeData, Object>> exclamations = new ClassKeyMap<>();
1✔
57
    private final List<UserLiteralRule> userDefinedLiterals = new ArrayList<>();
1✔
58
    private final NumberType numberType = new NumberType();
1✔
59
    private final Map<Method, BiFunction<Object, List<Object>, List<Object>>> curryingMethodArgRanges = new HashMap<>();
1✔
60
    private final Map<String, TextFormatter<?, ?>> textFormatterMap = new LinkedHashMap<>();
1✔
61
    private final Map<Operators, LinkedList<Operation>> operations = new HashMap<>();
1✔
62
    private Converter converter = Converter.getInstance();
1✔
63
    private final ClassKeyMap<DumperFactory> dumperFactories = new ClassKeyMap<>();
1✔
64
    private final CheckerSet checkerSetForMatching = new CheckerSet(CheckerSet::defaultMatching);
1✔
65
    private final CheckerSet checkerSetForEqualing = new CheckerSet(CheckerSet::defaultEqualing);
1✔
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✔
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) {
161
        this.converter = converter;
×
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) {
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) {
233
                return formatter.format(content, attribute, context);
×
234
            }
235

236
            @Override
237
            protected TextAttribute attribute(TextAttribute attribute) {
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, Object> action) {
264
        remarks.put(type, action);
1✔
265
        return this;
1✔
266
    }
267

268
    public RuntimeContextBuilder registerExclamation(Class<?> type, Function<RuntimeData, Object> 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
    @SuppressWarnings("unchecked")
279
    public <T> RuntimeContextBuilder registerCustomSorter(Class<T> type, Function<T, Comparable<?>> sorter) {
280
        customSorters.put(type, (Function<Object, Comparable<?>>) sorter);
1✔
281
        return this;
1✔
282
    }
283

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

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

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

300
    public Features features() {
301
        return features;
1✔
302
    }
303

304
    public class DALRuntimeContext implements RuntimeContext {
305
        private final LinkedList<Data> stack = new LinkedList<>();
1✔
306
        private final Map<Data, PartialPropertyStack> partialPropertyStacks;
307

308
        public Features features() {
309
            return features;
1✔
310
        }
311

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

326
        public Data getThis() {
327
            return stack.getFirst();
1✔
328
        }
329

330
        public <T> T pushAndExecute(Data data, Supplier<T> supplier) {
331
            try {
332
                stack.push(data);
1✔
333
                return supplier.get();
1✔
334
            } finally {
335
                stack.pop();
1✔
336
            }
337
        }
338

339
        public Optional<ConstructorViaSchema> searchValueConstructor(String type) {
340
            return Optional.ofNullable(valueConstructors.get(type));
1✔
341
        }
342

343
        public Set<?> findPropertyReaderNames(Object instance) {
344
            return getObjectPropertyAccessor(instance).getPropertyNames(instance);
1✔
345
        }
346

347
        public PropertyAccessor<Object> getObjectPropertyAccessor(Object instance) {
348
            return propertyAccessors.tryGetData(instance)
1✔
349
                    .orElseGet(() -> new JavaClassPropertyAccessor<>(BeanClass.createFrom(instance)));
1✔
350
        }
351

352
        public Boolean isNull(Object instance) {
353
            return propertyAccessors.tryGetData(instance).map(f -> f.isNull(instance))
1✔
354
                    .orElseGet(() -> Objects.equals(instance, null));
1✔
355
        }
356

357
        public DALCollection<Object> createCollection(Object instance) {
358
            return dALCollectionFactories.tryGetData(instance).map(factory -> factory.create(instance))
1✔
359
                    .orElseGet(() -> new CollectionDALCollection<>(toStream(instance).collect(toList())));
1✔
360
        }
361

362
        public boolean isRegisteredList(Object instance) {
363
            return dALCollectionFactories.tryGetData(instance).map(f -> f.isList(instance)).orElse(false);
1✔
364
        }
365

366
        public Converter getConverter() {
367
            return converter;
1✔
368
        }
369

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

377
        public Data data(ThrowingSupplier<?> supplier, BeanClass<?> schemaType) {
378
            return new Data(supplier == null ? () -> null : supplier, this, SchemaType.create(schemaType));
1✔
379
        }
380

381
        public Data data(ThrowingSupplier<?> instance) {
382
            return data(instance, null);
1✔
383
        }
384

385
        public Data data(Object instance) {
386
            return data(() -> instance, null);
1✔
387
        }
388

389
        public Optional<Result> takeUserDefinedLiteral(String token) {
390
            return userDefinedLiterals.stream().map(userLiteralRule -> userLiteralRule.compile(token))
1✔
391
                    .filter(Result::hasResult)
1✔
392
                    .findFirst();
1✔
393
        }
394

395
        public void appendPartialPropertyReference(Data data, Object symbol) {
396
            fetchPartialProperties(data).map(partialProperties -> partialProperties.appendPartialProperties(symbol));
1✔
397
        }
1✔
398

399
        private Optional<PartialProperties> fetchPartialProperties(Data data) {
400
            return partialPropertyStacks.values().stream().map(partialPropertyStack ->
1✔
401
                    partialPropertyStack.fetchPartialProperties(data)).filter(Objects::nonNull).findFirst();
1✔
402
        }
403

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

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

418
        public NumberType getNumberType() {
419
            return numberType;
1✔
420
        }
421

422
        public Optional<Object> getImplicitObject(Object obj) {
423
            return objectImplicitMapper.tryGetData(obj).map(mapper -> mapper.apply(obj));
1✔
424
        }
425

426
        public Set<Method> methodToCurrying(Class<?> type, Object methodName) {
427
            return RuntimeContextBuilder.this.methodToCurrying(type, methodName);
1✔
428
        }
429

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

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

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

452
        private Stream<Map.Entry<Class<?>, Map<Object, Function<MetaData, Object>>>> metaFunctionsByType(MetaData metaData) {
453
            return localMetaProperties.entrySet().stream().filter(e -> metaData.isInstance(e.getKey()));
1✔
454
        }
455

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

465
        public Checker fetchEqualsChecker(Data expected, Data actual) {
466
            return checkerSetForEqualing.fetch(expected, actual);
1✔
467
        }
468

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

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

485
        public int maxDumpingLineCount() {
486
            return maxDumpingLineSize;
1✔
487
        }
488

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

493
        public boolean hookError(String expression, Throwable error) {
494
            return errorHook.handle(getThis(), expression, error);
1✔
495
        }
496

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

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

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

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

529
        public PrintStream warningOutput() {
530
            return warning;
1✔
531
        }
532

533
        public BiFunction<Object, List<Object>, List<Object>> fetchCurryingMethodArgRange(Method method) {
534
            return curryingMethodArgRanges.get(method);
1✔
535
        }
536

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

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