cdc.mf.html.index.IndexSection Maven / Gradle / Ivy
The newest version!
package cdc.mf.html.index;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import cdc.mf.model.MfElement;
import cdc.mf.model.MfNameItem;
public class IndexSection {
private static final Comparator COMPARATOR =
Comparator.comparing((MfNameItem e) -> Index.getEffectiveName(e).toLowerCase())
.thenComparing(MfNameItem::getKind)
.thenComparing(IndexSection::getEffectiveId);
private final char key;
private final List entries = new ArrayList<>();
private int number = -1;
IndexSection(char key) {
this.key = key;
}
private static String getEffectiveId(MfElement item) {
final String id = item.getId();
return id == null ? "" : id;
}
void add(MfNameItem entry) {
this.entries.add(entry);
}
void sort() {
Collections.sort(entries, COMPARATOR);
}
void setNumber(int number) {
this.number = number;
}
public char getKey() {
return key;
}
public List getEntries() {
return entries;
}
public int getNumber() {
return number;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy