From f0b58321ae53f330da86c392661354b87bd9a412 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 20 Jun 2025 20:04:02 +0300 Subject: Modernize codebase to use Java 21 features MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Convert VS3Tupel and VSLamportTime to records for immutability - Use switch expressions with pattern matching in VSTimestampTriggeredEvent - Modernize exception handling with pattern matching in VSErrorHandler - Replace anonymous ActionListener with lambda in VSAboutFrame - Use formatted strings instead of concatenation in VSDummyProtocol - Add sealed hierarchy VSEventType for exhaustive pattern matching - Create VSSimulationConfig record for configuration management - Maintain backward compatibility with deprecated methods All 132 unit tests pass successfully with Java 21 features. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/main/java/utils/VS3Tupel.java | 69 ++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 34 deletions(-) (limited to 'src/main/java/utils/VS3Tupel.java') diff --git a/src/main/java/utils/VS3Tupel.java b/src/main/java/utils/VS3Tupel.java index ac7ffba..3ff5129 100644 --- a/src/main/java/utils/VS3Tupel.java +++ b/src/main/java/utils/VS3Tupel.java @@ -1,58 +1,59 @@ package utils; /** - * The class VS3Tupel, an object of this class represents a 3-Tupel of objects. - * Each object can have its own type. + * A generic 3-tuple record that holds three values of potentially different types. + * This is an immutable value object that provides automatic implementations of + * {@code equals()}, {@code hashCode()}, and {@code toString()}. + * + *

Example usage:

+ *
{@code
+ * VS3Tupel tuple = new VS3Tupel<>("Hello", 42, true);
+ * String first = tuple.a();
+ * Integer second = tuple.b();
+ * Boolean third = tuple.c();
+ * }
* + * @param the type of the first element + * @param the type of the second element + * @param the type of the third element + * @param a the first element + * @param b the second element + * @param c the third element + * * @author Paul C. Buetow */ -public final class VS3Tupel { - /** The a. */ - private A a; - - /** The b. */ - private B b; - - /** The c. */ - private C c; - - /** - * Instantiates a new tupel. - * - * @param a the a - * @param b the b - * @param c the c - */ - public VS3Tupel(A a, B b, C c) { - this.a = a; - this.b = b; - this.c = c; - } - +public record VS3Tupel(A a, B b, C c) { + /** - * Gets the a. + * Gets the first element (provided for backward compatibility). * - * @return the a + * @return the first element + * @deprecated Use {@link #a()} instead */ + @Deprecated public A getA() { return a; } - + /** - * Gets the b. + * Gets the second element (provided for backward compatibility). * - * @return the b + * @return the second element + * @deprecated Use {@link #b()} instead */ + @Deprecated public B getB() { return b; } - + /** - * Gets the c. + * Gets the third element (provided for backward compatibility). * - * @return the c + * @return the third element + * @deprecated Use {@link #c()} instead */ + @Deprecated public C getC() { return c; } -} +} \ No newline at end of file -- cgit v1.2.3