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

CyclopsMC / IntegratedDynamics / 20210191346

14 Dec 2025 03:32PM UTC coverage: 19.514% (-33.5%) from 53.061%
20210191346

push

github

rubensworks
Remove deprecations

663 of 8728 branches covered (7.6%)

Branch coverage included in aggregate %.

6786 of 29445 relevant lines covered (23.05%)

1.09 hits per line

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

0.0
/src/main/java/org/cyclops/integrateddynamics/core/ingredient/ExtendedIngredientsSingle.java
1
package org.cyclops.integrateddynamics.core.ingredient;
2

3
import com.google.common.collect.Sets;
4
import org.cyclops.commoncapabilities.api.ingredient.IMixedIngredients;
5
import org.cyclops.commoncapabilities.api.ingredient.IngredientComponent;
6

7
import java.util.AbstractList;
8
import java.util.List;
9
import java.util.Set;
10

11
/**
12
 * A lazy extension for ingredients for a single instance.
13
 * @param <T> The instance type.
14
 * @param <M> The matching condition parameter, may be Void. Instances MUST properly implement the equals method.
15
 * @author rubensworks
16
 */
17
public class ExtendedIngredientsSingle<T, M> extends WrappedIngredients {
18

19
    private final int targetIndex;
20

21
    private final IngredientComponent<T, M> component;
22
    private final T instance;
23

24
    public ExtendedIngredientsSingle(IMixedIngredients base, int targetIndex,
25
                                     IngredientComponent<T, M> component, T instance) {
26
        super(base);
×
27
        this.targetIndex = targetIndex;
×
28
        this.component = component;
×
29
        this.instance = instance;
×
30
    }
×
31

32
    protected boolean forComponent(IngredientComponent<?, ?> component) {
33
        return component == this.component;
×
34
    }
35

36
    @Override
37
    public Set<IngredientComponent<?, ?>> getComponents() {
38
        Set<IngredientComponent<?, ?>> components = Sets.newIdentityHashSet();
×
39
        components.addAll(super.getComponents());
×
40
        components.add(component);
×
41
        return components;
×
42
    }
43

44
    @Override
45
    public <T2> List<T2> getInstances(IngredientComponent<T2, ?> ingredientComponent) {
46
        List<T2> superList = super.getInstances(ingredientComponent);
×
47
        return forComponent(ingredientComponent) ? new AbstractList<T2>() {
×
48
            @Override
49
            public T2 get(int index) {
50
                if (index == targetIndex) {
×
51
                    return (T2) instance;
×
52
                } else if (index < targetIndex && index >= superList.size()) {
×
53
                    return (T2) component.getMatcher().getEmptyInstance();
×
54
                }
55
                return superList.get(index);
×
56
            }
57

58
            @Override
59
            public int size() {
60
                int superSize = superList.size();
×
61
                if (targetIndex >= superSize) {
×
62
                    return targetIndex + 1;
×
63
                }
64
                return superSize;
×
65
            }
66
        } : superList;
×
67
    }
68
}
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