Skip to content

Commit

Permalink
LEGS.formatted/unformatted hinzugefügt
Browse files Browse the repository at this point in the history
  • Loading branch information
oboehm committed Feb 21, 2025
1 parent 171fbb6 commit 453dccc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
29 changes: 18 additions & 11 deletions domains/med/src/main/kotlin/de/jfachwert/med/LEGS.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,24 @@ open class LEGS
*/
@JvmOverloads constructor(code: String, validator: KSimpleValidator<String> = VALIDATOR) : AbstractFachwert<String, LEGS>(code, validator) {

/**
* Liefert die LEGS formattiert mit Leerzeichen zurueck
*
* @return formatierte LEGS, z.B. "81 02 999"
*/
val formatted: String
get() {
return code.substring(0, 2) + " " + code.substring(2, 4) + " " + getTK()
}

/**
* Liefert die unformattierte LEGS.
*
* @return unformattierte LEGS
*/
val unformatted: String
get() = code

/**
* Liefert das Tarifkennzeichen (TK).
*
Expand Down Expand Up @@ -96,17 +114,6 @@ open class LEGS
return WEAK_CACHE.computeIfAbsent(code) { s: String -> LEGS(s) }
}

/**
* Ueberprueft die uebergebenen Nummer, ob sie 7-stellig und eine
* korrekte LEGS darstellt.
*
* @param nummer 7-stelliger Schluessel
* @return der Schluessel selbst zur Weiterverarbeitung
*/
fun validate(nummer: String): String {
return VALIDATOR.validate(nummer)
}

}

}
7 changes: 7 additions & 0 deletions domains/med/src/test/java/de/jfachwert/med/LEGSTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ public void testOf() {
assertEquals(b, c);
}

@Test
public void testFormatted() {
LEGS legs = LEGS.of("91 02 999");
assertEquals("91 02 999", legs.getFormatted());
assertEquals("9102999", legs.getUnformatted());
}

@Test
public void testTK() {
LEGS legs = LEGS.of("15 02 B05");
Expand Down

0 comments on commit 453dccc

Please sign in to comment.