Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feature/jsr-310-lo…
Browse files Browse the repository at this point in the history
…caldate

# Conflicts:
#	build.gradle
#	gradle.properties
#	gradlew.bat
#	src/test/java/net/fortuna/ical4j/model/property/LocationTypeTest.java
  • Loading branch information
benfortuna committed Mar 14, 2021
2 parents 20eebdd + 09e11e8 commit 2f8d8c6
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 8 deletions.
Expand Up @@ -8,7 +8,7 @@
import java.util.List;
import java.util.function.Supplier;

class DefaultComponentFactorySupplier implements Supplier<List<ComponentFactory<? extends Component>>> {
public class DefaultComponentFactorySupplier implements Supplier<List<ComponentFactory<? extends Component>>> {

@Override
public List<ComponentFactory<? extends Component>> get() {
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/net/fortuna/ical4j/model/LocationTypeList.java
Expand Up @@ -70,6 +70,11 @@ public LocationTypeList(final String aValue) {
locationTypes.addAll(Arrays.asList(aValue.split(",")));
}

public LocationTypeList(LocationType... locationTypes) {
this.locationTypes = Arrays.stream(locationTypes).map(LocationType::toString)
.collect(Collectors.toList());
}

/**
* {@inheritDoc}
*/
Expand Down
50 changes: 44 additions & 6 deletions src/main/java/net/fortuna/ical4j/model/property/LocationType.java
Expand Up @@ -49,13 +49,41 @@
import static net.fortuna.ical4j.validate.ValidationRule.ValidationType.OneOrLess;

/**
* $Id$
* <p/>
* Created: [Apr 6, 2004]
* <p/>
* Defines a LOCATION_TYPE iCalendar component property.
* <pre>
* 6.1. Location Type
*
* @author benf
* Property name: LOCATION-TYPE
*
* Purpose: To specify the type(s) of a location.
*
* Value type: The value type for this property is TEXT. The allowable
* values are defined below.
*
* Description: This property MAY be specified in VLOCATION components
* and provides a way to differentiate multiple locations. For
* example, it allows event producers to provide location information
* for the venue and the parking.
*
* Format Definition:
*
* This property is defined by the following notation:
*
* loctype = "LOCATION-TYPE" loctypeparam ":"
* text *("," text)
* CRLF
*
* loctypeparam = *(";" other-param)
*
* Multiple values may be used if the location has multiple purposes,
* for example a hotel and a restaurant.
*
* Values for this parameter are taken from the values defined in
* [RFC4589] section 3. New location types SHOULD be registered in
* the manner laid down in section 5 of that specification.
* </pre>
*
* @author Mike Douglass, Ben Fortuna
* @see <a href="https://tools.ietf.org/html/draft-ietf-calext-eventpub-extensions-18#section-6.1">Event Publishing Extensions to iCalendar</a>
*/
public class LocationType extends Property {

Expand Down Expand Up @@ -108,6 +136,16 @@ public LocationType(final ParameterList aList, final List<net.fortuna.ical4j.mod
locationTypes = cList;
}

public LocationType(net.fortuna.ical4j.model.LocationType... locationTypes) {
super(LOCATION_TYPE, new ParameterList(), new Factory());
this.locationTypes = new LocationTypeList(locationTypes);
}

public LocationType(ParameterList params, net.fortuna.ical4j.model.LocationType... locationTypes) {
super(LOCATION_TYPE, params, new Factory());
this.locationTypes = new LocationTypeList(locationTypes);
}

/**
* {@inheritDoc}
*/
Expand Down
26 changes: 26 additions & 0 deletions src/test/groovy/net/fortuna/ical4j/model/LocationTypeTest.groovy
@@ -0,0 +1,26 @@
package net.fortuna.ical4j.model

import spock.lang.Specification

class LocationTypeTest extends Specification {

def 'assert string parsing'() {
expect:
LocationType.from(locationTypeString) == expectedType

where:
locationTypeString | expectedType
"public" | LocationType.public_
"bus-station" | LocationType.bus_station
}

def 'assert string formatting'() {
expect:
locationType as String == expectedString

where:
locationType | expectedString
LocationType.public_ | "public"
LocationType.bus_station | "bus-station"
}
}
Expand Up @@ -65,7 +65,7 @@ public LocationTypeTest(String testMethod, LocationType property) {
*/
public static TestSuite suite() {
TestSuite suite = new TestSuite();
LocationType type = new LocationType("bus-station");
LocationType type = new LocationType(net.fortuna.ical4j.model.LocationType.bus_station);
suite.addTest(new LocationTypeTest(type, "bus-station"));
suite.addTest(new LocationTypeTest("testValidation", type));
suite.addTest(new LocationTypeTest("testEquals", type));
Expand Down

0 comments on commit 2f8d8c6

Please sign in to comment.