Skip to content

Commit

Permalink
style(service): fix code smells in Context
Browse files Browse the repository at this point in the history
  • Loading branch information
poikilotherm committed May 11, 2022
1 parent 87526cc commit 87e09d2
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ public class Context {
private static final TransformerFactory factory = TransformerFactory.newInstance();

private Transformer transformer;
private Map<String, Transformer> metadataTransformers = new HashMap<String, Transformer>();
private final Map<String, Transformer> metadataTransformers = new HashMap<>();
private String baseUrl;
private Granularity granularity;
private OAIClient client;

public Context() {
try {
this.withMetadataTransformer("xoai", factory.newTransformer());
this.withMetadataTransformer("xoai", Context.factory.newTransformer());
} catch (TransformerConfigurationException e) {
throw new RuntimeException("Unable to initialize identity transformer");
throw new IllegalStateException("Unable to initialize identity transformer", e);
}
}

Expand Down Expand Up @@ -95,17 +95,17 @@ public OAIClient getClient () {
public enum KnownTransformer {
OAI_DC("to_xoai/oai_dc.xsl");

private String location;
private final String location;

KnownTransformer(String location) {
this.location = location;
}

public Transformer transformer () {
try {
return factory.newTransformer(new StreamSource(this.getClass().getClassLoader().getResourceAsStream(location)));
return Context.factory.newTransformer(new StreamSource(this.getClass().getClassLoader().getResourceAsStream(location)));
} catch (TransformerConfigurationException e) {
throw new RuntimeException("Unable to load resource file '"+location+"'", e);
throw new IllegalStateException("Unable to load resource file '" + location + "'", e);
}
}
}
Expand Down

0 comments on commit 87e09d2

Please sign in to comment.