mattjlewis / diozero

Java Device I/O library that is portable across Single Board Computers and microcontrollers. Tested with Raspberry Pi, Odroid C2, BeagleBone Black, Next Thing CHIP, Asus Tinker Board and Arduinos / Pico. Supports GPIO, I2C, SPI as well as Serial communication. Also known to work with Udoo Quad.
https://www.diozero.com
MIT License
261 stars 59 forks source link

Refactor DeviceFactory interfaces to use a default registration method and Supplier #132

Closed EAGrahamJr closed 1 year ago

EAGrahamJr commented 1 year ago

There's a bit of repetitious code in the various DeviceFactoryInterface definitions that would benefit from consolidation. This involves mostly the "open" check and the ability to prevent duplicate devices from being created.

Recommendation: create a default registerDevice method that wraps the actual device creation in a Supplier so that all downstream classes do not have to check for open devices.

EAGrahamJr commented 1 year ago

(I've got this - it can definitely wait for 1.4)

mattjlewis commented 1 year ago

Brilliant - look forward to seeing something here. You might have seen I did a commit not so long ago refactoring some internal bits and pieces. I should really make use of the GitHub project board for tracking backlog / ideas...

EAGrahamJr commented 1 year ago

:grinning: