Package com.norconex.commons.lang.jar
Class JarDuplicates
java.lang.Object
com.norconex.commons.lang.jar.JarDuplicates
Holds jar files that are considered duplicates. Jar duplicates are defined
as having the same base name, which is the regular file name, minus the
version information.
- Since:
- 1.10.0
-
Constructor Summary
ConstructorsConstructorDescriptionJarDuplicates(@NonNull JarFile... jarFiles) Creates a group of 2 or moreJarFileduplicates.JarDuplicates(@NonNull Collection<JarFile> jarFiles) Creates a group of 2 or moreJarFileduplicates. -
Method Summary
Modifier and TypeMethodDescriptionbooleanGets whether all jar files in this duplicate are equivalent (equivalent versions and identical last modified dates).protected booleanbooleanGets whether this duplicate batch contains the given jar file, by comparing their paths.booleanGets theJarFilecorresponding to the supplied file by comparing their paths.Gets all jar files of this duplicate batch except for the one considered the greatest, as pergetGreatest().Gets the duplicate jar file that is considered the greatest based on its version and last modified date (in case of equivalent versions).Gets the jar files being considered duplicates of each other.Deprecated.inthashCode()booleanDeprecated.Use !toString()
-
Constructor Details
-
JarDuplicates
Creates a group of 2 or moreJarFileduplicates.- Parameters:
jarFiles- duplicate jar files (must not benull)- Throws:
IllegalArgumentException- if jar file array contains less than 2 non-nulljar files.- Since:
- 3.0.0
-
JarDuplicates
Creates a group of 2 or moreJarFileduplicates.- Parameters:
jarFiles- duplicate jar files (must not benull)- Throws:
IllegalArgumentException- if jar file collection contains less than 2 non-nulljar files.- Since:
- 3.0.0
-
-
Method Details
-
getBaseName
- Returns:
- the file name, minus the version and file extension
- Since:
- 3.0.0
-
getJarFiles
Gets the jar files being considered duplicates of each other. Since 3.0.0, returns aListinstead of an array, sorted from greatest to lowest.- Returns:
- jar files
-
getLatestVersion
Deprecated.UsegetGreatest()instead.Gets the jar file that is considered the greatest of the batch based on their version and last modified date (in case of equivalent versions). If two ore more jars are candidates to be greatest (equivalent versions and modified date), there are no guarantees as to which one will be returned. Versions are expected to follow semantic versioning. Otherwise, a best effort it made to identify and convert versions to semantic ones for the purpose of comparing them. Given non-semantic version patterns vary, there are no guarantees of 100% accuracy in such case.- Returns:
- greatest jar file
-
getGreatest
Gets the duplicate jar file that is considered the greatest based on its version and last modified date (in case of equivalent versions). If two ore more jars are candidates to be greatest (equivalent versions and modified date), there are no guarantees as to which one will be returned. Versions are expected to follow semantic versioning. Otherwise, a best effort it made to identify and convert versions to semantic ones for the purpose of comparing them. Given non-semantic version patterns vary, there are no guarantees of 100% accuracy in such case.- Returns:
- greatest jar file
- Since:
- 3.0.0
-
getAllButGreatest
Gets all jar files of this duplicate batch except for the one considered the greatest, as pergetGreatest(). The jar files are sorted from greatest to lowest.- Returns:
- all but the greatest jar files
- Since:
- 3.0.0
-
hasVersionConflict
Deprecated.Use !areEquivalent()instead.Whether all jar files share the same version or if at least one of them have a different version.- Returns:
trueif at least one jar file has a different version
-
areEquivalent
public boolean areEquivalent()Gets whether all jar files in this duplicate are equivalent (equivalent versions and identical last modified dates).- Returns:
trueif all jars are equivalent- Since:
- 3.0.0
-
get
Gets theJarFilecorresponding to the supplied file by comparing their paths.- Parameters:
file- file to get its correspondingJarFile- Returns:
- an optional with the matching jar file, or empty if none found
- Since:
- 3.0.0
-
contains
Gets whether this duplicate batch contains the given jar file, by comparing their paths. Same as invokingisPresent()on the returned value ofget(File).- Parameters:
jarFile- jar file- Returns:
trueif this instance contains the given jar file
-
toString
-
equals
-
canEqual
-
hashCode
public int hashCode()
-
getGreatest()instead.