package net.fortuna.ical4j.validate.component;

import net.fortuna.ical4j.model.Property;
import net.fortuna.ical4j.model.component.VFreeBusy;
import net.fortuna.ical4j.validate.PropertyValidator;
import net.fortuna.ical4j.validate.ValidationException;
import net.fortuna.ical4j.validate.Validator;

/**
 * <pre>
 * Component/Property  Presence
 * ------------------- ----------------------------------------------
 * METHOD              1       MUST be "PUBLISH"
 *
 * VFREEBUSY           1+
 *     DTSTAMP         1
 *     DTSTART         1       DateTime values must be in UTC
 *     DTEND           1       DateTime values must be in UTC
 *     FREEBUSY        1+      MUST be BUSYTIME. Multiple instances are
 *                             allowed. Multiple instances must be sorted
 *                             in ascending order
 *     ORGANIZER       1       MUST contain the address of originator of
 *                             busy time data.
 *     UID             1
 *     COMMENT         0 or 1
 *     CONTACT         0+
 *     X-PROPERTY      0+
 *     URL             0 or 1  Specifies busy time URL
 *
 *     ATTENDEE        0
 *     DURATION        0
 *     REQUEST-STATUS  0
 *
 * X-COMPONENT         0+
 *
 * VEVENT              0
 * VTODO               0
 * VJOURNAL            0
 * VTIMEZONE           0
 * VALARM              0
 * </pre>
 *
 */
public class VFreeBusyPublishValidator implements Validator<VFreeBusy> {

    private static final long serialVersionUID = 1L;

    public void validate(VFreeBusy target) throws ValidationException {
        PropertyValidator.getInstance().assertOneOrMore(Property.FREEBUSY, target.getProperties());

        PropertyValidator.getInstance().assertOne(Property.DTSTAMP, target.getProperties());
        PropertyValidator.getInstance().assertOne(Property.DTSTART, target.getProperties());
        PropertyValidator.getInstance().assertOne(Property.DTEND, target.getProperties());
        PropertyValidator.getInstance().assertOne(Property.ORGANIZER, target.getProperties());
        PropertyValidator.getInstance().assertOne(Property.UID, target.getProperties());

        PropertyValidator.getInstance().assertOneOrLess(Property.URL, target.getProperties());

        PropertyValidator.getInstance().assertNone(Property.ATTENDEE, target.getProperties());
        PropertyValidator.getInstance().assertNone(Property.DURATION, target.getProperties());
        PropertyValidator.getInstance().assertNone(Property.REQUEST_STATUS, target.getProperties());
    }
}

@@ -291,16 +291,146 @@
 lidator;
+%0Aimport org.apache.commons.collections4.Closure;%0Aimport org.apache.commons.collections4.CollectionUtils;%0A%0Aimport java.util.Arrays;
 %0A%0A/**%0A *
@@ -1648,16 +1648,22 @@
 alidate(
+final 
 VFreeBus
@@ -1814,194 +1814,129 @@
     
-PropertyValidator.getInstance().assertOne(Property.DTSTAMP, target.getProperties());%0A        PropertyValidator.getInstance().assertOne(Property.DTSTART, target.getProperties());%0A
+CollectionUtils.forAllDo(Arrays.asList(Property.DTSTAMP, Property.DTSTART, Property.DTEND, Property.ORGANIZER,%0A  
         
 Prop
@@ -1927,32 +1927,38 @@
 ,%0A          
+      
 Property
 Validator.ge
@@ -1949,178 +1949,117 @@
 erty
-Validator.getInstance().assertOne(Property.DTEND, target.getProperties());%0A        PropertyValidator.getInstance().assertOne(Property.ORGANIZER, target.getProperties());%0A
+.UID), new Closure%3CString%3E() %7B%0A            @Override%0A            public void execute(String input) %7B%0A        
     
@@ -2104,28 +2104,21 @@
 sertOne(
-Property.UID
+input
 , target
@@ -2127,32 +2127,58 @@
 etProperties());
+%0A            %7D%0A        %7D);
 %0A%0A        Proper
@@ -2271,190 +2271,229 @@
     
-PropertyValidator.getInstance().assertNone(Property.ATTENDEE, target.getProperties());%0A        PropertyValidator.getInstance().assertNone(Property.DURATION, target.getProperties());%0A
+CollectionUtils.forAllDo(Arrays.asList(Property.ATTENDEE, Property.DURATION, Property.REQUEST_STATUS),%0A                new Closure%3CString%3E() %7B%0A            @Override%0A            public void execute(String input) %7B%0A        
     
@@ -2539,39 +2539,21 @@
 ertNone(
-Property.REQUEST_STATUS
+input
 , target
@@ -2567,20 +2567,46 @@
 perties());%0A
+            %7D%0A        %7D);%0A
     %7D%0A%7D%0A

Use closures to reduce duplicate code