Skip to content

Commit

Permalink
Use superclass validator for simple validation
Browse files Browse the repository at this point in the history
  • Loading branch information
benfortuna committed Nov 26, 2016
1 parent 2a4378c commit 267c3ff
Show file tree
Hide file tree
Showing 42 changed files with 97 additions and 559 deletions.
8 changes: 0 additions & 8 deletions src/main/java/net/fortuna/ical4j/model/property/Action.java
Expand Up @@ -32,7 +32,6 @@
package net.fortuna.ical4j.model.property;

import net.fortuna.ical4j.model.*;
import net.fortuna.ical4j.validate.ValidationException;

import java.io.IOException;
import java.net.URISyntaxException;
Expand Down Expand Up @@ -134,13 +133,6 @@ public final String getValue() {
return value;
}

/**
* {@inheritDoc}
*/
public final void validate() throws ValidationException {
// TODO: Auto-generated method stub
}

public static class Factory extends Content.Factory implements PropertyFactory {
private static final long serialVersionUID = 1L;

Expand Down
8 changes: 0 additions & 8 deletions src/main/java/net/fortuna/ical4j/model/property/BusyType.java
Expand Up @@ -32,7 +32,6 @@
package net.fortuna.ical4j.model.property;

import net.fortuna.ical4j.model.*;
import net.fortuna.ical4j.validate.ValidationException;

import java.io.IOException;
import java.net.URISyntaxException;
Expand Down Expand Up @@ -143,13 +142,6 @@ public final String getValue() {
return value;
}

/**
* {@inheritDoc}
*/
public final void validate() throws ValidationException {
// TODO: Auto-generated method stub
}

public static class Factory extends Content.Factory implements PropertyFactory<BusyType> {
private static final long serialVersionUID = 1L;

Expand Down
32 changes: 9 additions & 23 deletions src/main/java/net/fortuna/ical4j/model/property/Categories.java
Expand Up @@ -32,8 +32,7 @@
package net.fortuna.ical4j.model.property;

import net.fortuna.ical4j.model.*;
import net.fortuna.ical4j.validate.ParameterValidator;
import net.fortuna.ical4j.validate.ValidationException;
import net.fortuna.ical4j.validate.property.OneOrLessParameterValidator;

import java.io.IOException;
import java.net.URISyntaxException;
Expand Down Expand Up @@ -100,15 +99,17 @@ public class Categories extends Property {
* Default constructor.
*/
public Categories() {
super(CATEGORIES, PropertyFactoryImpl.getInstance());
super(CATEGORIES, new ParameterList(), new OneOrLessParameterValidator(Parameter.LANGUAGE),
PropertyFactoryImpl.getInstance());
categories = new TextList();
}

/**
* @param aValue a value string for this component
*/
public Categories(final String aValue) {
super(CATEGORIES, PropertyFactoryImpl.getInstance());
super(CATEGORIES, new ParameterList(), new OneOrLessParameterValidator(Parameter.LANGUAGE),
PropertyFactoryImpl.getInstance());
setValue(aValue);
}

Expand All @@ -117,15 +118,16 @@ public Categories(final String aValue) {
* @param aValue a value string for this component
*/
public Categories(final ParameterList aList, final String aValue) {
super(CATEGORIES, aList, PropertyFactoryImpl.getInstance());
super(CATEGORIES, aList, new OneOrLessParameterValidator(Parameter.LANGUAGE), PropertyFactoryImpl.getInstance());
setValue(aValue);
}

/**
* @param cList a list of categories
*/
public Categories(final TextList cList) {
super(CATEGORIES, PropertyFactoryImpl.getInstance());
super(CATEGORIES, new ParameterList(), new OneOrLessParameterValidator(Parameter.LANGUAGE),
PropertyFactoryImpl.getInstance());
categories = cList;
}

Expand All @@ -134,7 +136,7 @@ public Categories(final TextList cList) {
* @param cList a list of categories
*/
public Categories(final ParameterList aList, final TextList cList) {
super(CATEGORIES, aList, PropertyFactoryImpl.getInstance());
super(CATEGORIES, aList, new OneOrLessParameterValidator(Parameter.LANGUAGE), PropertyFactoryImpl.getInstance());
categories = cList;
}

Expand All @@ -145,22 +147,6 @@ public final void setValue(final String aValue) {
categories = new TextList(aValue);
}

/**
* {@inheritDoc}
*/
public final void validate() throws ValidationException {

/*
* ; the following is optional, ; but MUST NOT occur more than once (";" languageparam ) /
*/
ParameterValidator.getInstance().assertOneOrLess(Parameter.LANGUAGE,
getParameters());

/*
* ; the following is optional, ; and MAY occur more than once (";" xparam)
*/
}

/**
* @return Returns the categories.
*/
Expand Down
8 changes: 0 additions & 8 deletions src/main/java/net/fortuna/ical4j/model/property/Clazz.java
Expand Up @@ -32,7 +32,6 @@
package net.fortuna.ical4j.model.property;

import net.fortuna.ical4j.model.*;
import net.fortuna.ical4j.validate.ValidationException;

import java.io.IOException;
import java.net.URISyntaxException;
Expand Down Expand Up @@ -175,13 +174,6 @@ public final String getValue() {
return value;
}

/**
* {@inheritDoc}
*/
public final void validate() throws ValidationException {
// TODO: Auto-generated method stub
}

public static class Factory extends Content.Factory implements PropertyFactory {
private static final long serialVersionUID = 1L;

Expand Down
30 changes: 7 additions & 23 deletions src/main/java/net/fortuna/ical4j/model/property/Comment.java
Expand Up @@ -32,8 +32,7 @@
package net.fortuna.ical4j.model.property;

import net.fortuna.ical4j.model.*;
import net.fortuna.ical4j.validate.ParameterValidator;
import net.fortuna.ical4j.validate.ValidationException;
import net.fortuna.ical4j.validate.property.OneOrLessParameterValidator;

import java.io.IOException;
import java.net.URISyntaxException;
Expand All @@ -58,14 +57,16 @@ public class Comment extends Property implements Escapable {
* Default constructor.
*/
public Comment() {
super(COMMENT, PropertyFactoryImpl.getInstance());
super(COMMENT, new ParameterList(), new OneOrLessParameterValidator(Parameter.ALTREP, Parameter.LANGUAGE),
PropertyFactoryImpl.getInstance());
}

/**
* @param aValue a value string for this component
*/
public Comment(final String aValue) {
super(COMMENT, PropertyFactoryImpl.getInstance());
super(COMMENT, new ParameterList(), new OneOrLessParameterValidator(Parameter.ALTREP, Parameter.LANGUAGE),
PropertyFactoryImpl.getInstance());
setValue(aValue);
}

Expand All @@ -74,28 +75,11 @@ public Comment(final String aValue) {
* @param aValue a value string for this component
*/
public Comment(final ParameterList aList, final String aValue) {
super(COMMENT, aList, PropertyFactoryImpl.getInstance());
super(COMMENT, aList, new OneOrLessParameterValidator(Parameter.ALTREP, Parameter.LANGUAGE),
PropertyFactoryImpl.getInstance());
setValue(aValue);
}

/**
* {@inheritDoc}
*/
public final void validate() throws ValidationException {

/*
* ; the following are optional, ; but MUST NOT occur more than once (";" altrepparam) / (";" languageparam) /
*/
ParameterValidator.getInstance().assertOneOrLess(Parameter.ALTREP,
getParameters());
ParameterValidator.getInstance().assertOneOrLess(Parameter.LANGUAGE,
getParameters());

/*
* ; the following is optional, ; and MAY occur more than once (";" xparam)
*/
}

/**
* {@inheritDoc}
*/
Expand Down
30 changes: 7 additions & 23 deletions src/main/java/net/fortuna/ical4j/model/property/Contact.java
Expand Up @@ -32,8 +32,7 @@
package net.fortuna.ical4j.model.property;

import net.fortuna.ical4j.model.*;
import net.fortuna.ical4j.validate.ParameterValidator;
import net.fortuna.ical4j.validate.ValidationException;
import net.fortuna.ical4j.validate.property.OneOrLessParameterValidator;

import java.io.IOException;
import java.net.URISyntaxException;
Expand All @@ -58,14 +57,16 @@ public class Contact extends Property implements Escapable {
* Default constructor.
*/
public Contact() {
super(CONTACT, PropertyFactoryImpl.getInstance());
super(CONTACT, new ParameterList(), new OneOrLessParameterValidator(Parameter.ALTREP, Parameter.LANGUAGE),
PropertyFactoryImpl.getInstance());
}

/**
* @param aValue a value string for this component
*/
public Contact(final String aValue) {
super(CONTACT, PropertyFactoryImpl.getInstance());
super(CONTACT, new ParameterList(), new OneOrLessParameterValidator(Parameter.ALTREP, Parameter.LANGUAGE),
PropertyFactoryImpl.getInstance());
setValue(aValue);
}

Expand All @@ -74,28 +75,11 @@ public Contact(final String aValue) {
* @param aValue a value string for this component
*/
public Contact(final ParameterList aList, final String aValue) {
super(CONTACT, aList, PropertyFactoryImpl.getInstance());
super(CONTACT, aList, new OneOrLessParameterValidator(Parameter.ALTREP, Parameter.LANGUAGE),
PropertyFactoryImpl.getInstance());
setValue(aValue);
}

/**
* {@inheritDoc}
*/
public final void validate() throws ValidationException {

/*
* ; the following are optional, ; but MUST NOT occur more than once (";" altrepparam) / (";" languageparam) /
*/
ParameterValidator.getInstance().assertOneOrLess(Parameter.ALTREP,
getParameters());
ParameterValidator.getInstance().assertOneOrLess(Parameter.LANGUAGE,
getParameters());

/*
* ; the following is optional, ; and MAY occur more than once (";" xparam)
*/
}

/**
* {@inheritDoc}
*/
Expand Down
27 changes: 6 additions & 21 deletions src/main/java/net/fortuna/ical4j/model/property/Country.java
Expand Up @@ -32,8 +32,7 @@
package net.fortuna.ical4j.model.property;

import net.fortuna.ical4j.model.*;
import net.fortuna.ical4j.validate.ParameterValidator;
import net.fortuna.ical4j.validate.ValidationException;
import net.fortuna.ical4j.validate.property.OneOrLessParameterValidator;

import java.io.IOException;
import java.net.URISyntaxException;
Expand All @@ -59,14 +58,16 @@ public class Country extends Property implements Escapable {
* Default constructor.
*/
public Country() {
super(COUNTRY, PropertyFactoryImpl.getInstance());
super(COUNTRY, new ParameterList(), new OneOrLessParameterValidator(Parameter.ABBREV),
PropertyFactoryImpl.getInstance());
}

/**
* @param aValue a value string for this component
*/
public Country(final String aValue) {
super(COUNTRY, PropertyFactoryImpl.getInstance());
super(COUNTRY, new ParameterList(), new OneOrLessParameterValidator(Parameter.ABBREV),
PropertyFactoryImpl.getInstance());
setValue(aValue);
}

Expand All @@ -75,26 +76,10 @@ public Country(final String aValue) {
* @param aValue a value string for this component
*/
public Country(final ParameterList aList, final String aValue) {
super(COUNTRY, aList, PropertyFactoryImpl.getInstance());
super(COUNTRY, aList, new OneOrLessParameterValidator(Parameter.ABBREV), PropertyFactoryImpl.getInstance());
setValue(aValue);
}

/**
* {@inheritDoc}
*/
public final void validate() throws ValidationException {

/*
* ; the following are optional, ; but MUST NOT occur more than once (";" abbrev
*/
ParameterValidator.getInstance().assertOneOrLess(Parameter.ABBREV,
getParameters());

/*
* ; the following is optional, ; and MAY occur more than once (";" xparam)
*/
}

/**
* {@inheritDoc}
*/
Expand Down
Expand Up @@ -223,6 +223,15 @@ public final boolean isUtc() {
*/
public void validate() throws ValidationException {

/*
* ; the following are optional, ; but MUST NOT occur more than once (";" "VALUE" "=" ("DATE-TIME" / "DATE")) /
* (";" tzidparam) /
*/

/*
* ; the following is optional, ; and MAY occur more than once (";" xparam)
*/

ParameterValidator.getInstance().assertOneOrLess(Parameter.VALUE,
getParameters());

Expand Down
30 changes: 7 additions & 23 deletions src/main/java/net/fortuna/ical4j/model/property/Description.java
Expand Up @@ -32,8 +32,7 @@
package net.fortuna.ical4j.model.property;

import net.fortuna.ical4j.model.*;
import net.fortuna.ical4j.validate.ParameterValidator;
import net.fortuna.ical4j.validate.ValidationException;
import net.fortuna.ical4j.validate.property.OneOrLessParameterValidator;

import java.io.IOException;
import java.net.URISyntaxException;
Expand All @@ -58,14 +57,16 @@ public class Description extends Property implements Escapable {
* Default constructor.
*/
public Description() {
super(DESCRIPTION, PropertyFactoryImpl.getInstance());
super(DESCRIPTION, new ParameterList(), new OneOrLessParameterValidator(Parameter.ALTREP, Parameter.LANGUAGE),
PropertyFactoryImpl.getInstance());
}

/**
* @param aValue a value string for this component
*/
public Description(final String aValue) {
super(DESCRIPTION, PropertyFactoryImpl.getInstance());
super(DESCRIPTION, new ParameterList(), new OneOrLessParameterValidator(Parameter.ALTREP, Parameter.LANGUAGE),
PropertyFactoryImpl.getInstance());
setValue(aValue);
}

Expand All @@ -74,28 +75,11 @@ public Description(final String aValue) {
* @param aValue a value string for this component
*/
public Description(final ParameterList aList, final String aValue) {
super(DESCRIPTION, aList, PropertyFactoryImpl.getInstance());
super(DESCRIPTION, aList, new OneOrLessParameterValidator(Parameter.ALTREP, Parameter.LANGUAGE),
PropertyFactoryImpl.getInstance());
setValue(aValue);
}

/**
* {@inheritDoc}
*/
public final void validate() throws ValidationException {

/*
* ; the following are optional, ; but MUST NOT occur more than once (";" altrepparam) / (";" languageparam) /
*/
ParameterValidator.getInstance().assertOneOrLess(Parameter.ALTREP,
getParameters());
ParameterValidator.getInstance().assertOneOrLess(Parameter.LANGUAGE,
getParameters());

/*
* ; the following is optional, ; and MAY occur more than once (";" xparam)
*/
}

/**
* {@inheritDoc}
*/
Expand Down

0 comments on commit 267c3ff

Please sign in to comment.