1 package net.mograsim.logic.model.verilog.model;
3 import java.util.HashSet;
5 import java.util.Objects;
8 import net.mograsim.logic.model.verilog.model.signals.IOPort;
10 public class VerilogComponentDeclaration
12 private final String id;
13 private final List<IOPort> ioPorts;
15 public VerilogComponentDeclaration(String id, List<IOPort> ioPorts)
17 this.id = Objects.requireNonNull(id);
18 this.ioPorts = List.copyOf(ioPorts);
25 Set<String> usedNames = new HashSet<>();
27 for (IOPort ioPort : ioPorts)
28 if (!usedNames.add(ioPort.getName()))
29 throw new IllegalArgumentException("Name occurs twice: " + ioPort.getName());
37 public List<IOPort> getIOPorts()
47 result = prime * result + ((ioPorts == null) ? 0 : ioPorts.hashCode());
48 result = prime * result + ((id == null) ? 0 : id.hashCode());
53 public String toString()
55 return id + "[" + ioPorts.size() + "]";
59 public boolean equals(Object obj)
65 if (getClass() != obj.getClass())
67 VerilogComponentDeclaration other = (VerilogComponentDeclaration) obj;
70 if (other.ioPorts != null)
72 } else if (!ioPorts.equals(other.ioPorts))
78 } else if (!id.equals(other.id))