refactor + test: removed comments and fixed Test-Assertion
All checks were successful
Build and Test with Maven / Build-and-test-with-Maven (push) Successful in 4m56s

This commit is contained in:
Ruben 2024-09-04 11:03:11 +02:00
parent 8f094eb025
commit 114de0b236
2 changed files with 2 additions and 5 deletions

View File

@ -7,9 +7,6 @@ sealed interface List permits LinkedElem, Elem {}
public record LinkedElem<T>(T a,List l) implements List{} public record LinkedElem<T>(T a,List l) implements List{}
public record Elem<T>(T c) implements List{} public record Elem<T>(T c) implements List{}
//Wie gehe ich mit Type Erasure durch den Compiler um? Elemente werden wegen Generics immer zu Object umgewandelt, default Case muss also auch vom Type Object sein.
//Dadurch entsteht folgendes Constraint: java.lang.Integer <. T, das nicht aufgelöst werden kann.
public class GenericRecordSwitchCase { public class GenericRecordSwitchCase {
public main(o) { public main(o) {
return switch(o) { return switch(o) {

View File

@ -795,10 +795,10 @@ public class TestComplete {
var listWithMoreThanOneElement = constructorLinkedElem.newInstance(5, constructorLinkedElem.newInstance(1, constructorElem.newInstance(5))); var listWithMoreThanOneElement = constructorLinkedElem.newInstance(5, constructorLinkedElem.newInstance(1, constructorElem.newInstance(5)));
assertEquals(swtch.invoke(instance, listWithMoreThanOneElement), 2); assertEquals(swtch.invoke(instance, listWithMoreThanOneElement), 5);
var listWithOneElement = constructorLinkedElem.newInstance(5, constructorElem.newInstance(5)); var listWithOneElement = constructorLinkedElem.newInstance(5, constructorElem.newInstance(5));
assertEquals(swtch.invoke(instance, listWithOneElement), 1); assertEquals(swtch.invoke(instance, listWithOneElement), 5);
} }