net.fortuna.ical4j.model.ComponentFactoryWrapper.groovy 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 net.fortuna.ical4j.model.ComponentFactory
import net.fortuna.ical4j.model.Property
import net.fortuna.ical4j.model.PropertyList
class ComponentFactoryWrapper extends AbstractFactory {
Class componentClass
ComponentFactory factory
ComponentFactoryWrapper(Class compClass, ComponentFactory factory) {
this.componentClass = compClass
this.factory = factory
}
@Override
Object newInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes) throws InstantiationException, IllegalAccessException {
if (FactoryBuilderSupport.checkValueIsTypeNotString(value, name, componentClass)) {
return value
}
List properties = (List) attributes.remove('properties')
if (properties == null) {
properties = []
}
return factory.createComponent(new PropertyList(properties))
}
void setChild(FactoryBuilderSupport build, Object parent, Object child) {
if (child instanceof Property || child instanceof Component) {
parent.add(child)
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy