Creating new objects in a module

I have created a serial comm module and so far I can read and write data but only for one port. The issue is that in the module class I have a static port as follows:
private static SerialPort myPort;
Once I configure that port it is associated with one of the ports on the client computer.
public int configurePort(
@ScriptArg(“PortName”) String Name,
@ScriptArg(“BaudRate”) int BaudRate,
@ScriptArg(“DataBits”) int DataBits,
@ScriptArg(“StopBits”) int StopBits,
@ScriptArg(“Parity”) int Parity) {
int result = -1;
try {
myPort = SerialPort.getCommPort(Name);
myPort.setComPortParameters(BaudRate, DataBits, StopBits, Parity);
result = 1;
} catch (Exception e) { e.printStackTrace(); }
return result;
}
Is there a way to dynamically create new objects (ports) in the module instead so that I can use more than one serial port at a time or is there a more proper way to be doing this in the first place? In my past C# experience I would create a serial port object in the program but I don’t think this is possible with Ignition.
The only thing I can think of myself is to create an array of a static class with a name and serial port, then fill in the name with the system name of each serial port of the client so that I can select which one to interact with in each method.

Keep a Map<String, SerialPort>. Create and put new serial ports into it when one doesn’t exist, otherwise get the existing one. Make sure to remove them on shutdown.