net.fortuna.ical4j.transform.component.UidUpdate Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ical4j Show documentation
Show all versions of ical4j Show documentation
A Java library for reading and writing iCalendar (*.ics) files
package net.fortuna.ical4j.transform.component;
import net.fortuna.ical4j.model.Component;
import net.fortuna.ical4j.model.Property;
import net.fortuna.ical4j.model.property.Uid;
import net.fortuna.ical4j.transform.Transformer;
import net.fortuna.ical4j.util.UidGenerator;
import java.util.Optional;
public class UidUpdate implements Transformer {
private final UidGenerator uidGenerator;
public UidUpdate(UidGenerator uidGenerator) {
this.uidGenerator = uidGenerator;
}
@Override
public Component transform(Component object) {
Optional uid = object.getProperties().getFirst(Property.UID);
if (!uid.isPresent()) {
object.add(uidGenerator.generateUid());
}
return object;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy