Migrates to Apache Commons Collections 4.x
org.openrewrite.apache.commons.collections.UpgradeApacheCommonsCollections_3_4
Migrate applications to the latest Apache Commons Collections 4.x release. This recipe modifies application's build files, make changes to deprecated/preferred APIs, and migrates configuration settings that have changes between versions.
Tags
Recipe source
GitHub: apache-commons-collections-3-4.yml, Issue Tracker, Code Genome Project
This recipe is composed of more than one recipe. If you want to customize the set of recipes this is composed of, you can find and copy the GitHub source for the recipe from the link above.
This recipe is available under the Moderne Source Available License. Moderne customers can download precompiled artifacts from The Code Genome Project. For non-commercial use you can build the artifact from source locally.
Definition
- Recipe List
- Yaml Recipe List
- Change Gradle or Maven dependency
- oldGroupId:
commons-collections - oldArtifactId:
commons-collections - newGroupId:
org.apache.commons - newArtifactId:
commons-collections4 - newVersion:
4.x
- oldGroupId:
- Add Gradle or Maven dependency
- groupId:
org.apache.commons - artifactId:
commons-collections4 - version:
4.x - onlyIfUsing:
org.apache.commons.collections..* - acceptTransitive:
true
- groupId:
- Change type
- oldFullyQualifiedTypeName:
org.apache.commons.collections.map.IdentityMap - newFullyQualifiedTypeName:
java.util.IdentityHashMap
- oldFullyQualifiedTypeName:
- Delete method argument
- methodPattern:
org.apache.commons.collections.FastArrayList <constructor>(int) - argumentIndex:
0
- methodPattern:
- Remove method invocations
- methodPattern:
org.apache.commons.collections.FastArrayList setFast(boolean)
- methodPattern:
- Change type
- oldFullyQualifiedTypeName:
org.apache.commons.collections.FastArrayList - newFullyQualifiedTypeName:
java.util.concurrent.CopyOnWriteArrayList
- oldFullyQualifiedTypeName:
- Change static field access to static method access
- oldClassName:
org.apache.commons.collections.MapUtils - oldFieldName:
EMPTY_MAP - newClassName:
java.util.Collections - newMethodName:
emptyMap
- oldClassName:
- Change static field access to static method access
- oldClassName:
org.apache.commons.collections.ListUtils - oldFieldName:
EMPTY_LIST - newClassName:
java.util.Collections - newMethodName:
emptyList
- oldClassName:
- Change static field access to static method access
- oldClassName:
org.apache.commons.collections.SetUtils - oldFieldName:
EMPTY_SET - newClassName:
java.util.Collections - newMethodName:
emptySet
- oldClassName:
- Change method name
- methodPattern:
org.apache.commons.collections.OrderedMap orderedMapIterator() - newMethodName:
mapIterator - matchOverrides:
true
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.OrderedBidiMap inverseOrderedBidiMap() - newMethodName:
inverseBidiMap - matchOverrides:
true
- methodPattern:
- Replace constant with another constant
- existingFullyQualifiedConstantName:
org.apache.commons.collections.map.AbstractReferenceMap.HARD - fullyQualifiedConstantName:
org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength.HARD
- existingFullyQualifiedConstantName:
- Replace constant with another constant
- existingFullyQualifiedConstantName:
org.apache.commons.collections.map.AbstractReferenceMap.SOFT - fullyQualifiedConstantName:
org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength.SOFT
- existingFullyQualifiedConstantName:
- Replace constant with another constant
- existingFullyQualifiedConstantName:
org.apache.commons.collections.map.AbstractReferenceMap.WEAK - fullyQualifiedConstantName:
org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength.WEAK
- existingFullyQualifiedConstantName:
- Replace constant with another constant
- existingFullyQualifiedConstantName:
org.apache.commons.collections.ReferenceMap.HARD - fullyQualifiedConstantName:
org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength.HARD
- existingFullyQualifiedConstantName:
- Replace constant with another constant
- existingFullyQualifiedConstantName:
org.apache.commons.collections.ReferenceMap.SOFT - fullyQualifiedConstantName:
org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength.SOFT
- existingFullyQualifiedConstantName:
- Replace constant with another constant
- existingFullyQualifiedConstantName:
org.apache.commons.collections.ReferenceMap.WEAK - fullyQualifiedConstantName:
org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength.WEAK
- existingFullyQualifiedConstantName:
- Change method name
- methodPattern:
org.apache.commons.collections.set.SynchronizedSet decorate(java.util.Set) - newMethodName:
synchronizedSet
- methodPattern:
- Change method target to static
- methodPattern:
org.apache.commons.collections.set.SynchronizedSet synchronizedSet(java.util.Set) - fullyQualifiedTargetTypeName:
java.util.Collections
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.set.SynchronizedSortedSet decorate(java.util.SortedSet) - newMethodName:
synchronizedSortedSet
- methodPattern:
- Change method target to static
- methodPattern:
org.apache.commons.collections.set.SynchronizedSortedSet synchronizedSortedSet(java.util.SortedSet) - fullyQualifiedTargetTypeName:
java.util.Collections
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.list.SynchronizedList decorate(java.util.List) - newMethodName:
synchronizedList
- methodPattern:
- Change method target to static
- methodPattern:
org.apache.commons.collections.list.SynchronizedList synchronizedList(java.util.List) - fullyQualifiedTargetTypeName:
java.util.Collections
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.bag.PredicatedBag decorate(..) - newMethodName:
predicatedBag
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.bag.PredicatedSortedBag decorate(..) - newMethodName:
predicatedSortedBag
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.bag.SynchronizedBag decorate(..) - newMethodName:
synchronizedBag
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.bag.SynchronizedSortedBag decorate(..) - newMethodName:
synchronizedSortedBag
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.bag.TransformedBag decorate(..) - newMethodName:
transformingBag
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.bag.TransformedSortedBag decorate(..) - newMethodName:
transformingSortedBag
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.bag.UnmodifiableBag decorate(..) - newMethodName:
unmodifiableBag
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.bag.UnmodifiableSortedBag decorate(..) - newMethodName:
unmodifiableSortedBag
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.bidimap.UnmodifiableBidiMap decorate(..) - newMethodName:
unmodifiableBidiMap
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.bidimap.UnmodifiableOrderedBidiMap decorate(..) - newMethodName:
unmodifiableOrderedBidiMap
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.bidimap.UnmodifiableSortedBidiMap decorate(..) - newMethodName:
unmodifiableSortedBidiMap
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.collection.PredicatedCollection decorate(..) - newMethodName:
predicatedCollection
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.collection.SynchronizedCollection decorate(..) - newMethodName:
synchronizedCollection
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.collection.TransformedCollection decorate(..) - newMethodName:
transformingCollection
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.collection.UnmodifiableBoundedCollection decorate(..) - newMethodName:
unmodifiableBoundedCollection
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.collection.UnmodifiableCollection decorate(..) - newMethodName:
unmodifiableCollection
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.comparators.ComparableComparator getInstance(..) - newMethodName:
comparableComparator
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.AllPredicate getInstance(..) - newMethodName:
allPredicate
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.AndPredicate getInstance(..) - newMethodName:
andPredicate
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.AnyPredicate getInstance(..) - newMethodName:
anyPredicate
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.ChainedClosure getInstance(..) - newMethodName:
chainedClosure
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.ChainedTransformer getInstance(..) - newMethodName:
chainedTransformer
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.CloneTransformer getInstance(..) - newMethodName:
cloneTransformer
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.ClosureTransformer getInstance(..) - newMethodName:
closureTransformer
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.ConstantFactory getInstance(..) - newMethodName:
constantFactory
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.ConstantTransformer getInstance(..) - newMethodName:
constantTransformer
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.EqualPredicate getInstance(..) - newMethodName:
equalPredicate
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.ExceptionClosure getInstance(..) - newMethodName:
exceptionClosure
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.ExceptionFactory getInstance(..) - newMethodName:
exceptionFactory
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.ExceptionPredicate getInstance(..) - newMethodName:
exceptionPredicate
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.ExceptionTransformer getInstance(..) - newMethodName:
exceptionTransformer
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.FactoryTransformer getInstance(..) - newMethodName:
factoryTransformer
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.FalsePredicate getInstance(..) - newMethodName:
falsePredicate
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.ForClosure getInstance(..) - newMethodName:
forClosure
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.IdentityPredicate getInstance(..) - newMethodName:
identityPredicate
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.IfClosure getInstance(..) - newMethodName:
ifClosure
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.InstanceofPredicate getInstance(..) - newMethodName:
instanceOfPredicate
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.InstantiateFactory getInstance(..) - newMethodName:
instantiateFactory
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.InstantiateTransformer getInstance(..) - newMethodName:
instantiateTransformer
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.InvokerTransformer getInstance(..) - newMethodName:
invokerTransformer
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.MapTransformer getInstance(..) - newMethodName:
mapTransformer
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.NOPClosure getInstance(..) - newMethodName:
nopClosure
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.NOPTransformer getInstance(..) - newMethodName:
nopTransformer
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.NonePredicate getInstance(..) - newMethodName:
nonePredicate
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.NotNullPredicate getInstance(..) - newMethodName:
notNullPredicate
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.NotPredicate getInstance(..) - newMethodName:
notPredicate
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.NullIsExceptionPredicate getInstance(..) - newMethodName:
nullIsExceptionPredicate
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.NullIsFalsePredicate getInstance(..) - newMethodName:
nullIsFalsePredicate
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.NullIsTruePredicate getInstance(..) - newMethodName:
nullIsTruePredicate
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.NullPredicate getInstance(..) - newMethodName:
nullPredicate
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.OnePredicate getInstance(..) - newMethodName:
onePredicate
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.OrPredicate getInstance(..) - newMethodName:
orPredicate
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.PredicateTransformer getInstance(..) - newMethodName:
predicateTransformer
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.PrototypeFactory getInstance(..) - newMethodName:
prototypeFactory
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.StringValueTransformer getInstance(..) - newMethodName:
stringValueTransformer
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.SwitchClosure getInstance(..) - newMethodName:
switchClosure
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.SwitchTransformer getInstance(..) - newMethodName:
switchTransformer
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.TransformedPredicate getInstance(..) - newMethodName:
transformedPredicate
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.TransformerClosure getInstance(..) - newMethodName:
transformerClosure
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.TransformerPredicate getInstance(..) - newMethodName:
transformerPredicate
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.TruePredicate getInstance(..) - newMethodName:
truePredicate
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.UniquePredicate getInstance(..) - newMethodName:
uniquePredicate
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.functors.WhileClosure getInstance(..) - newMethodName:
whileClosure
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.iterators.UnmodifiableIterator decorate(..) - newMethodName:
unmodifiableIterator
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.iterators.UnmodifiableListIterator decorate(..) - newMethodName:
unmodifiableListIterator
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.iterators.UnmodifiableMapIterator decorate(..) - newMethodName:
unmodifiableMapIterator
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.iterators.UnmodifiableOrderedMapIterator decorate(..) - newMethodName:
unmodifiableOrderedMapIterator
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.list.FixedSizeList decorate(..) - newMethodName:
fixedSizeList
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.list.GrowthList decorate(..) - newMethodName:
growthList
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.list.LazyList decorate(..) - newMethodName:
lazyList
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.list.PredicatedList decorate(..) - newMethodName:
predicatedList
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.list.SetUniqueList decorate(..) - newMethodName:
setUniqueList
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.list.TransformedList decorate(..) - newMethodName:
transformingList
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.list.UnmodifiableList decorate(..) - newMethodName:
unmodifiableList
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.map.DefaultedMap decorate(..) - newMethodName:
defaultedMap
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.map.FixedSizeMap decorate(..) - newMethodName:
fixedSizeMap
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.map.FixedSizeSortedMap decorate(..) - newMethodName:
fixedSizeSortedMap
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.map.LazyMap decorate(..) - newMethodName:
lazyMap
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.map.LazySortedMap decorate(..) - newMethodName:
lazySortedMap
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.map.ListOrderedMap decorate(..) - newMethodName:
listOrderedMap
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.map.MultiKeyMap decorate(..) - newMethodName:
multiKeyMap
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.map.MultiValueMap decorate(..) - newMethodName:
multiValueMap
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.map.PredicatedMap decorate(..) - newMethodName:
predicatedMap
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.map.PredicatedSortedMap decorate(..) - newMethodName:
predicatedSortedMap
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.map.TransformedMap decorate(..) - newMethodName:
transformingMap
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.map.TransformedMap decorateTransform(..) - newMethodName:
transformedMap
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.map.TransformedSortedMap decorate(..) - newMethodName:
transformingSortedMap
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.map.TransformedSortedMap decorateTransform(..) - newMethodName:
transformedSortedMap
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.map.UnmodifiableEntrySet decorate(..) - newMethodName:
unmodifiableEntrySet
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.map.UnmodifiableMap decorate(..) - newMethodName:
unmodifiableMap
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.map.UnmodifiableOrderedMap decorate(..) - newMethodName:
unmodifiableOrderedMap
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.map.UnmodifiableSortedMap decorate(..) - newMethodName:
unmodifiableSortedMap
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.set.ListOrderedSet decorate(..) - newMethodName:
listOrderedSet
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.set.MapBackedSet decorate(..) - newMethodName:
mapBackedSet
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.set.PredicatedSet decorate(..) - newMethodName:
predicatedSet
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.set.PredicatedSortedSet decorate(..) - newMethodName:
predicatedSortedSet
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.set.TransformedSet decorate(..) - newMethodName:
transformingSet
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.set.TransformedSortedSet decorate(..) - newMethodName:
transformingSortedSet
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.set.UnmodifiableSet decorate(..) - newMethodName:
unmodifiableSet
- methodPattern:
- Change method name
- methodPattern:
org.apache.commons.collections.set.UnmodifiableSortedSet decorate(..) - newMethodName:
unmodifiableSortedSet
- methodPattern:
- Change type
- oldFullyQualifiedTypeName:
org.apache.commons.collections.DefaultMapEntry - newFullyQualifiedTypeName:
org.apache.commons.collections4.keyvalue.DefaultMapEntry
- oldFullyQualifiedTypeName:
- Change type
- oldFullyQualifiedTypeName:
org.apache.commons.collections.HashBag - newFullyQualifiedTypeName:
org.apache.commons.collections4.bag.HashBag
- oldFullyQualifiedTypeName:
- Change type
- oldFullyQualifiedTypeName:
org.apache.commons.collections.ReferenceMap - newFullyQualifiedTypeName:
org.apache.commons.collections4.map.ReferenceMap
- oldFullyQualifiedTypeName:
- Change type
- oldFullyQualifiedTypeName:
org.apache.commons.collections.StaticBucketMap - newFullyQualifiedTypeName:
org.apache.commons.collections4.map.StaticBucketMap
- oldFullyQualifiedTypeName:
- Change type
- oldFullyQualifiedTypeName:
org.apache.commons.collections.TreeBag - newFullyQualifiedTypeName:
org.apache.commons.collections4.bag.TreeBag
- oldFullyQualifiedTypeName:
- Rename package name
- oldPackageName:
org.apache.commons.collections - newPackageName:
org.apache.commons.collections4 - recursive:
true
- oldPackageName:
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.apache.commons.collections.UpgradeApacheCommonsCollections_3_4
displayName: Migrates to Apache Commons Collections 4.x
description: |
Migrate applications to the latest Apache Commons Collections 4.x release. This recipe modifies application's build files, make changes to deprecated/preferred APIs, and migrates configuration settings that have changes between versions.
tags:
- collections
- commons
- apache
recipeList:
- org.openrewrite.java.dependencies.ChangeDependency:
oldGroupId: commons-collections
oldArtifactId: commons-collections
newGroupId: org.apache.commons
newArtifactId: commons-collections4
newVersion: 4.x
- org.openrewrite.java.dependencies.AddDependency:
groupId: org.apache.commons
artifactId: commons-collections4
version: 4.x
onlyIfUsing: org.apache.commons.collections..*
acceptTransitive: true
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: org.apache.commons.collections.map.IdentityMap
newFullyQualifiedTypeName: java.util.IdentityHashMap
- org.openrewrite.java.DeleteMethodArgument:
methodPattern: org.apache.commons.collections.FastArrayList <constructor>(int)
argumentIndex: 0
- org.openrewrite.java.RemoveMethodInvocations:
methodPattern: org.apache.commons.collections.FastArrayList setFast(boolean)
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: org.apache.commons.collections.FastArrayList
newFullyQualifiedTypeName: java.util.concurrent.CopyOnWriteArrayList
- org.openrewrite.java.ChangeStaticFieldToMethod:
oldClassName: org.apache.commons.collections.MapUtils
oldFieldName: EMPTY_MAP
newClassName: java.util.Collections
newMethodName: emptyMap
- org.openrewrite.java.ChangeStaticFieldToMethod:
oldClassName: org.apache.commons.collections.ListUtils
oldFieldName: EMPTY_LIST
newClassName: java.util.Collections
newMethodName: emptyList
- org.openrewrite.java.ChangeStaticFieldToMethod:
oldClassName: org.apache.commons.collections.SetUtils
oldFieldName: EMPTY_SET
newClassName: java.util.Collections
newMethodName: emptySet
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.OrderedMap orderedMapIterator()
newMethodName: mapIterator
matchOverrides: true
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.OrderedBidiMap inverseOrderedBidiMap()
newMethodName: inverseBidiMap
matchOverrides: true
- org.openrewrite.java.ReplaceConstantWithAnotherConstant:
existingFullyQualifiedConstantName: org.apache.commons.collections.map.AbstractReferenceMap.HARD
fullyQualifiedConstantName: org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength.HARD
- org.openrewrite.java.ReplaceConstantWithAnotherConstant:
existingFullyQualifiedConstantName: org.apache.commons.collections.map.AbstractReferenceMap.SOFT
fullyQualifiedConstantName: org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength.SOFT
- org.openrewrite.java.ReplaceConstantWithAnotherConstant:
existingFullyQualifiedConstantName: org.apache.commons.collections.map.AbstractReferenceMap.WEAK
fullyQualifiedConstantName: org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength.WEAK
- org.openrewrite.java.ReplaceConstantWithAnotherConstant:
existingFullyQualifiedConstantName: org.apache.commons.collections.ReferenceMap.HARD
fullyQualifiedConstantName: org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength.HARD
- org.openrewrite.java.ReplaceConstantWithAnotherConstant:
existingFullyQualifiedConstantName: org.apache.commons.collections.ReferenceMap.SOFT
fullyQualifiedConstantName: org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength.SOFT
- org.openrewrite.java.ReplaceConstantWithAnotherConstant:
existingFullyQualifiedConstantName: org.apache.commons.collections.ReferenceMap.WEAK
fullyQualifiedConstantName: org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength.WEAK
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.set.SynchronizedSet decorate(java.util.Set)
newMethodName: synchronizedSet
- org.openrewrite.java.ChangeMethodTargetToStatic:
methodPattern: org.apache.commons.collections.set.SynchronizedSet synchronizedSet(java.util.Set)
fullyQualifiedTargetTypeName: java.util.Collections
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.set.SynchronizedSortedSet decorate(java.util.SortedSet)
newMethodName: synchronizedSortedSet
- org.openrewrite.java.ChangeMethodTargetToStatic:
methodPattern: org.apache.commons.collections.set.SynchronizedSortedSet synchronizedSortedSet(java.util.SortedSet)
fullyQualifiedTargetTypeName: java.util.Collections
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.list.SynchronizedList decorate(java.util.List)
newMethodName: synchronizedList
- org.openrewrite.java.ChangeMethodTargetToStatic:
methodPattern: org.apache.commons.collections.list.SynchronizedList synchronizedList(java.util.List)
fullyQualifiedTargetTypeName: java.util.Collections
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.bag.PredicatedBag decorate(..)
newMethodName: predicatedBag
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.bag.PredicatedSortedBag decorate(..)
newMethodName: predicatedSortedBag
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.bag.SynchronizedBag decorate(..)
newMethodName: synchronizedBag
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.bag.SynchronizedSortedBag decorate(..)
newMethodName: synchronizedSortedBag
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.bag.TransformedBag decorate(..)
newMethodName: transformingBag
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.bag.TransformedSortedBag decorate(..)
newMethodName: transformingSortedBag
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.bag.UnmodifiableBag decorate(..)
newMethodName: unmodifiableBag
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.bag.UnmodifiableSortedBag decorate(..)
newMethodName: unmodifiableSortedBag
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.bidimap.UnmodifiableBidiMap decorate(..)
newMethodName: unmodifiableBidiMap
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.bidimap.UnmodifiableOrderedBidiMap decorate(..)
newMethodName: unmodifiableOrderedBidiMap
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.bidimap.UnmodifiableSortedBidiMap decorate(..)
newMethodName: unmodifiableSortedBidiMap
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.collection.PredicatedCollection decorate(..)
newMethodName: predicatedCollection
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.collection.SynchronizedCollection decorate(..)
newMethodName: synchronizedCollection
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.collection.TransformedCollection decorate(..)
newMethodName: transformingCollection
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.collection.UnmodifiableBoundedCollection decorate(..)
newMethodName: unmodifiableBoundedCollection
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.collection.UnmodifiableCollection decorate(..)
newMethodName: unmodifiableCollection
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.comparators.ComparableComparator getInstance(..)
newMethodName: comparableComparator
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.AllPredicate getInstance(..)
newMethodName: allPredicate
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.AndPredicate getInstance(..)
newMethodName: andPredicate
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.AnyPredicate getInstance(..)
newMethodName: anyPredicate
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.ChainedClosure getInstance(..)
newMethodName: chainedClosure
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.ChainedTransformer getInstance(..)
newMethodName: chainedTransformer
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.CloneTransformer getInstance(..)
newMethodName: cloneTransformer
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.ClosureTransformer getInstance(..)
newMethodName: closureTransformer
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.ConstantFactory getInstance(..)
newMethodName: constantFactory
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.ConstantTransformer getInstance(..)
newMethodName: constantTransformer
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.EqualPredicate getInstance(..)
newMethodName: equalPredicate
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.ExceptionClosure getInstance(..)
newMethodName: exceptionClosure
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.ExceptionFactory getInstance(..)
newMethodName: exceptionFactory
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.ExceptionPredicate getInstance(..)
newMethodName: exceptionPredicate
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.ExceptionTransformer getInstance(..)
newMethodName: exceptionTransformer
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.FactoryTransformer getInstance(..)
newMethodName: factoryTransformer
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.FalsePredicate getInstance(..)
newMethodName: falsePredicate
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.ForClosure getInstance(..)
newMethodName: forClosure
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.IdentityPredicate getInstance(..)
newMethodName: identityPredicate
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.IfClosure getInstance(..)
newMethodName: ifClosure
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.InstanceofPredicate getInstance(..)
newMethodName: instanceOfPredicate
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.InstantiateFactory getInstance(..)
newMethodName: instantiateFactory
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.InstantiateTransformer getInstance(..)
newMethodName: instantiateTransformer
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.InvokerTransformer getInstance(..)
newMethodName: invokerTransformer
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.MapTransformer getInstance(..)
newMethodName: mapTransformer
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.NOPClosure getInstance(..)
newMethodName: nopClosure
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.NOPTransformer getInstance(..)
newMethodName: nopTransformer
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.NonePredicate getInstance(..)
newMethodName: nonePredicate
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.NotNullPredicate getInstance(..)
newMethodName: notNullPredicate
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.NotPredicate getInstance(..)
newMethodName: notPredicate
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.NullIsExceptionPredicate getInstance(..)
newMethodName: nullIsExceptionPredicate
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.NullIsFalsePredicate getInstance(..)
newMethodName: nullIsFalsePredicate
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.NullIsTruePredicate getInstance(..)
newMethodName: nullIsTruePredicate
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.NullPredicate getInstance(..)
newMethodName: nullPredicate
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.OnePredicate getInstance(..)
newMethodName: onePredicate
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.OrPredicate getInstance(..)
newMethodName: orPredicate
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.PredicateTransformer getInstance(..)
newMethodName: predicateTransformer
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.PrototypeFactory getInstance(..)
newMethodName: prototypeFactory
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.StringValueTransformer getInstance(..)
newMethodName: stringValueTransformer
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.SwitchClosure getInstance(..)
newMethodName: switchClosure
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.SwitchTransformer getInstance(..)
newMethodName: switchTransformer
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.TransformedPredicate getInstance(..)
newMethodName: transformedPredicate
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.TransformerClosure getInstance(..)
newMethodName: transformerClosure
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.TransformerPredicate getInstance(..)
newMethodName: transformerPredicate
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.TruePredicate getInstance(..)
newMethodName: truePredicate
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.UniquePredicate getInstance(..)
newMethodName: uniquePredicate
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.functors.WhileClosure getInstance(..)
newMethodName: whileClosure
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.iterators.UnmodifiableIterator decorate(..)
newMethodName: unmodifiableIterator
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.iterators.UnmodifiableListIterator decorate(..)
newMethodName: unmodifiableListIterator
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.iterators.UnmodifiableMapIterator decorate(..)
newMethodName: unmodifiableMapIterator
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.iterators.UnmodifiableOrderedMapIterator decorate(..)
newMethodName: unmodifiableOrderedMapIterator
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.list.FixedSizeList decorate(..)
newMethodName: fixedSizeList
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.list.GrowthList decorate(..)
newMethodName: growthList
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.list.LazyList decorate(..)
newMethodName: lazyList
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.list.PredicatedList decorate(..)
newMethodName: predicatedList
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.list.SetUniqueList decorate(..)
newMethodName: setUniqueList
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.list.TransformedList decorate(..)
newMethodName: transformingList
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.list.UnmodifiableList decorate(..)
newMethodName: unmodifiableList
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.map.DefaultedMap decorate(..)
newMethodName: defaultedMap
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.map.FixedSizeMap decorate(..)
newMethodName: fixedSizeMap
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.map.FixedSizeSortedMap decorate(..)
newMethodName: fixedSizeSortedMap
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.map.LazyMap decorate(..)
newMethodName: lazyMap
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.map.LazySortedMap decorate(..)
newMethodName: lazySortedMap
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.map.ListOrderedMap decorate(..)
newMethodName: listOrderedMap
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.map.MultiKeyMap decorate(..)
newMethodName: multiKeyMap
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.map.MultiValueMap decorate(..)
newMethodName: multiValueMap
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.map.PredicatedMap decorate(..)
newMethodName: predicatedMap
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.map.PredicatedSortedMap decorate(..)
newMethodName: predicatedSortedMap
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.map.TransformedMap decorate(..)
newMethodName: transformingMap
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.map.TransformedMap decorateTransform(..)
newMethodName: transformedMap
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.map.TransformedSortedMap decorate(..)
newMethodName: transformingSortedMap
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.map.TransformedSortedMap decorateTransform(..)
newMethodName: transformedSortedMap
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.map.UnmodifiableEntrySet decorate(..)
newMethodName: unmodifiableEntrySet
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.map.UnmodifiableMap decorate(..)
newMethodName: unmodifiableMap
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.map.UnmodifiableOrderedMap decorate(..)
newMethodName: unmodifiableOrderedMap
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.map.UnmodifiableSortedMap decorate(..)
newMethodName: unmodifiableSortedMap
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.set.ListOrderedSet decorate(..)
newMethodName: listOrderedSet
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.set.MapBackedSet decorate(..)
newMethodName: mapBackedSet
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.set.PredicatedSet decorate(..)
newMethodName: predicatedSet
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.set.PredicatedSortedSet decorate(..)
newMethodName: predicatedSortedSet
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.set.TransformedSet decorate(..)
newMethodName: transformingSet
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.set.TransformedSortedSet decorate(..)
newMethodName: transformingSortedSet
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.set.UnmodifiableSet decorate(..)
newMethodName: unmodifiableSet
- org.openrewrite.java.ChangeMethodName:
methodPattern: org.apache.commons.collections.set.UnmodifiableSortedSet decorate(..)
newMethodName: unmodifiableSortedSet
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: org.apache.commons.collections.DefaultMapEntry
newFullyQualifiedTypeName: org.apache.commons.collections4.keyvalue.DefaultMapEntry
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: org.apache.commons.collections.HashBag
newFullyQualifiedTypeName: org.apache.commons.collections4.bag.HashBag
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: org.apache.commons.collections.ReferenceMap
newFullyQualifiedTypeName: org.apache.commons.collections4.map.ReferenceMap
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: org.apache.commons.collections.StaticBucketMap
newFullyQualifiedTypeName: org.apache.commons.collections4.map.StaticBucketMap
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: org.apache.commons.collections.TreeBag
newFullyQualifiedTypeName: org.apache.commons.collections4.bag.TreeBag
- org.openrewrite.java.ChangePackage:
oldPackageName: org.apache.commons.collections
newPackageName: org.apache.commons.collections4
recursive: true
Used by
This recipe is used as part of the following composite recipes:
Examples
Example 1
UpgradeApacheCommonsCollections_3_4Test#apacheCommonsCollections
- java
- Diff
Before
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.map.IdentityMap;
import org.apache.commons.collections.ListUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.collections.FastArrayList;
import java.util.List;
import java.util.Map;
class Test {
static void helloApacheCollections() {
Object[] input = new Object[] { "one", "two" };
CollectionUtils.reverseArray(input);
IdentityMap identityMap = new IdentityMap();
Map emptyMap = MapUtils.EMPTY_MAP;
FastArrayList fastList = new FastArrayList(100);
List emptyList = ListUtils.EMPTY_LIST;
}
}
After
import org.apache.commons.collections4.CollectionUtils;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
class Test {
static void helloApacheCollections() {
Object[] input = new Object[] { "one", "two" };
CollectionUtils.reverseArray(input);
IdentityHashMap identityMap = new IdentityHashMap();
Map emptyMap = Collections.emptyMap();
CopyOnWriteArrayList fastList = new CopyOnWriteArrayList(100);
List emptyList = Collections.emptyList();
}
}
@@ -1,5 +1,1 @@
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.collections.map.IdentityMap;
-import org.apache.commons.collections.ListUtils;
-import org.apache.commons.collections.MapUtils;
-import org.apache.commons.collections.FastArrayList;
+import org.apache.commons.collections4.CollectionUtils;
@@ -7,0 +3,2 @@
import org.apache.commons.collections.FastArrayList;
+import java.util.Collections;
+import java.util.IdentityHashMap;
import java.util.List;
@@ -9,0 +7,1 @@
import java.util.List;
import java.util.Map;
+import java.util.concurrent.CopyOnWriteArrayList;
@@ -14,4 +13,4 @@
Object[] input = new Object[] { "one", "two" };
CollectionUtils.reverseArray(input);
- IdentityMap identityMap = new IdentityMap();
- Map emptyMap = MapUtils.EMPTY_MAP;
- FastArrayList fastList = new FastArrayList(100);
- List emptyList = ListUtils.EMPTY_LIST;
+ IdentityHashMap identityMap = new IdentityHashMap();
+ Map emptyMap = Collections.emptyMap();
+ CopyOnWriteArrayList fastList = new CopyOnWriteArrayList(100);
+ List emptyList = Collections.emptyList();
}
Example 2
UpgradeApacheCommonsCollections_3_4Test#apacheCommonsCollections
- java
- Diff
Before
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.map.IdentityMap;
import org.apache.commons.collections.ListUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.collections.FastArrayList;
import java.util.List;
import java.util.Map;
class Test {
static void helloApacheCollections() {
Object[] input = new Object[] { "one", "two" };
CollectionUtils.reverseArray(input);
IdentityMap identityMap = new IdentityMap();
Map emptyMap = MapUtils.EMPTY_MAP;
FastArrayList fastList = new FastArrayList(100);
List emptyList = ListUtils.EMPTY_LIST;
}
}
After
import org.apache.commons.collections4.CollectionUtils;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
class Test {
static void helloApacheCollections() {
Object[] input = new Object[] { "one", "two" };
CollectionUtils.reverseArray(input);
IdentityHashMap identityMap = new IdentityHashMap();
Map emptyMap = Collections.emptyMap();
CopyOnWriteArrayList fastList = new CopyOnWriteArrayList(100);
List emptyList = Collections.emptyList();
}
}
@@ -1,5 +1,1 @@
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.collections.map.IdentityMap;
-import org.apache.commons.collections.ListUtils;
-import org.apache.commons.collections.MapUtils;
-import org.apache.commons.collections.FastArrayList;
+import org.apache.commons.collections4.CollectionUtils;
@@ -7,0 +3,2 @@
import org.apache.commons.collections.FastArrayList;
+import java.util.Collections;
+import java.util.IdentityHashMap;
import java.util.List;
@@ -9,0 +7,1 @@
import java.util.List;
import java.util.Map;
+import java.util.concurrent.CopyOnWriteArrayList;
@@ -14,4 +13,4 @@
Object[] input = new Object[] { "one", "two" };
CollectionUtils.reverseArray(input);
- IdentityMap identityMap = new IdentityMap();
- Map emptyMap = MapUtils.EMPTY_MAP;
- FastArrayList fastList = new FastArrayList(100);
- List emptyList = ListUtils.EMPTY_LIST;
+ IdentityHashMap identityMap = new IdentityHashMap();
+ Map emptyMap = Collections.emptyMap();
+ CopyOnWriteArrayList fastList = new CopyOnWriteArrayList(100);
+ List emptyList = Collections.emptyList();
}
Usage
This recipe has no required configuration options. It can be activated by adding a dependency on `org.openrewrite.recipe:rewrite-apache` in your build file or by running a shell command (in which case no build changes are needed):
OpenRewrite artifacts, including the Maven and Gradle plugins themselves, are distributed through the Code Genome Project repository (https://artifacts.codegenomeproject.org/maven), which requires authentication. Sign in to the Code Genome Project to create a download token; your build authenticates with the email or username you signed in with, plus that token as the password. See the quickstart guide for details.
- Gradle
- Gradle init script
- Gradle init script (Kotlin)
- Maven POM
- Maven Command Line
- Moderne CLI
- Put your Code Genome Project credentials in
~/.gradle/gradle.properties, so that they are not committed alongside your build:~/.gradle/gradle.propertiescodegenomeUsername=you@example.com
codegenomePassword=your-download-token - Add the Code Genome Project repository to your
settings.gradlefile, so that the plugin itself can be resolved:settings.gradlepluginManagement {
repositories {
maven {
url = "https://artifacts.codegenomeproject.org/maven"
credentials {
username = providers.gradleProperty("codegenomeUsername").get()
password = providers.gradleProperty("codegenomePassword").get()
}
}
// Keep the portal for any other plugins your build applies
gradlePluginPortal()
}
} - Add the following to your
build.gradlefile:build.gradleplugins {
id("org.openrewrite.rewrite") version("latest.release")
}
rewrite {
activeRecipe("org.openrewrite.apache.commons.collections.UpgradeApacheCommonsCollections_3_4")
setExportDatatables(true)
}
repositories {
mavenCentral()
maven {
url = "https://artifacts.codegenomeproject.org/maven"
credentials {
username = providers.gradleProperty("codegenomeUsername").get()
password = providers.gradleProperty("codegenomePassword").get()
}
}
}
dependencies {
rewrite("org.openrewrite.recipe:rewrite-apache:2.34.0")
} - Run
gradle rewriteRunto run the recipe.
- Export your Code Genome Project credentials. Init scripts run before any project is configured, so they cannot read
gradle.properties:shellexport ORG_GRADLE_PROJECT_codegenomeUsername='you@example.com'
export ORG_GRADLE_PROJECT_codegenomePassword='your-download-token' - Create a file named
init.gradlein the root of your project.init.gradleinitscript {
repositories {
maven {
url = "https://artifacts.codegenomeproject.org/maven"
credentials {
username = System.getenv("ORG_GRADLE_PROJECT_codegenomeUsername")
password = System.getenv("ORG_GRADLE_PROJECT_codegenomePassword")
}
}
}
dependencies { classpath("org.openrewrite:plugin:7.44.1") }
}
rootProject {
plugins.apply(org.openrewrite.gradle.RewritePlugin)
dependencies {
rewrite("org.openrewrite.recipe:rewrite-apache:2.34.0")
}
rewrite {
activeRecipe("org.openrewrite.apache.commons.collections.UpgradeApacheCommonsCollections_3_4")
setExportDatatables(true)
}
afterEvaluate {
if (repositories.isEmpty()) {
repositories {
mavenCentral()
}
}
repositories {
maven {
url = "https://artifacts.codegenomeproject.org/maven"
credentials {
username = System.getenv("ORG_GRADLE_PROJECT_codegenomeUsername")
password = System.getenv("ORG_GRADLE_PROJECT_codegenomePassword")
}
}
}
}
} - Run the recipe.shell
gradle --init-script init.gradle rewriteRun
- Export your Code Genome Project credentials. Init scripts run before any project is configured, so they cannot read
gradle.properties:shellexport ORG_GRADLE_PROJECT_codegenomeUsername='you@example.com'
export ORG_GRADLE_PROJECT_codegenomePassword='your-download-token' - Create a file named
init.gradle.ktsin the root of your project.init.gradle.ktsinitscript {
repositories {
maven {
url = uri("https://artifacts.codegenomeproject.org/maven")
credentials {
username = System.getenv("ORG_GRADLE_PROJECT_codegenomeUsername")
password = System.getenv("ORG_GRADLE_PROJECT_codegenomePassword")
}
}
}
dependencies { classpath("org.openrewrite:plugin:7.44.1") }
}
rootProject {
plugins.apply(org.openrewrite.gradle.RewritePlugin::class.java)
dependencies {
add("rewrite", "org.openrewrite.recipe:rewrite-apache:2.34.0")
}
extensions.configure<org.openrewrite.gradle.RewriteExtension> {
activeRecipe("org.openrewrite.apache.commons.collections.UpgradeApacheCommonsCollections_3_4")
setExportDatatables(true)
}
afterEvaluate {
if (repositories.isEmpty()) {
repositories {
mavenCentral()
}
}
repositories {
maven {
url = uri("https://artifacts.codegenomeproject.org/maven")
credentials {
username = System.getenv("ORG_GRADLE_PROJECT_codegenomeUsername")
password = System.getenv("ORG_GRADLE_PROJECT_codegenomePassword")
}
}
}
}
} - Run the recipe.shell
gradle --init-script init.gradle.kts rewriteRun
- Add the Code Genome Project credentials to your Maven
settings.xmlfile (typically at~/.m2/settings.xml), replacingUSERNAMEandTOKENwith your own:settings.xml<settings>
<servers>
<server>
<id>codegenome</id>
<username>USERNAME</username>
<password>TOKEN</password>
</server>
</servers>
</settings> - Add the following to your
pom.xmlfile:pom.xml<project>
<repositories>
<repository>
<id>codegenome</id>
<url>https://artifacts.codegenomeproject.org/maven</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>codegenome</id>
<url>https://artifacts.codegenomeproject.org/maven</url>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>6.50.0</version>
<configuration>
<exportDatatables>true</exportDatatables>
<activeRecipes>
<recipe>org.openrewrite.apache.commons.collections.UpgradeApacheCommonsCollections_3_4</recipe>
</activeRecipes>
</configuration>
<dependencies>
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-apache</artifactId>
<version>2.34.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project> - Run
mvn rewrite:runto run the recipe.
You will need to have Maven installed on your machine before you can run the following command. Since this approach leaves your pom.xml untouched, the Code Genome Project repository has to be declared in your Maven settings.xml file (typically at ~/.m2/settings.xml) instead: as a pluginRepository so that rewrite-maven-plugin itself can be resolved, and as a repository so that recipe artifacts passed to rewrite.recipeArtifactCoordinates can be resolved.
<settings>
<servers>
<server>
<id>codegenome</id>
<username>USERNAME</username>
<password>TOKEN</password>
</server>
</servers>
<profiles>
<profile>
<id>codegenome</id>
<repositories>
<repository>
<id>codegenome</id>
<url>https://artifacts.codegenomeproject.org/maven</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>codegenome</id>
<url>https://artifacts.codegenomeproject.org/maven</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>codegenome</activeProfile>
</activeProfiles>
</settings>
With those credentials in place you can run the recipe:
mvn -U org.openrewrite.maven:rewrite-maven-plugin:6.50.0:run --define rewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-apache:RELEASE --define rewrite.activeRecipes=org.openrewrite.apache.commons.collections.UpgradeApacheCommonsCollections_3_4 --define rewrite.exportDatatables=true
You will need to have configured the Moderne CLI on your machine before you can run the following command.
mod run . --recipe UpgradeApacheCommonsCollections_3_4
If the recipe is not available locally, then you can install it using:
mod config recipes jar install org.openrewrite.recipe:rewrite-apache:2.34.0
See how this recipe works across multiple open-source repositories
Run this recipe on OSS repos at scale with the Moderne SaaS.

The community edition of the Moderne platform enables you to easily run recipes across thousands of open-source repositories.
Please contact Moderne for more information about safely running the recipes on your own codebase in a private SaaS.
Data Tables
- SourcesFileResults
- SearchResults
- SourcesFileErrors
- RecipeRunStats
Source files that had results
org.openrewrite.table.SourcesFileResults
Source files that were modified by the recipe run.
| Column Name | Description |
|---|---|
| Source path before the run | The source path of the file before the run. null when a source file was created during the run. |
| Source path after the run | A recipe may modify the source path. This is the path after the run. null when a source file was deleted during the run. |
| Parent of the recipe that made changes | In a hierarchical recipe, the parent of the recipe that made a change. Empty if this is the root of a hierarchy or if the recipe is not hierarchical at all. |
| Recipe that made changes | The specific recipe that made a change. |
| Estimated time saving | An estimated effort that a developer to fix manually instead of using this recipe, in unit of seconds. |
| Cycle | The recipe cycle in which the change was made. |
Source files that had search results
org.openrewrite.table.SearchResults
Search results that were found during the recipe run.
| Column Name | Description |
|---|---|
| Source path of search result before the run | The source path of the file with the search result markers present. |
| Source path of search result after run the run | A recipe may modify the source path. This is the path after the run. null when a source file was deleted during the run. |
| Result | The trimmed printed tree of the LST element that the marker is attached to. |
| Description | The content of the description of the marker. |
| Recipe that added the search marker | The specific recipe that added the Search marker. |
Source files that errored on a recipe
org.openrewrite.table.SourcesFileErrors
The details of all errors produced by a recipe run.
| Column Name | Description |
|---|---|
| Source path | The file that failed to parse. |
| Recipe that made changes | The specific recipe that made a change. |
| Stack trace | The stack trace of the failure. |
Recipe performance
org.openrewrite.table.RecipeRunStats
Statistics used in analyzing the performance of recipes.
| Column Name | Description |
|---|---|
| The recipe | The recipe whose stats are being measured both individually and cumulatively. |
| Source file count | The number of source files the recipe ran over. |
| Source file changed count | The number of source files which were changed in the recipe run. Includes files created, deleted, and edited. |
| Cumulative scanning time (ns) | The total time spent across the scanning phase of this recipe. |
| Max scanning time (ns) | The max time scanning any one source file. |
| Cumulative edit time (ns) | The total time spent across the editing phase of this recipe. |
| Max edit time (ns) | The max time editing any one source file. |