aboutsummaryrefslogtreecommitdiffstats
path: root/abi-check-plugin
diff options
context:
space:
mode:
authorIlpo Ruotsalainen <ilpo.ruotsalainen@oath.com>2018-11-30 11:27:56 +0100
committerIlpo Ruotsalainen <ilpo.ruotsalainen@oath.com>2018-11-30 11:27:56 +0100
commit4ab17a2abf972fe0892469f3e0205acc21e24975 (patch)
tree1238c6d51eebcba1826f2b383d0b39da246f0cb1 /abi-check-plugin
parent7ae381e07c315af1bb52aadddbfeceb43ef975a4 (diff)
Refactor to extract a method.
Diffstat (limited to 'abi-check-plugin')
-rw-r--r--abi-check-plugin/src/main/java/com/yahoo/abicheck/mojo/AbiCheck.java29
1 files changed, 16 insertions, 13 deletions
diff --git a/abi-check-plugin/src/main/java/com/yahoo/abicheck/mojo/AbiCheck.java b/abi-check-plugin/src/main/java/com/yahoo/abicheck/mojo/AbiCheck.java
index 83bc26147d1..516c1bb015f 100644
--- a/abi-check-plugin/src/main/java/com/yahoo/abicheck/mojo/AbiCheck.java
+++ b/abi-check-plugin/src/main/java/com/yahoo/abicheck/mojo/AbiCheck.java
@@ -99,19 +99,12 @@ public class AbiCheck extends AbstractMojo {
getLog().info("Writing ABI specs to " + specFileName);
writeSpec(signatures, specFileName);
} else {
- Gson gson = new GsonBuilder().create();
- try (FileReader reader = new FileReader(specFileName)) {
- TypeToken<Map<String, JavaClassSignature>> typeToken =
- new TypeToken<Map<String, JavaClassSignature>>() {
- };
- Map<String, JavaClassSignature> abiSpec = gson
- .fromJson(reader, typeToken.getType());
- if (!matchingItemSets(abiSpec.keySet(), signatures.keySet(),
- item -> matchingClasses(item, abiSpec.get(item), signatures.get(item)),
- (item, error) -> getLog()
- .error(String.format("%s class: %s", capitalizeFirst(error), item)))) {
- throw new MojoFailureException("ABI spec mismatch");
- }
+ Map<String, JavaClassSignature> abiSpec = readSpec(specFileName);
+ if (!matchingItemSets(abiSpec.keySet(), signatures.keySet(),
+ item -> matchingClasses(item, abiSpec.get(item), signatures.get(item)),
+ (item, error) -> getLog()
+ .error(String.format("%s class: %s", capitalizeFirst(error), item)))) {
+ throw new MojoFailureException("ABI spec mismatch");
}
}
} catch (IOException e) {
@@ -119,6 +112,16 @@ public class AbiCheck extends AbstractMojo {
}
}
+ private static Map<String, JavaClassSignature> readSpec(String fileName) throws IOException {
+ try (FileReader reader = new FileReader(fileName)) {
+ TypeToken<Map<String, JavaClassSignature>> typeToken =
+ new TypeToken<Map<String, JavaClassSignature>>() {
+ };
+ Gson gson = new GsonBuilder().create();
+ return gson.fromJson(reader, typeToken.getType());
+ }
+ }
+
private static void writeSpec(Map<String, JavaClassSignature> signatures, String fileName)
throws IOException {
Gson gson = new GsonBuilder().setPrettyPrinting().create();