1package org.jf.dexlib2.builder.instruction;
2
3import org.jf.dexlib2.builder.BuilderSwitchPayload;
4import org.jf.dexlib2.builder.Label;
5import org.jf.dexlib2.iface.instruction.SwitchElement;
6
7import javax.annotation.Nonnull;
8
9public class BuilderSwitchElement implements SwitchElement {
10    @Nonnull BuilderSwitchPayload parent;
11    private final int key;
12    @Nonnull private final Label target;
13
14    public BuilderSwitchElement(@Nonnull BuilderSwitchPayload parent,
15                                int key,
16                                @Nonnull Label target) {
17        this.parent = parent;
18        this.key = key;
19        this.target = target;
20    }
21
22    @Override public int getKey() {
23        return key;
24    }
25
26    @Override public int getOffset() {
27        return target.getCodeAddress() - parent.getReferrer().getCodeAddress();
28    }
29
30    @Nonnull
31    public Label getTarget() {
32        return target;
33    }
34}
35