Skip to content

Commit 1b4344b

Browse files
committed
Add comments and Javadoc
1 parent 68b8b78 commit 1b4344b

File tree

6 files changed

+18
-3
lines changed

6 files changed

+18
-3
lines changed

core/sds-aspect-model-validator/src/main/java/io/openmanufacturing/sds/aspectmodel/shacl/LiteralComparator.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717

1818
import org.apache.jena.rdf.model.Literal;
1919

20+
/**
21+
* A {@link Comparator} for RDF {@link Literal}s that takes into account their type
22+
*/
2023
public class LiteralComparator implements Comparator<Literal> {
2124
@Override
2225
public int compare( final Literal literal1, final Literal literal2 ) {

core/sds-aspect-model-validator/src/main/java/io/openmanufacturing/sds/aspectmodel/shacl/RdfTypes.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525

2626
import com.google.common.collect.ImmutableList;
2727

28+
/**
29+
* Provides functions to find out information about the types of resources
30+
*/
2831
public class RdfTypes {
2932
public static List<Resource> superTypesOfType( final Resource type ) {
3033
final List<Resource> types = new ArrayList<>();

core/sds-aspect-model-validator/src/main/java/io/openmanufacturing/sds/aspectmodel/shacl/SHACL.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
import io.openmanufacturing.sds.aspectmodel.vocabulary.Namespace;
2020

21+
/**
22+
* Vocabulary for the Shapes Constraint Language (SHACL)
23+
*/
2124
public class SHACL implements Namespace {
2225
public final String NS = "http://www.w3.org/ns/shacl#";
2326

core/sds-aspect-model-validator/src/main/java/io/openmanufacturing/sds/aspectmodel/shacl/ShaclValidator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public ShaclValidator( final Model shapesModel ) {
6767
* Validates a model element using the SHACL shapes the validator was initialized with.
6868
* {@link Resource#getModel()} on the element must not return null, i.e., the resource may not be created using
6969
* {@link org.apache.jena.rdf.model.ResourceFactory#createProperty(String)}, but instead must be created via {@link Model#createResource(String)}.
70-
* @param element the element to validated
70+
* @param element the element to be validated
7171
* @return the list of {@link Violation}s if there are violations
7272
*/
7373
public List<Violation> validateElement( final Resource element ) {
@@ -99,7 +99,7 @@ public List<Violation> validateShapeForElement( final Resource element, final Sh
9999
}
100100

101101
// MinCount needs to be handled separately: If the property is not used at all on the target node, but a MinCount constraints >= 1
102-
// exists, a violation must be emitted even no value for the property exists
102+
// exists, a violation must be emitted even though no value for the property exists
103103
if ( reachableNodes.isEmpty() && constraint instanceof MinCountConstraint && property.path() instanceof PredicatePath predicatePath ) {
104104
final Property rdfProperty = model.createProperty( predicatePath.predicate().getURI() );
105105
final EvaluationContext context = new EvaluationContext( element, shape, Optional.of( rdfProperty ), List.of(), this );

core/sds-aspect-model-validator/src/main/java/io/openmanufacturing/sds/aspectmodel/shacl/Shape.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,14 @@
2424
import io.openmanufacturing.sds.aspectmodel.shacl.constraint.Constraint;
2525

2626
/**
27-
* Implements <code>sh:NodeShape</code>
27+
* Implements <a href="https://www.w3.org/TR/shacl/#node-shapes">sh:NodeShape</a>
2828
*/
2929
public interface Shape {
3030
Attributes attributes();
3131

32+
/**
33+
* Implements the valid values for <a href="https://www.w3.org/TR/shacl/#NodeKindConstraintComponent">sh:nodeKind</a>
34+
*/
3235
enum NodeKind {
3336
BlankNode, IRI, Literal, BlankNodeOrIRI, BlankNodeOrLiteral, IRIOrLiteral;
3437

core/sds-aspect-model-validator/src/main/java/io/openmanufacturing/sds/aspectmodel/shacl/ShapeLoader.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@
7575
import io.openmanufacturing.sds.aspectmodel.shacl.path.ZeroOrMorePath;
7676
import io.openmanufacturing.sds.aspectmodel.shacl.path.ZeroOrOnePath;
7777

78+
/**
79+
* Takes an RDF model describing one or more SHACL shapes as input and parses them into {@link Shape}s
80+
*/
7881
public class ShapeLoader implements Function<Model, List<Shape.Node>> {
7982
private static final SHACL SHACL = new SHACL();
8083

0 commit comments

Comments
 (0)