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

LearnLib / learnlib / 6433387082

06 Oct 2023 03:10PM UTC coverage: 92.296% (-0.007%) from 92.303%
6433387082

push

github

mtf90
update Falk's developer id

11573 of 12539 relevant lines covered (92.3%)

1.67 hits per line

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

54.17
/drivers/basic/src/main/java/de/learnlib/drivers/reflect/MethodInput.java
1
/* Copyright (C) 2013-2023 TU Dortmund
2
 * This file is part of LearnLib, http://www.learnlib.de/.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package de.learnlib.drivers.reflect;
17

18
import java.lang.reflect.Method;
19
import java.util.Arrays;
20
import java.util.Collection;
21
import java.util.HashMap;
22
import java.util.Map;
23
import java.util.Map.Entry;
24

25
import org.checkerframework.checker.nullness.qual.KeyFor;
26

27
/**
28
 * abstract method input, may have abstract parameters.
29
 */
30
public class MethodInput {
31

32
    private final String name;
33

34
    private final Method method;
35

36
    private final Map<String, Integer> parameters;
37

38
    private final Object[] values;
39

40
    public MethodInput(String name, Method method, Map<String, Integer> parameters, Object[] values) {
2✔
41
        this.name = name;
2✔
42
        this.method = method;
2✔
43
        this.parameters = parameters;
2✔
44
        this.values = values;
2✔
45
    }
2✔
46

47
    @Override
48
    public String toString() {
49
        return this.name() + Arrays.toString(this.parameters.keySet().toArray());
1✔
50
    }
51

52
    public String name() {
53
        return this.name;
1✔
54
    }
55

56
    public String getCall() {
57
        Map<String, Object> names = new HashMap<>();
×
58
        for (String p : getParameterNames()) {
×
59
            names.put(p, p);
×
60
        }
×
61
        return this.method.getName() + Arrays.toString(getParameters(names));
×
62
    }
63

64
    public Collection<@KeyFor("parameters") String> getParameterNames() {
65
        return this.parameters.keySet();
×
66
    }
67

68
    public Object[] getParameters(Map<String, Object> fill) {
69
        Object[] ret = new Object[this.values.length];
2✔
70
        System.arraycopy(this.values, 0, ret, 0, this.values.length);
2✔
71
        for (Entry<String, Object> e : fill.entrySet()) {
2✔
72
            Integer idx = this.parameters.get(e.getKey());
×
73
            ret[idx] = e.getValue();
×
74
        }
×
75
        return ret;
2✔
76
    }
77

78
    public Class<?> getParameterType(@KeyFor("parameters") String name) {
79
        int id = parameters.get(name);
×
80
        return this.method.getParameterTypes()[id];
×
81
    }
82

83
    public Method getMethod() {
84
        return this.method;
2✔
85
    }
86

87
}
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

© 2025 Coveralls, Inc