Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
benfortuna committed Aug 4, 2021
1 parent d72513d commit a32216e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 23 deletions.
20 changes: 0 additions & 20 deletions src/main/java/net/fortuna/ical4j/model/Component.java
Expand Up @@ -194,26 +194,6 @@ public final PropertyList<Property> getProperties() {
return properties;
}

/**
* Convenience method for retrieving a list of named properties.
*
* @param name name of properties to retrieve
* @return a property list containing only properties with the specified name
*/
public final <C extends Property> PropertyList<C> getProperties(final String name) {
return getProperties().getProperties(name);
}

/**
* Convenience method for retrieving a named property.
*
* @param name name of the property to retrieve
* @return the first matching property in the property list with the specified name
*/
public final <T extends Property> T getProperty(final String name) {
return (T) getProperties().getProperty(name);
}

/**
* Convenience method for retrieving a required named property.
*
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/fortuna/ical4j/model/ComponentList.java
Expand Up @@ -117,7 +117,7 @@ public final T getComponent(final String aName) {
*/
@SuppressWarnings("unchecked")
public final <C extends T> ComponentList<C> getComponents(final String name) {
final ComponentList<C> components = new ComponentList<C>();
final ComponentList<C> components = new ComponentList<>();
for (final T c : this) {
if (c.getName().equals(name)) {
components.add((C) c);
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/net/fortuna/ical4j/model/ParameterList.java
Expand Up @@ -176,6 +176,15 @@ public final boolean isEmpty() {
return parameters.isEmpty();
}

/**
* Returns true if this parameter list includes the specified parameter.
* @param parameter a parameter specification
* @return true if parameter matching specification is found
*/
public boolean contains(Parameter parameter) {
return parameters.contains(parameter);
}

/**
* @return an iterator
* @see List#iterator()
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/net/fortuna/ical4j/model/PropertyContainer.java
Expand Up @@ -4,7 +4,11 @@ public interface PropertyContainer {

PropertyList<Property> getProperties();

<T extends Property> PropertyList<T> getProperties(final String name);
default <T extends Property> PropertyList<T> getProperties(final String name) {
return getProperties().getProperties(name);
}

<T extends Property> T getProperty(final String name);
default <T extends Property> T getProperty(final String name) {
return getProperties().getProperty(name);
}
}

0 comments on commit a32216e

Please sign in to comment.