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

net.fortuna.ical4j.model.PropertyContainer Maven / Gradle / Ivy

package net.fortuna.ical4j.model;

import java.util.List;
import java.util.Optional;

public interface PropertyContainer {

    PropertyList getProperties();

    void setProperties(PropertyList properties);

    default  List getProperties(final String name) {
        return getProperties().get(name);
    }

    default  Optional getProperty(final String name) {
        return getProperties().getFirst(name);
    }

    /**
     * Add a property to the container.
     * @param property the property to add
     * @return a reference to the container to support method chaining
     */
    default PropertyContainer add(Property property) {
        setProperties((PropertyList) getProperties().add(property));
        return this;
    }

    /**
     * Remove a property from the container.
     * @param property the property to remove
     * @return a reference to the container to support method chaining
     */
    default PropertyContainer remove(Property property) {
        setProperties((PropertyList) getProperties().remove(property));
        return this;
    }

    /**
     * Remove all properties with the matching name.
     * @param name name of the properties to remove
     * @return a reference to the container to support method chaining
     */
    default PropertyContainer removeAll(String... name) {
        setProperties((PropertyList) getProperties().removeAll(name));
        return this;
    }

    /**
     * Add a property to the container whilst removing all other properties with the same property name.
     * @param property the property to add
     * @return a reference to the container to support method chaining
     */
    default PropertyContainer replace(Property property) {
        setProperties((PropertyList) getProperties().replace(property));
        return this;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy