All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.fortuna.ical4j.transform.component.UidUpdate Maven / Gradle / Ivy

There is a newer version: 4.0.8
Show newest version
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