package net.fortuna.ical4j.model;

import net.fortuna.ical4j.model.property.XProperty;
import org.apache.commons.codec.DecoderException;

import java.io.IOException;
import java.net.URISyntaxException;
import java.text.ParseException;
import java.util.Collections;
import java.util.List;

/**
 * Provides a configurable builder for creating {@link Property} instances from {@link String} values.
 *
 * You can specify an arbitrary list of supported property factories, and a list of property names to ignore.
 */
public class PropertyBuilder extends AbstractContentBuilder {

    private final List<PropertyFactory<?>> factories;

    private String name;

    private String value;

    private ParameterList parameters = new ParameterList();

    public PropertyBuilder() {
        this(Collections.emptyList());
    }

    public PropertyBuilder(List<PropertyFactory<? extends Property>> factories) {
        this.factories = factories;
    }

    public PropertyBuilder name(String name) {
        // property names are case-insensitive, but convert to upper case to simplify further processing
        this.name = name.toUpperCase();
        return this;
    }

    public PropertyBuilder value(String value) {
        // remove any trailing whitespace
        this.value = value.trim();
        return this;
    }

    public PropertyBuilder parameter(Parameter parameter) {
        parameters.add(parameter);
        return this;
    }

    public Property build() throws ParseException, IOException, URISyntaxException {
        Property property = null;
        String decodedValue;
        try {
            decodedValue = PropertyCodec.INSTANCE.decode(value);
        } catch (DecoderException e) {
            decodedValue = value;
        }

        for (PropertyFactory<?> factory : factories) {
            if (factory.supports(name)) {
                property = factory.createProperty(parameters, value);
            }
        }

        if (property == null) {
            if (isExperimentalName(name)) {
                property = new XProperty(name, parameters, value);
            } else if (allowIllegalNames()) {
                property = new XProperty(name, parameters, value);
            } else {
                throw new IllegalArgumentException("Illegal property [" + name + "]");
            }
        }

        if (property instanceof Encodable) {
            property.setValue(decodedValue);
        }

        return property;
    }
}

@@ -245,27 +245,25 @@
 va.util.
-Collections
+ArrayList
 ;%0Aimport
@@ -784,29 +784,23 @@
 his(
-Collections.empt
+new Arra
 yList
+%3C%3E
 ());
@@ -881,32 +881,32 @@
 %3E%3E factories) %7B%0A
-
         this.fac
@@ -924,32 +924,484 @@
 ctories;%0A    %7D%0A%0A
+    /**%0A     * Set the list of property factories supporting this builder instance.%0A     * @param factories a list of property factories%0A     * @return the builder instance%0A     * @deprecated preference the constructor option for specifying factories%0A     */%0A    @Deprecated%0A    public PropertyBuilder factories(List%3CPropertyFactory%3C?%3E%3E factories) %7B%0A        this.factories.clear();%0A        this.factories.addAll(factories);%0A        return this;%0A    %7D%0A%0A
     public Prope

Revert method removal for backwards compatibility