Skip to content

Commit

Permalink
Deprecate Factory in favor of java.util.function.Supplier
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Apr 28, 2024
1 parent c176372 commit e5c3d7e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<action issue="COLLECTIONS-852" type="update" dev="ggregory" due-to="Claude Warren, Alex Herbert">Add layerd bloom filter clean method #476.</action>
<!-- FIX -->
<action type="update" dev="ggregory" due-to="Gary Gregory">Deprecate Closure in favor of java.util.function.Consumer.</action>
<action type="update" dev="ggregory" due-to="Gary Gregory">Deprecate Factory in favor of java.util.function.Supplier.</action>
<!-- UPDATE -->
<action type="update" dev="ggregory" due-to="Dependabot">Bump org.apache.commons:commons-parent from 67 to 69 #473.</action>
<action type="update" dev="ggregory" due-to="Dependabot">Bump tests commons-io:commons-io from 2.16.0 to 2.16.1 #475 .</action>
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/org/apache/commons/collections4/Factory.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.commons.collections4;

import java.util.function.Supplier;

/**
* Defines a functor interface implemented by classes that create objects.
* <p>
Expand All @@ -31,9 +33,10 @@
* @param <T> the type that the factory creates
*
* @since 2.1
* @deprecated Use {@link Supplier}.
*/
@FunctionalInterface
public interface Factory<T> {
@Deprecated
public interface Factory<T> extends Supplier<T> {

/**
* Create a new object.
Expand All @@ -43,4 +46,9 @@ public interface Factory<T> {
*/
T create();

@Override
default T get() {
return create();
}

}

0 comments on commit e5c3d7e

Please sign in to comment.