net.fortuna.ical4j.model.ComponentContainer 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.model;
import java.util.function.BiFunction;
public interface ComponentContainer extends ComponentListAccessor {
void setComponentList(ComponentList components);
/**
* Add a subcomponent to this component.
* @param component the subcomponent to add
* @return a reference to this component to support method chaining
*/
default > T add(C component) {
setComponentList((ComponentList) getComponentList().add(component));
//noinspection unchecked
return (T) this;
}
/**
* Remove a subcomponent from this component.
* @param component the subcomponent to remove
* @return a reference to this component to support method chaining
*/
default > T remove(C component) {
setComponentList((ComponentList) getComponentList().remove(component));
//noinspection unchecked
return (T) this;
}
/**
* Add a subcomponent to this component whilst removing all other subcomponents with the same component name.
* @param component the subcomponent to add
* @return a reference to the component to support method chaining
*/
default > T replace(C component) {
setComponentList((ComponentList) getComponentList().replace(component));
//noinspection unchecked
return (T) this;
}
/**
* A functional method used to apply a component to a container in an undefined way.
*
* For example, a null check can be introduced as follows:
*
* container.with((container, component) -> if (component != null) container.add(component); return container;)
* @param f
* @param c
* @return
* @param
*/
default > T with(BiFunction f, C c) {
return f.apply((T) this, c);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy