Skip to content
Permalink
Browse files
Make private elements final where possible.
  • Loading branch information
garydgregory committed Jan 17, 2021
1 parent 6af4086 commit 90dd81006cecbc0938e7ae4728eb6ee34b64c5d7
Showing 10 changed files with 61 additions and 61 deletions.
@@ -46,7 +46,7 @@ class W3CRDFSyntax implements RDFSyntax {
* format</a>.
*/
private final static class FormatIRI implements IRI {
private static String BASE = "http://www.w3.org/ns/formats/";
private static final String BASE = "http://www.w3.org/ns/formats/";
private final String format;

private FormatIRI(final String format) {
@@ -76,7 +76,7 @@
*/
public final class JenaRDF implements RDF {

private static InternalJenaFactory internalJenaFactory = new InternalJenaFactory() {
private static final InternalJenaFactory INTERNAL_JENA_FACTORY = new InternalJenaFactory() {
};

private final UUID salt;
@@ -108,49 +108,49 @@ public JenaRDF(final UUID salt) {

@Override
public JenaBlankNode createBlankNode() {
return internalJenaFactory.createBlankNode(salt());
return INTERNAL_JENA_FACTORY.createBlankNode(salt());
}

@Override
public JenaBlankNode createBlankNode(final String name) {
return internalJenaFactory.createBlankNode(name, salt());
return INTERNAL_JENA_FACTORY.createBlankNode(name, salt());
}

@Override
public JenaDataset createDataset() {
return internalJenaFactory.createDataset(salt());
return INTERNAL_JENA_FACTORY.createDataset(salt());
}

@Override
public JenaGraph createGraph() {
return internalJenaFactory.createGraph(salt());
return INTERNAL_JENA_FACTORY.createGraph(salt());
}

@Override
public JenaIRI createIRI(final String iri) {
validateIRI(iri);
return internalJenaFactory.createIRI(iri);
return INTERNAL_JENA_FACTORY.createIRI(iri);
}

@Override
public JenaLiteral createLiteral(final String lexicalForm) {
return internalJenaFactory.createLiteral(lexicalForm);
return INTERNAL_JENA_FACTORY.createLiteral(lexicalForm);
}

@Override
public JenaLiteral createLiteral(final String lexicalForm, final IRI dataType) {
return internalJenaFactory.createLiteralDT(lexicalForm, dataType.getIRIString());
return INTERNAL_JENA_FACTORY.createLiteralDT(lexicalForm, dataType.getIRIString());
}

@Override
public JenaLiteral createLiteral(final String lexicalForm, final String languageTag) {
validateLang(languageTag);
return internalJenaFactory.createLiteralLang(lexicalForm, languageTag);
return INTERNAL_JENA_FACTORY.createLiteralLang(lexicalForm, languageTag);
}

@Override
public JenaTriple createTriple(final BlankNodeOrIRI subject, final IRI predicate, final RDFTerm object) {
return internalJenaFactory.createTriple(subject, predicate, object);
return INTERNAL_JENA_FACTORY.createTriple(subject, predicate, object);
}

/**
@@ -168,7 +168,7 @@ public JenaTriple createTriple(final BlankNodeOrIRI subject, final IRI predicate
@Override
public JenaQuad createQuad(final BlankNodeOrIRI graphName, final BlankNodeOrIRI subject, final IRI predicate, final RDFTerm object)
throws IllegalArgumentException, UnsupportedOperationException {
return internalJenaFactory.createQuad(subject, predicate, object, graphName);
return INTERNAL_JENA_FACTORY.createQuad(subject, predicate, object, graphName);
}

/**
@@ -192,7 +192,7 @@ public JenaQuad createQuad(final BlankNodeOrIRI graphName, final BlankNodeOrIRI
* or {@link Triple#hashCode()}.
*/
public JenaGeneralizedTripleLike createGeneralizedTriple(final RDFTerm subject, final RDFTerm predicate, final RDFTerm object) {
return internalJenaFactory.createGeneralizedTriple(subject, predicate, object);
return INTERNAL_JENA_FACTORY.createGeneralizedTriple(subject, predicate, object);
}

/**
@@ -227,7 +227,7 @@ public JenaGeneralizedTripleLike createGeneralizedTriple(final RDFTerm subject,
*/
public JenaGeneralizedQuadLike createGeneralizedQuad(final RDFTerm subject, final RDFTerm predicate, final RDFTerm object,
final RDFTerm graphName) {
return internalJenaFactory.createGeneralizedQuad(subject, predicate, object, graphName);
return INTERNAL_JENA_FACTORY.createGeneralizedQuad(subject, predicate, object, graphName);
}

/**
@@ -252,7 +252,7 @@ public JenaGeneralizedQuadLike createGeneralizedQuad(final RDFTerm subject, fina
* represents a variable in Jena.
*/
public JenaRDFTerm asRDFTerm(final Node node) throws ConversionException {
return internalJenaFactory.createRDFTerm(node, salt());
return INTERNAL_JENA_FACTORY.createRDFTerm(node, salt());
}

/**
@@ -323,7 +323,7 @@ public static RDFTerm asRDFTerm(final RDF factory, final Node node) {
* is a generalized triple
*/
public JenaTriple asTriple(final org.apache.jena.graph.Triple triple) throws ConversionException {
return internalJenaFactory.createTriple(triple, salt());
return INTERNAL_JENA_FACTORY.createTriple(triple, salt());
}

/**
@@ -351,7 +351,7 @@ public JenaTriple asTriple(final org.apache.jena.graph.Triple triple) throws Con
* if any of the triple's nodes are not concrete
*/
public JenaTripleLike asGeneralizedTriple(final org.apache.jena.graph.Triple triple) throws ConversionException {
return internalJenaFactory.createGeneralizedTriple(triple, salt());
return INTERNAL_JENA_FACTORY.createGeneralizedTriple(triple, salt());
}

/**
@@ -384,7 +384,7 @@ public JenaTripleLike asGeneralizedTriple(final org.apache.jena.graph.Triple tri
* if any of the quad nodes are not concrete
*/
public JenaQuadLike<RDFTerm> asGeneralizedQuad(final org.apache.jena.sparql.core.Quad quad) throws ConversionException {
return internalJenaFactory.createGeneralizedQuad(quad, salt());
return INTERNAL_JENA_FACTORY.createGeneralizedQuad(quad, salt());
}

/**
@@ -443,7 +443,7 @@ public static Triple asTriple(final RDF factory, final org.apache.jena.graph.Tri
* @return Adapted quad
*/
public JenaQuad asQuad(final org.apache.jena.sparql.core.Quad quad) {
return internalJenaFactory.createQuad(quad, salt());
return INTERNAL_JENA_FACTORY.createQuad(quad, salt());
}

/**
@@ -464,7 +464,7 @@ public JenaQuad asQuad(final org.apache.jena.sparql.core.Quad quad) {
* @return Adapted {@link JenaGraph}
*/
public JenaGraph asGraph(final org.apache.jena.graph.Graph graph) {
return internalJenaFactory.createGraph(graph, salt());
return INTERNAL_JENA_FACTORY.createGraph(graph, salt());
}

/**
@@ -485,7 +485,7 @@ public JenaGraph asGraph(final org.apache.jena.graph.Graph graph) {
* @return Adapted {@link JenaGraph}
*/
public JenaGraph asGraph(final org.apache.jena.rdf.model.Model model) {
return internalJenaFactory.createGraph(model, salt());
return INTERNAL_JENA_FACTORY.createGraph(model, salt());
}

/**
@@ -507,7 +507,7 @@ public JenaGraph asGraph(final org.apache.jena.rdf.model.Model model) {
* @return Adapted {@link JenaDataset}
*/
public JenaDataset asDataset(final DatasetGraph datasetGraph) {
return internalJenaFactory.createDataset(datasetGraph, salt());
return INTERNAL_JENA_FACTORY.createDataset(datasetGraph, salt());
}

/**
@@ -529,7 +529,7 @@ public JenaDataset asDataset(final DatasetGraph datasetGraph) {
* @return Adapted {@link JenaDataset}
*/
public JenaDataset asDataset(final org.apache.jena.query.Dataset datasetGraph) {
return internalJenaFactory.createDataset(datasetGraph.asDatasetGraph(), salt());
return INTERNAL_JENA_FACTORY.createDataset(datasetGraph.asDatasetGraph(), salt());
}

/**
@@ -50,7 +50,7 @@
abstract class AbstractQuadLike<S extends RDFTerm, P extends RDFTerm, O extends RDFTerm, G extends RDFTerm>
implements JenaQuadLike<G> {

private static InternalJenaFactory internalJenaFactory = new InternalJenaFactory() {
private static final InternalJenaFactory INTERNAL_JENA_FACTORY = new InternalJenaFactory() {
};

/**
@@ -65,8 +65,8 @@
private static class DefaultGraphChecker {
// Fixed UUID for comparison of defaultGraphNodeGenerated
private final UUID salt = UUID.fromString("aaa6bf96-ea58-4a55-9485-3733403a1f24");
private final RDFTerm defaultGraph = internalJenaFactory.createRDFTerm(Quad.defaultGraphIRI, salt);
private final RDFTerm defaultGraphNodeGenerated = internalJenaFactory.createRDFTerm(Quad.defaultGraphNodeGenerated, salt);
private final RDFTerm defaultGraph = INTERNAL_JENA_FACTORY.createRDFTerm(Quad.defaultGraphIRI, salt);
private final RDFTerm defaultGraphNodeGenerated = INTERNAL_JENA_FACTORY.createRDFTerm(Quad.defaultGraphNodeGenerated, salt);

/**
* Check if RDFTerm is an IRI that matches the two Jena default graph
@@ -99,7 +99,7 @@ public boolean isNotDefaultGraphJenaNode(final RDFTerm graphName) {
}
}

private static DefaultGraphChecker defaultGraphChecker = new DefaultGraphChecker();
private static final DefaultGraphChecker DEFAULT_GRAPH_CHECKER = new DefaultGraphChecker();

final Optional<G> graphName;
final S subject;
@@ -114,7 +114,7 @@ public boolean isNotDefaultGraphJenaNode(final RDFTerm graphName) {
this.predicate = Objects.requireNonNull(predicate);
this.object = Objects.requireNonNull(object);
// Enforce
this.graphName = Objects.requireNonNull(graphName).filter(defaultGraphChecker::isNotDefaultGraphJenaNode);
this.graphName = Objects.requireNonNull(graphName).filter(DEFAULT_GRAPH_CHECKER::isNotDefaultGraphJenaNode);
}

AbstractQuadLike(final S subject, final P predicate, final O object) {
@@ -124,22 +124,22 @@ public boolean isNotDefaultGraphJenaNode(final RDFTerm graphName) {
@SuppressWarnings("unchecked")
AbstractQuadLike(final org.apache.jena.sparql.core.Quad quad, final UUID salt) {
this.quad = Objects.requireNonNull(quad);
this.subject = (S) internalJenaFactory.createRDFTerm(quad.getSubject(), salt);
this.predicate = (P) internalJenaFactory.createRDFTerm(quad.getPredicate(), salt);
this.object = (O) internalJenaFactory.createRDFTerm(quad.getObject(), salt);
this.subject = (S) INTERNAL_JENA_FACTORY.createRDFTerm(quad.getSubject(), salt);
this.predicate = (P) INTERNAL_JENA_FACTORY.createRDFTerm(quad.getPredicate(), salt);
this.object = (O) INTERNAL_JENA_FACTORY.createRDFTerm(quad.getObject(), salt);
if (quad.isDefaultGraph()) {
this.graphName = Optional.empty();
} else {
this.graphName = Optional.of((G) internalJenaFactory.createRDFTerm(quad.getGraph(), salt));
this.graphName = Optional.of((G) INTERNAL_JENA_FACTORY.createRDFTerm(quad.getGraph(), salt));
}
}

@SuppressWarnings("unchecked")
AbstractQuadLike(final org.apache.jena.graph.Triple triple, final UUID salt) {
this.triple = Objects.requireNonNull(triple);
this.subject = (S) internalJenaFactory.createRDFTerm(triple.getSubject(), salt);
this.predicate = (P) internalJenaFactory.createRDFTerm(triple.getPredicate(), salt);
this.object = (O) internalJenaFactory.createRDFTerm(triple.getObject(), salt);
this.subject = (S) INTERNAL_JENA_FACTORY.createRDFTerm(triple.getSubject(), salt);
this.predicate = (P) INTERNAL_JENA_FACTORY.createRDFTerm(triple.getPredicate(), salt);
this.object = (O) INTERNAL_JENA_FACTORY.createRDFTerm(triple.getObject(), salt);
this.graphName = Optional.empty();
}

@@ -29,7 +29,7 @@

class JenaLiteralImpl extends AbstractJenaRDFTerm implements JenaLiteral {

private static InternalJenaFactory internalJenaFactory = new InternalJenaFactory() {
private static final InternalJenaFactory INTERNAL_JENA_FACTORY = new InternalJenaFactory() {
};

JenaLiteralImpl(final Node node) {
@@ -63,7 +63,7 @@ public boolean equals(final Object other) {

@Override
public IRI getDatatype() {
return internalJenaFactory.createIRI(asJenaNode().getLiteralDatatype().getURI());
return INTERNAL_JENA_FACTORY.createIRI(asJenaNode().getLiteralDatatype().getURI());
}

@Override
@@ -63,7 +63,7 @@
/**
* Used by {@link #bnodePrefix()} to get a unique UUID per JVM run
*/
private static UUID SALT = UUID.randomUUID();
private static final UUID SALT = UUID.randomUUID();

/**
* Prefix to use in blank node identifiers
@@ -33,7 +33,7 @@

// Note: We always pass the blankNodePrefix and don't rely on the internal
// blankNodePrefix in this static factory
private static JsonLdRDF rdfTermFactory = new JsonLdRDF();
private static final JsonLdRDF RDF_TERM_FACTORY = new JsonLdRDF();

private final Quad quad;
private final String blankNodePrefix;
@@ -46,26 +46,26 @@
@SuppressWarnings("unchecked")
@Override
public Optional<G> getGraphName() {
final G g = (G) rdfTermFactory.asRDFTerm(quad.getGraph(), blankNodePrefix);
final G g = (G) RDF_TERM_FACTORY.asRDFTerm(quad.getGraph(), blankNodePrefix);
return Optional.ofNullable(g);
}

@SuppressWarnings("unchecked")
@Override
public S getSubject() {
return (S) rdfTermFactory.asRDFTerm(quad.getSubject(), blankNodePrefix);
return (S) RDF_TERM_FACTORY.asRDFTerm(quad.getSubject(), blankNodePrefix);
}

@SuppressWarnings("unchecked")
@Override
public P getPredicate() {
return (P) rdfTermFactory.asRDFTerm(quad.getPredicate(), blankNodePrefix);
return (P) RDF_TERM_FACTORY.asRDFTerm(quad.getPredicate(), blankNodePrefix);
}

@SuppressWarnings("unchecked")
@Override
public O getObject() {
return (O) rdfTermFactory.asRDFTerm(quad.getObject(), blankNodePrefix);
return (O) RDF_TERM_FACTORY.asRDFTerm(quad.getObject(), blankNodePrefix);
}

@Override

0 comments on commit 90dd810

Please sign in to comment.