
ch.stegmaier.java2tex.genealogytree.impl.graphgrammar.EventDataKey Maven / Gradle / Ivy
package ch.stegmaier.java2tex.genealogytree.impl.graphgrammar;
import org.apache.commons.lang3.StringUtils;
import ch.stegmaier.java2tex.core.BaseCommand;
import ch.stegmaier.java2tex.genealogytree.DataKeys.Modifier;
public class EventDataKey extends DataKey {
private final String eventKey;
private String date;
private String place;
private String modifier;
public EventDataKey(String key) {
super(key + "-");
this.eventKey = key;
}
public EventDataKey addDate(String date) {
this.date = date;
return this;
}
public EventDataKey addPlace(String place) {
this.place = place;
return this;
}
public EventDataKey addModifier(String modifier) {
this.modifier = modifier;
return this;
}
public EventDataKey addModifier(Modifier modifier) {
return addModifier(modifier.getModifier());
}
@Override
public void build() {
// date must be first
this.values.add(date == null ? "" : date);
minValues=1;
// place must be second
if (StringUtils.isNotEmpty(place) || StringUtils.isNotEmpty(modifier)) {
this.values.add(place == null ? "" : place);
minValues=2;
this.key = eventKey;
}
// modifier must be third
if (StringUtils.isNotEmpty(modifier)) {
this.values.add(modifier);
minValues=3;
this.key = eventKey + "+";
}
}
public EventDataKey addDate(BaseCommand date) {
return addDate(date.toString());
}
public EventDataKey addPlace(BaseCommand place) {
return addPlace(place.toString());
}
public EventDataKey addModifier(BaseCommand modifier) {
return addModifier(modifier.toString());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy