• 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

4.67
/src/main/java/org/cyclops/integrateddynamics/core/item/ValueTypeVariableFacade.java
1
package org.cyclops.integrateddynamics.core.item;
2

3
import net.minecraft.network.chat.Component;
4
import net.minecraft.world.item.Item;
5
import org.cyclops.integrateddynamics.api.evaluate.variable.IValue;
6
import org.cyclops.integrateddynamics.api.evaluate.variable.IValueType;
7
import org.cyclops.integrateddynamics.api.evaluate.variable.IVariable;
8
import org.cyclops.integrateddynamics.api.item.IValueTypeVariableFacade;
9
import org.cyclops.integrateddynamics.api.item.IVariableFacadeClient;
10
import org.cyclops.integrateddynamics.api.network.INetwork;
11
import org.cyclops.integrateddynamics.api.network.IPartNetwork;
12
import org.cyclops.integrateddynamics.core.evaluate.variable.ValueHelpers;
13
import org.cyclops.integrateddynamics.core.evaluate.variable.Variable;
14
import org.cyclops.integrateddynamics.core.helper.L10NValues;
15

16
import java.util.function.Consumer;
17

18
/**
19
 * Variable facade for variables determined by a raw value.
20
 *
21
 * @author rubensworks
22
 */
23
public class ValueTypeVariableFacade<V extends IValue> extends VariableFacadeBase implements IValueTypeVariableFacade<V> {
24

25
    private final IValueType<V> valueType;
26
    private final V value;
27
    private IVariable<V> variable = null;
3✔
28

29
    public ValueTypeVariableFacade(boolean generateId, IValueType<V> valueType, V value) {
30
        super(generateId);
3✔
31
        this.valueType = valueType;
3✔
32
        this.value = value;
3✔
33
    }
1✔
34

35
    public ValueTypeVariableFacade(int id, IValueType<V> valueType, V value) {
36
        super(id);
×
37
        this.valueType = valueType;
×
38
        this.value = value;
×
39
    }
×
40

41
    @Override
42
    public IVariable<V> getVariable(INetwork network, IPartNetwork partNetwork) {
43
        if (isValid()) {
×
44
            if (variable == null) {
×
45
                variable = new Variable<V>(getValueType(), getValue());
×
46
            }
47
            return variable;
×
48
        }
49
        return null;
×
50
    }
51

52
    @Override
53
    public boolean isValid() {
54
        return getValueType() != null && getValue() != null;
×
55
    }
56

57
    @Override
58
    public void validate(INetwork network, IPartNetwork partNetwork, IValidator validator, IValueType containingValueType) {
59
        if (!isValid()) {
×
60
            validator.addError(Component.translatable(L10NValues.VARIABLE_ERROR_INVALIDITEM));
×
61
        } else {
62
            // Check expected aspect type and operator output type
63
            if (!ValueHelpers.correspondsTo(getValueType(), containingValueType)) {
×
64
                validator.addError(Component.translatable(L10NValues.ASPECT_ERROR_INVALIDTYPE,
×
65
                        Component.translatable(containingValueType.getTranslationKey()),
×
66
                        Component.translatable(getValueType().getTranslationKey())));
×
67
            }
68
        }
69
    }
×
70

71
    @Override
72
    public IValueType getOutputType() {
73
        return getValueType();
×
74
    }
75

76
    @Override
77
    protected IVariableFacadeClient constructClient() {
78
        return new ValueTypeVariableFacadeClient<>(this);
×
79
    }
80

81
    @Override
82
    public void appendHoverText(Consumer<Component> tooltipAdder, Item.TooltipContext context) {
83
        if (isValid()) {
×
84
            V value = getValue();
×
85
            getValueType().loadTooltip(tooltipAdder, false, value);
×
86
            tooltipAdder.accept(Component.translatable(L10NValues.VALUETYPE_TOOLTIP_VALUE, getValueType().toCompactString(value)));
×
87
        }
88
        super.appendHoverText(tooltipAdder, context);
×
89
    }
×
90

91
    public IValueType<V> getValueType() {
92
        return this.valueType;
×
93
    }
94

95
    public V getValue() {
96
        return this.value;
×
97
    }
98

99
    public IVariable<V> getVariable() {
100
        return this.variable;
×
101
    }
102

103
    public void setVariable(IVariable<V> variable) {
104
        this.variable = variable;
×
105
    }
×
106

107
    public String toString() {
108
        return "ValueTypeVariableFacade(valueType=" + this.getValueType() + ", value=" + this.getValue() + ", variable=" + this.getVariable() + ")";
×
109
    }
110

111
    public boolean equals(final Object o) {
112
        if (o == this) return true;
×
113
        if (!(o instanceof ValueTypeVariableFacade)) return false;
×
114
        final ValueTypeVariableFacade<?> other = (ValueTypeVariableFacade<?>) o;
×
115
        if (!other.canEqual((Object) this)) return false;
×
116
        if (!super.equals(o)) return false;
×
117
        final Object this$valueType = this.getValueType();
×
118
        final Object other$valueType = other.getValueType();
×
119
        if (this$valueType == null ? other$valueType != null : !this$valueType.equals(other$valueType)) return false;
×
120
        final Object this$value = this.getValue();
×
121
        final Object other$value = other.getValue();
×
122
        if (this$value == null ? other$value != null : !this$value.equals(other$value)) return false;
×
123
        final Object this$variable = this.getVariable();
×
124
        final Object other$variable = other.getVariable();
×
125
        if (this$variable == null ? other$variable != null : !this$variable.equals(other$variable)) return false;
×
126
        return true;
×
127
    }
128

129
    protected boolean canEqual(final Object other) {
130
        return other instanceof ValueTypeVariableFacade;
×
131
    }
132

133
    public int hashCode() {
134
        final int PRIME = 59;
×
135
        int result = super.hashCode();
×
136
        final Object $valueType = this.getValueType();
×
137
        result = result * PRIME + ($valueType == null ? 43 : $valueType.hashCode());
×
138
        final Object $value = this.getValue();
×
139
        result = result * PRIME + ($value == null ? 43 : $value.hashCode());
×
140
        final Object $variable = this.getVariable();
×
141
        result = result * PRIME + ($variable == null ? 43 : $variable.hashCode());
×
142
        return result;
×
143
    }
144
}
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