-
Notifications
You must be signed in to change notification settings - Fork 9
/
ChecksumModes.java
39 lines (35 loc) · 1.09 KB
/
ChecksumModes.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package io.github.chains_project.maven_lockfile.checksum;
/**
* The checksum modes that are supported by the plugin.
* A checksum mode is a way to calculate the checksum of a dependency.
*/
public enum ChecksumModes {
/**
* Downloads the checksum from the maven repository.
*/
MAVEN_CENTRAL("maven_central"),
/**
* Calculates the checksum from the downloaded artifact.
*/
MAVEN_LOCAL("maven_local");
/**
* The name of the checksum mode.
*/
private final String name;
ChecksumModes(String name) {
this.name = name;
}
/**
* Gets a checksum mode from its name. Throws an exception if no checksum mode with the given name exists.
* @param name The name of the checksum mode.
* @return The checksum mode.
*/
public static ChecksumModes fromName(String name) {
for (ChecksumModes mode : ChecksumModes.values()) {
if (mode.name.equals(name)) {
return mode;
}
}
throw new IllegalArgumentException("No checksum mode with name " + name + " found.");
}
}