Skip to content

Commit

Permalink
55-lemma-spelling
Browse files Browse the repository at this point in the history
Spelling added for LemmaDTO
  • Loading branch information
dwerning authored Aug 22, 2024
2 parents 9214fc9 + 6ec52f8 commit fd26aec
Showing 1 changed file with 119 additions and 106 deletions.
225 changes: 119 additions & 106 deletions src/main/java/tla/domain/dto/LemmaDto.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package tla.domain.dto;

import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.SortedMap;
Expand Down Expand Up @@ -38,110 +39,122 @@
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class LemmaDto extends NamedDocumentDto {

@JsonAlias({"sortString", "sort_string", "sort_key"})
private String sortKey;

//private String mdc;
@JsonInclude(
value = JsonInclude.Include.CUSTOM,
valueFilter = Glyphs.EmptyObjectFilter.class
)
private Glyphs glyphs;

@Singular
private SortedMap<Language, List<String>> translations;

private Transcription transcription;

@Singular
private List<SentenceToken> words;

private int attestedSentencesCount;

public static class TimeSpan{
/** first year */
@Setter
@Getter
private int begin;
/** last year */
@Setter
@Getter
private int end;
}

private TimeSpan timeSpan;

public LemmaDto() {
this.glyphs=new Glyphs();
this.transcription=new Transcription();
this.translations = Collections.emptySortedMap();
this.words = Collections.emptyList();
}
@Getter
@Setter
@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonIgnoreProperties(ignoreUnknown = true)
public static class Glyphs {
@JsonAlias({"mdc_compact"})
private String mdcCompact;
@JsonAlias({"unicode"})
private String unicode;


@JsonIgnore

public boolean isEmpty() {
return (
(this.mdcCompact == null || this.mdcCompact.isBlank()) &&
(this.unicode == null || this.unicode.isBlank())
);
}

public static class EmptyObjectFilter {
@Override
public boolean equals(Object obj) {
if (obj != null && obj instanceof Glyphs) {
return ((Glyphs) obj).isEmpty();
}
return true;
}
}
}

@Getter
@Setter
@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonIgnoreProperties(ignoreUnknown = true)
public static class Transcription {
@JsonAlias({"mdc"})
private String mdc;
@JsonAlias({"unicode"})
private String unicode;


@JsonIgnore

public boolean isEmpty() {
return (
(this.mdc == null || this.mdc.isBlank()) &&
(this.unicode == null || this.unicode.isBlank())
);
}

public static class EmptyObjectFilter {
@Override
public boolean equals(Object obj) {
if (obj != null && obj instanceof Glyphs) {
return ((Transcription) obj).isEmpty();
}
return true;
}
}
}
@JsonAlias({ "sortString", "sort_string", "sort_key" })
private String sortKey;

@JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = Glyphs.EmptyObjectFilter.class)
private Glyphs glyphs;

@Singular
private SortedMap<Language, List<String>> translations;

private Transcription transcription;

private Collection<Spelling> spellings;

@Singular
private List<SentenceToken> words;

private int attestedSentencesCount;

private TimeSpan timeSpan;

public static class Spelling {
@Setter
@Getter
private String unicode;

@Setter
@Getter
private String mdc;

@Setter
@Getter
private String lingGloss;

@Setter
@Getter
private String count;
}

public static class TimeSpan {
/** first year */
@Setter
@Getter
private int begin;
/** last year */
@Setter
@Getter
private int end;
}



public LemmaDto() {
this.glyphs = new Glyphs();
this.transcription = new Transcription();
this.translations = Collections.emptySortedMap();
this.words = Collections.emptyList();
}

@Getter
@Setter
@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonIgnoreProperties(ignoreUnknown = true)
public static class Glyphs {
@JsonAlias({ "mdc_compact" })
private String mdcCompact;
@JsonAlias({ "unicode" })
private String unicode;

@JsonIgnore

public boolean isEmpty() {
return ((this.mdcCompact == null || this.mdcCompact.isBlank())
&& (this.unicode == null || this.unicode.isBlank()));
}

public static class EmptyObjectFilter {
@Override
public boolean equals(Object obj) {
if (obj != null && obj instanceof Glyphs) {
return ((Glyphs) obj).isEmpty();
}
return true;
}
}
}

@Getter
@Setter
@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonIgnoreProperties(ignoreUnknown = true)
public static class Transcription {
@JsonAlias({ "mdc" })
private String mdc;
@JsonAlias({ "unicode" })
private String unicode;

@JsonIgnore

public boolean isEmpty() {
return ((this.mdc == null || this.mdc.isBlank()) && (this.unicode == null || this.unicode.isBlank()));
}

public static class EmptyObjectFilter {
@Override
public boolean equals(Object obj) {
if (obj != null && obj instanceof Glyphs) {
return ((Transcription) obj).isEmpty();
}
return true;
}
}
}
}

0 comments on commit fd26aec

Please sign in to comment.