feat(search): add MatchOffset record for character-level highlight positions
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,14 @@
|
|||||||
|
package org.raddatz.familienarchiv.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Character-level offset of a highlighted term within a text field.
|
||||||
|
* Offsets are Java {@code String} character positions (UTF-16 code units),
|
||||||
|
* which are identical to JavaScript string positions — consistent end-to-end
|
||||||
|
* for all German BMP characters (ä, ö, ü, ß, etc.).
|
||||||
|
*/
|
||||||
|
public record MatchOffset(
|
||||||
|
@Schema(requiredMode = Schema.RequiredMode.REQUIRED) int start,
|
||||||
|
@Schema(requiredMode = Schema.RequiredMode.REQUIRED) int length
|
||||||
|
) {}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package org.raddatz.familienarchiv.dto;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
class MatchOffsetTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_hold_start_and_length() {
|
||||||
|
MatchOffset offset = new MatchOffset(6, 5);
|
||||||
|
|
||||||
|
assertThat(offset.start()).isEqualTo(6);
|
||||||
|
assertThat(offset.length()).isEqualTo(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_implement_value_equality() {
|
||||||
|
assertThat(new MatchOffset(0, 3)).isEqualTo(new MatchOffset(0, 3));
|
||||||
|
assertThat(new MatchOffset(0, 3)).isNotEqualTo(new MatchOffset(0, 4));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user