From b213ecca9559f75d915c2105e981b3673c5ac2fa Mon Sep 17 00:00:00 2001 From: Frank Delporte Date: Fri, 22 Nov 2024 13:11:35 +0100 Subject: [PATCH] Extended use of List.of instead of Collections --- .../pi4j/boardinfo/definition/BoardModel.java | 101 +++++++++--------- .../boardinfo/definition/HeaderVersion.java | 5 +- 2 files changed, 52 insertions(+), 54 deletions(-) diff --git a/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/BoardModel.java b/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/BoardModel.java index d5bf048c..85e2d217 100644 --- a/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/BoardModel.java +++ b/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/BoardModel.java @@ -6,7 +6,6 @@ import java.time.LocalDate; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.stream.Collectors; @@ -31,8 +30,8 @@ public enum BoardModel { LocalDate.of(2013, 2, 1), Soc.BCM2835, Cpu.ARM1176JZF_S, 1, - Collections.singletonList(700), - Collections.singletonList(256 * 1024)), + List.of(700), + List.of(256 * 1024)), MODEL_1_A_PLUS("Raspberry Pi 1 Model A+", SINGLE_BOARD_COMPUTER, List.of("0012", "0015", "900021"), PiModel.MODEL_A, @@ -40,9 +39,9 @@ public enum BoardModel { LocalDate.of(2014, 11, 1), Soc.BCM2835, Cpu.ARM1176JZF_S, 1, - Collections.singletonList(700), + List.of(700), List.of(256 * 1024, 512 * 1024), - Collections.singletonList("Amount of memory changed to 512Mb on 20160810")), + List.of("Amount of memory changed to 512Mb on 20160810")), MODEL_3_A_PLUS("Raspberry Pi 3 Model A+", SINGLE_BOARD_COMPUTER, List.of("9020e0", "9020e1"), PiModel.MODEL_A, @@ -50,8 +49,8 @@ public enum BoardModel { LocalDate.of(2018, 11, 1), Soc.BCM2837B0, Cpu.CORTEX_A53, 4, - Collections.singletonList(1400), - Collections.singletonList(512 * 1024)), + List.of(1400), + List.of(512 * 1024)), MODEL_1_B("Raspberry Pi 1 Model B", SINGLE_BOARD_COMPUTER, List.of("0002", "0003", "0004", "0005", "0006", "000d", "000e", "000f"), PiModel.MODEL_B, @@ -59,9 +58,9 @@ public enum BoardModel { LocalDate.of(2012, 4, 1), Soc.BCM2835, Cpu.ARM1176JZF_S, 1, - Collections.singletonList(700), + List.of(700), List.of(256 * 1024, 512 * 1024), - Collections.singletonList("Amount of memory changed to 512Mb on 20121015")), + List.of("Amount of memory changed to 512Mb on 20121015")), MODEL_1_B_PLUS("Raspberry Pi 1 Model B+", SINGLE_BOARD_COMPUTER, List.of("0010", "0013", "900032"), PiModel.MODEL_B, @@ -69,8 +68,8 @@ public enum BoardModel { LocalDate.of(2014, 7, 1), Soc.BCM2835, Cpu.ARM1176JZF_S, 1, - Collections.singletonList(700), - Collections.singletonList(512 * 1024)), + List.of(700), + List.of(512 * 1024)), MODEL_2_B("Raspberry Pi 2 Model B", SINGLE_BOARD_COMPUTER, List.of("a01040", "a01041", "a21041"), PiModel.MODEL_B, @@ -78,8 +77,8 @@ public enum BoardModel { LocalDate.of(2015, 2, 1), Soc.BCM2836, Cpu.CORTEX_A7, 4, - Collections.singletonList(900), - Collections.singletonList(1024 * 1024)), + List.of(900), + List.of(1024 * 1024)), MODEL_2_B_V1_2("Raspberry Pi 2 Model B V1.2", SINGLE_BOARD_COMPUTER, List.of("a02042", "a22042"), PiModel.MODEL_B, @@ -87,8 +86,8 @@ public enum BoardModel { LocalDate.of(2016, 10, 1), Soc.BCM2837, Cpu.CORTEX_A53, 4, - Collections.singletonList(900), - Collections.singletonList(1024 * 1024)), + List.of(900), + List.of(1024 * 1024)), MODEL_3_B("Raspberry Pi 3 Model B", SINGLE_BOARD_COMPUTER, List.of("a02082", "a22082", "a32082", "a52082", "a22083"), PiModel.MODEL_B, @@ -96,8 +95,8 @@ public enum BoardModel { LocalDate.of(2016, 2, 1), Soc.BCM2837, Cpu.CORTEX_A53, 4, - Collections.singletonList(1200), - Collections.singletonList(1024 * 1024)), + List.of(1200), + List.of(1024 * 1024)), MODEL_3_B_PLUS("Raspberry Pi 3 Model B+", SINGLE_BOARD_COMPUTER, List.of("a020d3", "a020d4"), PiModel.MODEL_B, @@ -105,8 +104,8 @@ public enum BoardModel { LocalDate.of(2018, 3, 14), Soc.BCM2837B0, Cpu.CORTEX_A53, 4, - Collections.singletonList(1400), - Collections.singletonList(1024 * 1024)), + List.of(1400), + List.of(1024 * 1024)), MODEL_4_B("Raspberry Pi 4 Model B", SINGLE_BOARD_COMPUTER, List.of("a03111", "b03111", "b03112", "b03114", "b03115", "c03111", "c03112", "c03114", "c03115", "d03114", "d03115"), PiModel.MODEL_B, @@ -117,14 +116,14 @@ public enum BoardModel { List.of(1500, 1800), List.of(1024 * 1024, 2048 * 1024, 4096 * 1024, 8192 * 1024)), MODEL_400("Raspberry Pi 400", ALL_IN_ONE_COMPUTER, - Collections.singletonList("c03130"), + List.of("c03130"), PiModel.MODEL_B, HeaderVersion.TYPE_3, LocalDate.of(2020, 11, 2), Soc.BCM2711C0, Cpu.CORTEX_A72, 4, - Collections.singletonList(1800), - Collections.singletonList(4096 * 1024)), + List.of(1800), + List.of(4096 * 1024)), MODEL_5_B("Raspberry Pi 5 Model B", SINGLE_BOARD_COMPUTER, List.of("b04170", "c04170", "d04170"), PiModel.MODEL_B, @@ -132,7 +131,7 @@ public enum BoardModel { LocalDate.of(2023, 9, 28), Soc.BCM2712, Cpu.CORTEX_A76, 4, - Collections.singletonList(2400), + List.of(2400), List.of(2048 * 1024, 4096 * 1024, 8192 * 1024)), COMPUTE_1("Compute Module 1", STACK_ON_COMPUTER, List.of("0011", "0014", "900061"), @@ -141,8 +140,8 @@ public enum BoardModel { LocalDate.of(2014, 4, 1), Soc.BCM2835, Cpu.ARM1176JZF_S, 1, - Collections.singletonList(700), - Collections.singletonList(512 * 1024)), + List.of(700), + List.of(512 * 1024)), COMPUTE_3("Compute Module 3", STACK_ON_COMPUTER, List.of("a020a0", "a220a0"), PiModel.COMPUTE, @@ -150,17 +149,17 @@ public enum BoardModel { LocalDate.of(2017, 1, 1), Soc.BCM2837, Cpu.CORTEX_A53, 4, - Collections.singletonList(1200), - Collections.singletonList(1024 * 1024)), + List.of(1200), + List.of(1024 * 1024)), COMPUTE_3_PLUS("Compute Module 3+", STACK_ON_COMPUTER, - Collections.singletonList("a02100"), + List.of("a02100"), PiModel.COMPUTE, HeaderVersion.COMPUTE, LocalDate.of(2019, 1, 1), Soc.BCM2837B0, Cpu.CORTEX_A53, 4, - Collections.singletonList(1200), - Collections.singletonList(1024 * 1024)), + List.of(1200), + List.of(1024 * 1024)), COMPUTE_4("Compute Module 4", STACK_ON_COMPUTER, List.of("a03140", "b03140", "c03140", "d03140", "a03141", "b03141", "c03141", "d03141"), PiModel.COMPUTE, @@ -168,7 +167,7 @@ public enum BoardModel { LocalDate.of(2020, 10, 1), Soc.BCM2711, Cpu.CORTEX_A72, 4, - Collections.singletonList(1500), + List.of(1500), List.of(1024 * 1024, 2048 * 1024, 4096 * 1024, 8192 * 1024)), // https://datasheets.raspberrypi.com/cm4s/cm4s-datasheet.pdf COMPUTE_4_SODIMM("Compute Module 4 SODIMM", STACK_ON_COMPUTER, @@ -178,7 +177,7 @@ public enum BoardModel { LocalDate.of(2020, 10, 1), Soc.BCM2711, Cpu.CORTEX_A72, 4, - Collections.singletonList(1500), + List.of(1500), List.of(1024 * 1024, 2048 * 1024, 4096 * 1024, 8192 * 1024)), ZERO_PCB_1_2("Raspberry Pi Zero PCB V1.2", SINGLE_BOARD_COMPUTER, List.of("900092", "920092"), @@ -187,8 +186,8 @@ public enum BoardModel { LocalDate.of(2015, 11, 1), Soc.BCM2835, Cpu.ARM1176JZF_S, 1, - Collections.singletonList(1000), - Collections.singletonList(512 * 1024)), + List.of(1000), + List.of(512 * 1024)), ZERO_PCB_1_3("Raspberry Pi Zero PCB V1.3", SINGLE_BOARD_COMPUTER, List.of("900093", "920093"), PiModel.ZERO, @@ -196,26 +195,26 @@ public enum BoardModel { LocalDate.of(2016, 5, 1), Soc.BCM2835, Cpu.ARM1176JZF_S, 1, - Collections.singletonList(1000), - Collections.singletonList(512 * 1024)), + List.of(1000), + List.of(512 * 1024)), ZERO_W("Raspberry Pi Zero W", SINGLE_BOARD_COMPUTER, - Collections.singletonList("9000c1"), + List.of("9000c1"), PiModel.ZERO, HeaderVersion.TYPE_3, LocalDate.of(2017, 2, 28), Soc.BCM2835, Cpu.ARM1176JZF_S, 1, - Collections.singletonList(1000), - Collections.singletonList(512 * 1024)), + List.of(1000), + List.of(512 * 1024)), ZERO_V2("Raspberry Pi Zero V2", SINGLE_BOARD_COMPUTER, - Collections.singletonList("902120"), + List.of("902120"), PiModel.ZERO, HeaderVersion.TYPE_3, LocalDate.of(2021, 10, 28), Soc.BCM2710A1, Cpu.CORTEX_A53, 4, - Collections.singletonList(1000), - Collections.singletonList(512 * 1024)), + List.of(1000), + List.of(512 * 1024)), PICO("Raspberry Pi Pico", MICROCONTROLLER, new ArrayList<>(), PiModel.PICO, @@ -223,8 +222,8 @@ public enum BoardModel { LocalDate.of(2021, 1, 1), Soc.RP2040, Cpu.CORTEX_MO_PLUS, 1, - Collections.singletonList(133), - Collections.singletonList(264 + 2048)), + List.of(133), + List.of(264 + 2048)), PICO_W("Raspberry Pi Pico W", MICROCONTROLLER, new ArrayList<>(), PiModel.PICO, @@ -232,9 +231,9 @@ public enum BoardModel { LocalDate.of(2022, 6, 1), Soc.RP2040, Cpu.CORTEX_MO_PLUS, 1, - Collections.singletonList(133), - Collections.singletonList(264 + 2048), - Collections.singletonList("Same form factor as PICO but with Wi-Fi")), + List.of(133), + List.of(264 + 2048), + List.of("Same form factor as PICO but with Wi-Fi")), PICO_2("Raspberry Pi Pico 2", MICROCONTROLLER, new ArrayList<>(), PiModel.PICO, @@ -242,8 +241,8 @@ public enum BoardModel { LocalDate.of(2024, 8, 8), Soc.RP2350, Cpu.CORTEX_M33, 1, - Collections.singletonList(150), - Collections.singletonList(520 + 4096)), + List.of(150), + List.of(520 + 4096)), PICO_2_W("Raspberry Pi Pico 2 W", MICROCONTROLLER, new ArrayList<>(), PiModel.PICO, @@ -251,8 +250,8 @@ public enum BoardModel { LocalDate.of(2024, 8, 8), Soc.RP2350, Cpu.CORTEX_M33, 1, - Collections.singletonList(150), - Collections.singletonList(520 + 4096)), + List.of(150), + List.of(520 + 4096)), UNKNOWN("Unknown", BoardType.UNKNOWN, new ArrayList<>(), PiModel.UNKNOWN, diff --git a/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/HeaderVersion.java b/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/HeaderVersion.java index 5e6e972c..be69884f 100644 --- a/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/HeaderVersion.java +++ b/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/HeaderVersion.java @@ -1,14 +1,13 @@ package com.pi4j.boardinfo.definition; import java.util.ArrayList; -import java.util.Collections; import java.util.List; public enum HeaderVersion { PICO("Pico", "Used on the Pico microcontroller", new ArrayList<>()), - TYPE_1("Type 1", "Used on original Model B", Collections.singletonList(HeaderPins.HEADER_26_TYPE_1)), + TYPE_1("Type 1", "Used on original Model B", List.of(HeaderPins.HEADER_26_TYPE_1)), TYPE_2("Type 2", "Used on Model A and Model B (revision 2)", List.of(HeaderPins.HEADER_26_TYPE_2, HeaderPins.HEADER_8)), - TYPE_3("Type 3", "Used on Model A+, B+, Pi Zero, Pi Zero W, Pi2B, Pi3B, Pi4B, Pi5B", Collections.singletonList(HeaderPins.HEADER_40)), + TYPE_3("Type 3", "Used on Model A+, B+, Pi Zero, Pi Zero W, Pi2B, Pi3B, Pi4B, Pi5B", List.of(HeaderPins.HEADER_40)), COMPUTE("Compute Module", "54 GPIO", List.of(HeaderPins.COMPUTE_J5, HeaderPins.COMPUTE_J6)), UNKNOWN("Unknown", "", new ArrayList<>());