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

LearnLib / automatalib / 12651580329

07 Jan 2025 12:29PM UTC coverage: 91.569% (+0.03%) from 91.542%
12651580329

push

github

web-flow
Update dependencies (#85)

* bump basic dependency versions

* bump checkstyle + cleanups

* bump spotbugs + cleanups

* bump pmd + cleanups

* bump checkerframework + cleanups

* some more cleanups

* ExceptionUtil: support nulls

* improve comments

* cleanup naming + formatting

* formatting

* formatting

* do not fail on javadoc warnings

completness of documentation is now checked by checkstyle and we would have to disable failing anyways when moving on to JDK 17

192 of 217 new or added lines in 63 files covered. (88.48%)

4 existing lines in 4 files now uncovered.

16573 of 18099 relevant lines covered (91.57%)

1.69 hits per line

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

30.77
/commons/util/src/main/java/net/automatalib/common/util/array/ArrayStorage.java
1
/* Copyright (C) 2013-2024 TU Dortmund University
2
 * This file is part of AutomataLib, http://www.automatalib.net/.
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 net.automatalib.common.util.array;
17

18
import java.util.AbstractList;
19
import java.util.Arrays;
20
import java.util.Collection;
21
import java.util.RandomAccess;
22
import java.util.function.Supplier;
23

24
import org.checkerframework.checker.nullness.qual.Nullable;
25

26
/**
27
 * A thin wrapper around a simple {@code Object[]} array. Mainly used (and useful) for heavily generic and array-based
28
 * data storage. Extends/Implements some convenient classes/interfaces.
29
 *
30
 * @param <T>
31
 *         the type of stored elements
32
 */
33
public final class ArrayStorage<T> extends AbstractList<T> implements RandomAccess {
34

35
    private final @Nullable Object[] storage;
36

37
    public ArrayStorage(int size) {
1✔
38
        this.storage = new Object[size];
1✔
39
    }
1✔
40

41
    public ArrayStorage(int size, Supplier<T> supplier) {
×
42
        this.storage = new Object[size];
×
43
        for (int i = 0; i < size; i++) {
×
44
            storage[i] = supplier.get();
×
45
        }
46
    }
×
47

48
    public ArrayStorage(Collection<? extends T> collection) {
NEW
49
        this(collection.toArray());
×
50
    }
×
51

52
    private ArrayStorage(@Nullable Object[] storage) {
×
53
        this.storage = storage;
×
54
    }
×
55

56
    @Override
57
    @SuppressWarnings("unchecked")
58
    public T get(int index) {
59
        return (T) storage[index];
1✔
60
    }
61

62
    @Override
63
    public T set(int index, T element) {
64
        final T oldValue = get(index);
1✔
65
        storage[index] = element;
1✔
66
        return oldValue;
1✔
67
    }
68

69
    @Override
70
    public int size() {
71
        return storage.length;
1✔
72
    }
73

74
    @Override
75
    public Object[] toArray() {
NEW
76
        return storage.clone();
×
77
    }
78

79
    @Override
80
    public boolean equals(@Nullable Object o) {
81
        if (this == o) {
×
82
            return true;
×
83
        }
84
        if (!(o instanceof ArrayStorage)) {
×
85
            return false;
×
86
        }
87

88
        final ArrayStorage<?> that = (ArrayStorage<?>) o;
×
89
        return Arrays.equals(storage, that.storage);
×
90
    }
91

92
    @Override
93
    public int hashCode() {
94
        return Arrays.hashCode(storage);
×
95
    }
96
}
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