Merge remote-tracking branch 'origin/development' into development
[Mograsim.git] / plugins / net.mograsim.machine / src / net / mograsim / machine / isa / AsmOperands.java
1 package net.mograsim.machine.isa;
2
3 import java.util.List;
4 import java.util.Objects;
5 import java.util.stream.Collectors;
6
7 public final class AsmOperands
8 {
9         private final List<AsmOperand> operands;
10
11         public AsmOperands(List<AsmOperand> operands)
12         {
13                 this.operands = List.copyOf(Objects.requireNonNull(operands));
14         }
15
16         public List<AsmOperand> getOperands()
17         {
18                 return operands;
19         }
20
21         @Override
22         public int hashCode()
23         {
24                 return operands.hashCode();
25         }
26
27         @Override
28         public boolean equals(Object obj)
29         {
30                 if (this == obj)
31                         return true;
32                 if (!(obj instanceof AsmOperands))
33                         return false;
34                 AsmOperands other = (AsmOperands) obj;
35                 return operands.equals(other.operands);
36         }
37
38         @Override
39         public String toString()
40         {
41                 return operands.stream().map(AsmOperand::toString).collect(Collectors.joining(", "));
42         }
43 }