Skip to content

Commit

Permalink
Refactoring around deprecation changes
Browse files Browse the repository at this point in the history
  • Loading branch information
benfortuna committed Jan 6, 2022
1 parent 1e9991e commit 667785f
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 94 deletions.
19 changes: 3 additions & 16 deletions src/main/java/net/fortuna/ical4j/model/Calendar.java
Expand Up @@ -202,14 +202,8 @@ public <C extends CalendarComponent> List<C> getComponents() {
}

/**
* @return Returns the components.
* @deprecated to avoid confusion with how to mutate a ComponentList from v4.x onwards this method is temporarily
* deprecated.
* @see ComponentContainer#add(Component)
* @see ComponentContainer#remove(Component)
* @see ComponentContainer#replace(Component)
* @return Returns the underlying component list.
*/
@Deprecated
@Override
public final ComponentList<CalendarComponent> getComponentList() {
return components;
Expand All @@ -225,22 +219,15 @@ public <T extends Property> List<T> getProperties() {
}

/**
* @return Returns the properties.
* @deprecated to avoid confusion with how to mutate a PropertyList from v4.x onwards this method is temporarily
* deprecated.
* @see PropertyContainer#add(Property)
* @see PropertyContainer#remove(Property)
* @see PropertyContainer#removeAll(String...)
* @see PropertyContainer#replace(Property)
* @return Returns the underlying property list.
*/
@Deprecated
@Override
public final PropertyList getPropertyList() {
return properties;
}

@Override
public void setProperties(PropertyList properties) {
public void setPropertyList(PropertyList properties) {
this.properties = properties;
}

Expand Down
11 changes: 2 additions & 9 deletions src/main/java/net/fortuna/ical4j/model/Component.java
Expand Up @@ -190,22 +190,15 @@ public <T extends Property> List<T> getProperties() {
}

/**
* @return Returns the properties.
* @deprecated to avoid confusion with how to mutate a PropertyList from v4.x onwards this method is temporarily
* deprecated.
* @see PropertyContainer#add(Property)
* @see PropertyContainer#remove(Property)
* @see PropertyContainer#removeAll(String...)
* @see PropertyContainer#replace(Property)
* @return Returns the underlying property list.
*/
@Deprecated
@Override
public final PropertyList getPropertyList() {
return properties;
}

@Override
public void setProperties(PropertyList properties) {
public void setPropertyList(PropertyList properties) {
this.properties = properties;
}

Expand Down
23 changes: 8 additions & 15 deletions src/main/java/net/fortuna/ical4j/model/Property.java
Expand Up @@ -467,15 +467,8 @@ public final String getName() {
}

/**
* @return Returns the parameters.
* @deprecated to avoid confusion with how to mutate a {@link ParameterList} from v4.x onwards this method is temporarily
* deprecated.
* @see Property#add(Parameter)
* @see Property#remove(Parameter)
* @see Property#removeAll(String...)
* @see Property#replace(Parameter)
*/
@Deprecated
* @return Returns the underlying parameter list.
*/
public final ParameterList getParameterList() {
return parameters;
}
Expand Down Expand Up @@ -535,7 +528,7 @@ public <T extends Property> T replace(Parameter parameter) {
* @return a parameter list containing only parameters with the specified name
*/
public final List<Parameter> getParameters(final String... name) {
return getParameterList().get(name);
return parameters.get(name);
}

/**
Expand All @@ -545,7 +538,7 @@ public final List<Parameter> getParameters(final String... name) {
* @return the first parameter from the parameter list with the specified name
*/
public final <P extends Parameter> Optional<P> getParameter(final String name) {
return getParameterList().getFirst(name);
return parameters.getFirst(name);
}

/**
Expand All @@ -555,7 +548,7 @@ public final <P extends Parameter> Optional<P> getParameter(final String name) {
* @return
*/
public final <P extends Parameter> P getRequiredParameter(final String name) {
return getParameterList().getRequired(name);
return parameters.getRequired(name);
}

/**
Expand All @@ -582,8 +575,8 @@ public final boolean equals(final Object arg0) {
if (arg0 instanceof Property) {
final Property p = (Property) arg0;
return getName().equals(p.getName())
&& new EqualsBuilder().append(getValue(), p.getValue()).append(getParameterList(),
p.getParameterList()).isEquals();
&& new EqualsBuilder().append(getValue(), p.getValue()).append(parameters,
p.parameters).isEquals();
}
return super.equals(arg0);
}
Expand All @@ -595,7 +588,7 @@ && new EqualsBuilder().append(getValue(), p.getValue()).append(getParameterList(
public int hashCode() {
// as property name is case-insensitive generate hash for uppercase..
return new HashCodeBuilder().append(getName().toUpperCase()).append(
getValue()).append(getParameterList()).toHashCode();
getValue()).append(parameters).toHashCode();
}

/**
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/net/fortuna/ical4j/model/PropertyContainer.java
Expand Up @@ -7,7 +7,7 @@ public interface PropertyContainer {

PropertyList getPropertyList();

void setProperties(PropertyList properties);
void setPropertyList(PropertyList properties);

default <T extends Property> List<T> getProperties(final String... name) {
return getPropertyList().get(name);
Expand All @@ -34,7 +34,7 @@ default <T extends Property> T getRequiredProperty(String name) throws Constrain
* @return a reference to the container to support method chaining
*/
default PropertyContainer add(Property property) {
setProperties((PropertyList) getPropertyList().add(property));
setPropertyList((PropertyList) getPropertyList().add(property));
return this;
}

Expand All @@ -44,7 +44,7 @@ default PropertyContainer add(Property property) {
* @return a reference to the container to support method chaining
*/
default PropertyContainer remove(Property property) {
setProperties((PropertyList) getPropertyList().remove(property));
setPropertyList((PropertyList) getPropertyList().remove(property));
return this;
}

Expand All @@ -54,7 +54,7 @@ default PropertyContainer remove(Property property) {
* @return a reference to the container to support method chaining
*/
default PropertyContainer removeAll(String... name) {
setProperties((PropertyList) getPropertyList().removeAll(name));
setPropertyList((PropertyList) getPropertyList().removeAll(name));
return this;
}

Expand All @@ -64,7 +64,7 @@ default PropertyContainer removeAll(String... name) {
* @return a reference to the container to support method chaining
*/
default PropertyContainer replace(Property property) {
setProperties((PropertyList) getPropertyList().replace(property));
setPropertyList((PropertyList) getPropertyList().replace(property));
return this;
}
}
Expand Up @@ -166,14 +166,8 @@ public final void validate(final boolean recurse) throws ValidationException {

/**
*
* @return
* @deprecated to avoid confusion with how to mutate a ComponentList from v4.x onwards this method is temporarily
* deprecated.
* @see ComponentContainer#add(Component)
* @see ComponentContainer#remove(Component)
* @see ComponentContainer#replace(Component)
* @return Returns the underlying component list.
*/
@Deprecated
@Override
public ComponentList<Component> getComponentList() {
return (ComponentList<Component>) components;
Expand Down
Expand Up @@ -152,14 +152,8 @@ public final List<Available> getAvailable() {

/**
*
* @return
* @deprecated to avoid confusion with how to mutate a ComponentList from v4.x onwards this method is temporarily
* deprecated.
* @see ComponentContainer#add(Component)
* @see ComponentContainer#remove(Component)
* @see ComponentContainer#replace(Component)
* @return Returns the underlying component list.
*/
@Deprecated
@Override
public ComponentList<Available> getComponentList() {
return (ComponentList<Available>) components;
Expand Down
8 changes: 1 addition & 7 deletions src/main/java/net/fortuna/ical4j/model/component/VEvent.java
Expand Up @@ -328,14 +328,8 @@ public final List<VAlarm> getAlarms() {

/**
*
* @return
* @deprecated to avoid confusion with how to mutate a ComponentList from v4.x onwards this method is temporarily
* deprecated.
* @see ComponentContainer#add(Component)
* @see ComponentContainer#remove(Component)
* @see ComponentContainer#replace(Component)
* @return Returns the underlying component list.
*/
@Deprecated
@Override
public ComponentList<Component> getComponentList() {
return (ComponentList<Component>) components;
Expand Down
Expand Up @@ -516,14 +516,8 @@ public void validate(Method method) throws ValidationException {

/**
*
* @return
* @deprecated to avoid confusion with how to mutate a ComponentList from v4.x onwards this method is temporarily
* deprecated.
* @see ComponentContainer#add(Component)
* @see ComponentContainer#remove(Component)
* @see ComponentContainer#replace(Component)
* @return Returns the underlying component list.
*/
@Deprecated
@Override
public ComponentList<Component> getComponentList() {
return (ComponentList<Component>) components;
Expand Down
Expand Up @@ -193,14 +193,8 @@ public void validate(Method method) throws ValidationException {

/**
*
* @return
* @deprecated to avoid confusion with how to mutate a ComponentList from v4.x onwards this method is temporarily
* deprecated.
* @see ComponentContainer#add(Component)
* @see ComponentContainer#remove(Component)
* @see ComponentContainer#replace(Component)
* @return Returns the underlying component list.
*/
@Deprecated
@Override
public ComponentList<Component> getComponentList() {
return (ComponentList<Component>) components;
Expand Down
Expand Up @@ -195,14 +195,8 @@ public final List<Observance> getObservances() {

/**
*
* @return
* @deprecated to avoid confusion with how to mutate a ComponentList from v4.x onwards this method is temporarily
* deprecated.
* @see ComponentContainer#add(Component)
* @see ComponentContainer#remove(Component)
* @see ComponentContainer#replace(Component)
* @return Returns the underlying component list.
*/
@Deprecated
@Override
public ComponentList<Observance> getComponentList() {
return (ComponentList<Observance>) components;
Expand Down
8 changes: 1 addition & 7 deletions src/main/java/net/fortuna/ical4j/model/component/VToDo.java
Expand Up @@ -249,14 +249,8 @@ public final ComponentList<VAlarm> getAlarms() {

/**
*
* @return
* @deprecated to avoid confusion with how to mutate a ComponentList from v4.x onwards this method is temporarily
* deprecated.
* @see ComponentContainer#add(Component)
* @see ComponentContainer#remove(Component)
* @see ComponentContainer#replace(Component)
* @return Returns the underlying component list.
*/
@Deprecated
@Override
public ComponentList<Component> getComponentList() {
return (ComponentList<Component>) components;
Expand Down

0 comments on commit 667785f

Please sign in to comment.