added specieskey to make class reflection in Calculations.class stronger
This commit is contained in:
@@ -5,4 +5,6 @@ import java.time.LocalDate;
|
|||||||
public sealed interface Animal permits Dog, Cat, SmallAnimal {
|
public sealed interface Animal permits Dog, Cat, SmallAnimal {
|
||||||
|
|
||||||
LocalDate birthday();
|
LocalDate birthday();
|
||||||
|
|
||||||
|
String speciesKey();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,4 +3,9 @@ package com.pfefferminzia.petinsurance.animals;
|
|||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
|
||||||
public final record Cat(LocalDate birthday) implements Animal {
|
public final record Cat(LocalDate birthday) implements Animal {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String speciesKey() {
|
||||||
|
return "CAT";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import java.time.LocalDate;
|
|||||||
public final record Dog(LocalDate birthday, String breed) implements Animal {
|
public final record Dog(LocalDate birthday, String breed) implements Animal {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String breed() {
|
public String speciesKey() {
|
||||||
return (this.breed == null || this.breed.isBlank()) ? "" : this.breed;
|
return "DOG";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,4 +3,9 @@ package com.pfefferminzia.petinsurance.animals;
|
|||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
|
||||||
public final record SmallAnimal(LocalDate birthday) implements Animal {
|
public final record SmallAnimal(LocalDate birthday) implements Animal {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String speciesKey() {
|
||||||
|
return "SMALLANIMAL";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user