This is an automated email from the ASF dual-hosted git repository. joshsh pushed a commit to branch TINKERPOP-2563-language in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit 0640fc0a29a6c549edd9a5cc52ce4be3ed57302d Author: Joshua Shinavier <[email protected]> AuthorDate: Thu Jun 3 06:51:16 2021 -0700 Add generated classes for rdf11-concepts --- .../tinkerpop/rdf/rdf11concepts/BlankNode.java | 40 ++++++ .../apache/tinkerpop/rdf/rdf11concepts/Iri.java | 37 +++++ .../tinkerpop/rdf/rdf11concepts/LanguageTag.java | 36 +++++ .../rdf/rdf11concepts/NamespacePrefix.java | 33 +++++ .../tinkerpop/rdf/rdf11concepts/RdfDataset.java | 63 +++++++++ .../tinkerpop/rdf/rdf11concepts/RdfGraph.java | 33 +++++ .../tinkerpop/rdf/rdf11concepts/RdfLiteral.java | 80 +++++++++++ .../rdf/rdf11concepts/RdfSubjectTerm.java | 112 +++++++++++++++ .../tinkerpop/rdf/rdf11concepts/RdfTerm.java | 156 +++++++++++++++++++++ .../tinkerpop/rdf/rdf11concepts/RdfTriple.java | 78 +++++++++++ .../tinkerpop/rdf/rdf11concepts/RdfVocabulary.java | 33 +++++ 11 files changed, 701 insertions(+) diff --git a/gremlin-language/src/gen/java/org/apache/tinkerpop/rdf/rdf11concepts/BlankNode.java b/gremlin-language/src/gen/java/org/apache/tinkerpop/rdf/rdf11concepts/BlankNode.java new file mode 100644 index 0000000..f0476b4 --- /dev/null +++ b/gremlin-language/src/gen/java/org/apache/tinkerpop/rdf/rdf11concepts/BlankNode.java @@ -0,0 +1,40 @@ +package org.example.org.apache.tinkerpop.rdf.rdf11concepts; + +/** + * A node in an RDF graph which is neither an IRI nor a literal + * + * @seeAlso - id: "https://www.w3.org/TR/rdf11-concepts/#section-blank-nodes" + * title: "RDF 1.1 Concepts and Abstract Syntax, section 3.4: Blank Nodes" + */ +public class BlankNode { + /** + * A local identifier for the blank node which may be used in concrete syntaxes + * + * @comments Giving a blank node a string-valued identifier is a pragmatic choice which is intended to support + * implementations. rdf11-concepts makes clear that such identifiers are not part of the RDF abstract syntax, and should + * not be used as persistent or portable identifiers for blank nodes. + * @type string + */ + public final String identifier; + + /** + * Constructs an immutable BlankNode object + */ + public BlankNode(String identifier) { + this.identifier = identifier; + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof BlankNode)) { + return false; + } + BlankNode o = (BlankNode) other; + return identifier.equals(o.identifier); + } + + @Override + public int hashCode() { + return 2 * identifier.hashCode(); + } +} diff --git a/gremlin-language/src/gen/java/org/apache/tinkerpop/rdf/rdf11concepts/Iri.java b/gremlin-language/src/gen/java/org/apache/tinkerpop/rdf/rdf11concepts/Iri.java new file mode 100644 index 0000000..5eed57b --- /dev/null +++ b/gremlin-language/src/gen/java/org/apache/tinkerpop/rdf/rdf11concepts/Iri.java @@ -0,0 +1,37 @@ +package org.example.org.apache.tinkerpop.rdf.rdf11concepts; + +/** + * A Unicode string that conforms to the syntax defined in RFC 3987 + * + * @seeAlso - id: "https://www.w3.org/TR/rdf11-concepts/#section-IRIs" + * title: "RDF 1.1 Concepts and Abstract Syntax, section 3.2: IRIs" + * - id: "http://www.unicode.org/versions/latest" + * title: The Unicode Standard + * - id: "http://www.ietf.org/rfc/rfc3987.txt" + * title: "Internationalized Resource Identifiers (IRIs)" + * @type string + */ +public class Iri { + public final String value; + + /** + * Constructs an immutable Iri object + */ + public Iri(String value) { + this.value = value; + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof Iri)) { + return false; + } + Iri o = (Iri) other; + return value.equals(o.value); + } + + @Override + public int hashCode() { + return 2 * value.hashCode(); + } +} diff --git a/gremlin-language/src/gen/java/org/apache/tinkerpop/rdf/rdf11concepts/LanguageTag.java b/gremlin-language/src/gen/java/org/apache/tinkerpop/rdf/rdf11concepts/LanguageTag.java new file mode 100644 index 0000000..7c5376f --- /dev/null +++ b/gremlin-language/src/gen/java/org/apache/tinkerpop/rdf/rdf11concepts/LanguageTag.java @@ -0,0 +1,36 @@ +package org.example.org.apache.tinkerpop.rdf.rdf11concepts; + +/** + * A BCP 47 language tag + * + * @examples - en + * - de + * - zh + * @seeAlso - id: "http://tools.ietf.org/html/bcp47" + * title: Tags for Identifying Languages + * @type string + */ +public class LanguageTag { + public final String value; + + /** + * Constructs an immutable LanguageTag object + */ + public LanguageTag(String value) { + this.value = value; + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof LanguageTag)) { + return false; + } + LanguageTag o = (LanguageTag) other; + return value.equals(o.value); + } + + @Override + public int hashCode() { + return 2 * value.hashCode(); + } +} diff --git a/gremlin-language/src/gen/java/org/apache/tinkerpop/rdf/rdf11concepts/NamespacePrefix.java b/gremlin-language/src/gen/java/org/apache/tinkerpop/rdf/rdf11concepts/NamespacePrefix.java new file mode 100644 index 0000000..3bc0493 --- /dev/null +++ b/gremlin-language/src/gen/java/org/apache/tinkerpop/rdf/rdf11concepts/NamespacePrefix.java @@ -0,0 +1,33 @@ +package org.example.org.apache.tinkerpop.rdf.rdf11concepts; + +/** + * A common prefix for IRIs in the same RDF vocabulary + * + * @seeAlso - id: "https://www.w3.org/TR/rdf11-concepts/#vocabularies" + * title: "RDF 1.1 Concepts and Abstract Syntax, section 1.4: RDF Vocabularies and Namespace IRIs" + * @type string + */ +public class NamespacePrefix { + public final String value; + + /** + * Constructs an immutable NamespacePrefix object + */ + public NamespacePrefix(String value) { + this.value = value; + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof NamespacePrefix)) { + return false; + } + NamespacePrefix o = (NamespacePrefix) other; + return value.equals(o.value); + } + + @Override + public int hashCode() { + return 2 * value.hashCode(); + } +} diff --git a/gremlin-language/src/gen/java/org/apache/tinkerpop/rdf/rdf11concepts/RdfDataset.java b/gremlin-language/src/gen/java/org/apache/tinkerpop/rdf/rdf11concepts/RdfDataset.java new file mode 100644 index 0000000..9a535e6 --- /dev/null +++ b/gremlin-language/src/gen/java/org/apache/tinkerpop/rdf/rdf11concepts/RdfDataset.java @@ -0,0 +1,63 @@ +package org.example.org.apache.tinkerpop.rdf.rdf11concepts; + +/** + * A collection of RDF graphs, consisting of a default graph and a set of named graphs + * + * @seeAlso - id: "https://www.w3.org/TR/rdf11-concepts/#section-dataset" + * title: "RDF 1.1 Concepts and Abstract Syntax, section 4: RDF Datasets" + */ +public class RdfDataset { + /** + * The single default (unnamed) graph of the RDF dataset + * + * @type org/apache/tinkerpop/rdf/rdf11concepts.RdfGraph + */ + public final RdfGraph defaultGraph; + + /** + * The named graphs of the RDF dataset, as a map from unique graph names to graphs + * + * @type map: + * keys: org/apache/tinkerpop/rdf/rdf11concepts.RdfSubjectTerm + * values: org/apache/tinkerpop/rdf/rdf11concepts.RdfGraph + */ + public final java.util.Map<RdfSubjectTerm, RdfGraph> namedGraphs; + + /** + * Constructs an immutable RdfDataset object + */ + public RdfDataset(RdfGraph defaultGraph, java.util.Map<RdfSubjectTerm, RdfGraph> namedGraphs) { + this.defaultGraph = defaultGraph; + this.namedGraphs = namedGraphs; + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof RdfDataset)) { + return false; + } + RdfDataset o = (RdfDataset) other; + return defaultGraph.equals(o.defaultGraph) + && namedGraphs.equals(o.namedGraphs); + } + + @Override + public int hashCode() { + return 2 * defaultGraph.hashCode() + + 3 * namedGraphs.hashCode(); + } + + /** + * Construct a new immutable RdfDataset object in which defaultGraph is overridden + */ + public RdfDataset withDefaultGraph(RdfGraph defaultGraph) { + return new RdfDataset(defaultGraph, namedGraphs); + } + + /** + * Construct a new immutable RdfDataset object in which namedGraphs is overridden + */ + public RdfDataset withNamedGraphs(java.util.Map<RdfSubjectTerm, RdfGraph> namedGraphs) { + return new RdfDataset(defaultGraph, namedGraphs); + } +} diff --git a/gremlin-language/src/gen/java/org/apache/tinkerpop/rdf/rdf11concepts/RdfGraph.java b/gremlin-language/src/gen/java/org/apache/tinkerpop/rdf/rdf11concepts/RdfGraph.java new file mode 100644 index 0000000..70f6ef2 --- /dev/null +++ b/gremlin-language/src/gen/java/org/apache/tinkerpop/rdf/rdf11concepts/RdfGraph.java @@ -0,0 +1,33 @@ +package org.example.org.apache.tinkerpop.rdf.rdf11concepts; + +/** + * A set of RDF triples + * + * @seeAlso - id: "https://www.w3.org/TR/rdf11-concepts/#section-rdf-graph" + * title: "RDF 1.1 Concepts and Abstract Syntax, section 3: RDF Graphs" + * @type set: org/apache/tinkerpop/rdf/rdf11concepts.RdfTriple + */ +public class RdfGraph { + public final java.util.Set<RdfTriple> value; + + /** + * Constructs an immutable RdfGraph object + */ + public RdfGraph(java.util.Set<RdfTriple> value) { + this.value = value; + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof RdfGraph)) { + return false; + } + RdfGraph o = (RdfGraph) other; + return value.equals(o.value); + } + + @Override + public int hashCode() { + return 2 * value.hashCode(); + } +} diff --git a/gremlin-language/src/gen/java/org/apache/tinkerpop/rdf/rdf11concepts/RdfLiteral.java b/gremlin-language/src/gen/java/org/apache/tinkerpop/rdf/rdf11concepts/RdfLiteral.java new file mode 100644 index 0000000..a6c7f17 --- /dev/null +++ b/gremlin-language/src/gen/java/org/apache/tinkerpop/rdf/rdf11concepts/RdfLiteral.java @@ -0,0 +1,80 @@ +package org.example.org.apache.tinkerpop.rdf.rdf11concepts; + +/** + * A value such as a string, number, or date + * + * @seeAlso - id: "https://www.w3.org/TR/rdf11-concepts/#section-Graph-Literal" + * title: "RDF 1.1 Concepts and Abstract Syntax, section 3.2: Literals" + */ +public class RdfLiteral { + /** + * A Unicode string which should be in Normal Form C + * + * @seeAlso - id: "http://www.unicode.org/reports/tr15" + * title: "TR15, Unicode Normalization Forms" + * @type string + */ + public final String lexicalForm; + + /** + * An IRI identifying a datatype that determines how the lexical form maps to a literal value + * + * @type org/apache/tinkerpop/rdf/rdf11concepts.Iri + */ + public final Iri datatype; + + /** + * An optional language tag, provided only if the datatype of this literal is rdf:langString + * + * @type optional: org/apache/tinkerpop/rdf/rdf11concepts.LanguageTag + */ + public final java.util.Optional<LanguageTag> languageTag; + + /** + * Constructs an immutable RdfLiteral object + */ + public RdfLiteral(String lexicalForm, Iri datatype, java.util.Optional<LanguageTag> languageTag) { + this.lexicalForm = lexicalForm; + this.datatype = datatype; + this.languageTag = languageTag; + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof RdfLiteral)) { + return false; + } + RdfLiteral o = (RdfLiteral) other; + return lexicalForm.equals(o.lexicalForm) + && datatype.equals(o.datatype) + && languageTag.equals(o.languageTag); + } + + @Override + public int hashCode() { + return 2 * lexicalForm.hashCode() + + 3 * datatype.hashCode() + + 5 * languageTag.hashCode(); + } + + /** + * Construct a new immutable RdfLiteral object in which lexicalForm is overridden + */ + public RdfLiteral withLexicalForm(String lexicalForm) { + return new RdfLiteral(lexicalForm, datatype, languageTag); + } + + /** + * Construct a new immutable RdfLiteral object in which datatype is overridden + */ + public RdfLiteral withDatatype(Iri datatype) { + return new RdfLiteral(lexicalForm, datatype, languageTag); + } + + /** + * Construct a new immutable RdfLiteral object in which languageTag is overridden + */ + public RdfLiteral withLanguageTag(java.util.Optional<LanguageTag> languageTag) { + return new RdfLiteral(lexicalForm, datatype, languageTag); + } +} diff --git a/gremlin-language/src/gen/java/org/apache/tinkerpop/rdf/rdf11concepts/RdfSubjectTerm.java b/gremlin-language/src/gen/java/org/apache/tinkerpop/rdf/rdf11concepts/RdfSubjectTerm.java new file mode 100644 index 0000000..f47f232 --- /dev/null +++ b/gremlin-language/src/gen/java/org/apache/tinkerpop/rdf/rdf11concepts/RdfSubjectTerm.java @@ -0,0 +1,112 @@ +package org.example.org.apache.tinkerpop.rdf.rdf11concepts; + +/** + * An RDF term which may appear in the subject position of a triple, i.e. an IRI or a blank node + * + * @comments The concept of an "RDF subject" is not directly defined in rdf11-concepts; it is provided here as a + * convenience. + */ +public abstract class RdfSubjectTerm { + private RdfSubjectTerm() {} + + public abstract <R> R accept(Visitor<R> visitor) ; + + /** + * An interface for applying a function to a RdfSubjectTerm according to its variant (subclass) + */ + public interface Visitor<R> { + R visit(Iri instance) ; + + R visit(BlankNode instance) ; + } + + /** + * An interface for applying a function to a RdfSubjectTerm according to its variant (subclass). If a visit() method for + * a particular variant is not implemented, a default method is used instead. + */ + public interface PartialVisitor<R> extends Visitor<R> { + default R otherwise(RdfSubjectTerm instance) { + throw new IllegalStateException("Non-exhaustive patterns when matching: " + instance); + } + + @Override + default R visit(Iri instance) { + return otherwise(instance); + } + + @Override + default R visit(BlankNode instance) { + return otherwise(instance); + } + } + + /** + * An IRI + * + * @type org/apache/tinkerpop/rdf/rdf11concepts.Iri + */ + public static final class Iri extends RdfSubjectTerm { + public final Iri iri; + + /** + * Constructs an immutable Iri object + */ + public Iri(Iri iri) { + this.iri = iri; + } + + @Override + public <R> R accept(Visitor<R> visitor) { + return visitor.visit(this); + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof Iri)) { + return false; + } + Iri o = (Iri) other; + return iri.equals(o.iri); + } + + @Override + public int hashCode() { + return 2 * iri.hashCode(); + } + } + + /** + * A blank node + * + * @type org/apache/tinkerpop/rdf/rdf11concepts.BlankNode + */ + public static final class BlankNode extends RdfSubjectTerm { + public final BlankNode blankNode; + + /** + * Constructs an immutable BlankNode object + */ + public BlankNode(BlankNode blankNode) { + this.blankNode = blankNode; + } + + @Override + public <R> R accept(Visitor<R> visitor) { + return visitor.visit(this); + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof BlankNode)) { + return false; + } + BlankNode o = (BlankNode) other; + return blankNode.equals(o.blankNode); + } + + @Override + public int hashCode() { + return 2 * blankNode.hashCode(); + } + } +} diff --git a/gremlin-language/src/gen/java/org/apache/tinkerpop/rdf/rdf11concepts/RdfTerm.java b/gremlin-language/src/gen/java/org/apache/tinkerpop/rdf/rdf11concepts/RdfTerm.java new file mode 100644 index 0000000..0c311c8 --- /dev/null +++ b/gremlin-language/src/gen/java/org/apache/tinkerpop/rdf/rdf11concepts/RdfTerm.java @@ -0,0 +1,156 @@ +package org.example.org.apache.tinkerpop.rdf.rdf11concepts; + +/** + * An IRI, literal, or blank node + * + * @comments Whereas the "nodes" of a graph are all of that graph's subjects and objects, RDF terms are the set of all + * possible IRIs, literals, and blank nodes. + * @seeAlso - id: "https://www.w3.org/TR/rdf11-concepts/#section-triples" + * title: "RDF 1.1 Concepts and Abstract Syntax, section 3.1: Triples" + */ +public abstract class RdfTerm { + private RdfTerm() {} + + public abstract <R> R accept(Visitor<R> visitor) ; + + /** + * An interface for applying a function to a RdfTerm according to its variant (subclass) + */ + public interface Visitor<R> { + R visit(Iri instance) ; + + R visit(Literal instance) ; + + R visit(BlankNode instance) ; + } + + /** + * An interface for applying a function to a RdfTerm according to its variant (subclass). If a visit() method for a + * particular variant is not implemented, a default method is used instead. + */ + public interface PartialVisitor<R> extends Visitor<R> { + default R otherwise(RdfTerm instance) { + throw new IllegalStateException("Non-exhaustive patterns when matching: " + instance); + } + + @Override + default R visit(Iri instance) { + return otherwise(instance); + } + + @Override + default R visit(Literal instance) { + return otherwise(instance); + } + + @Override + default R visit(BlankNode instance) { + return otherwise(instance); + } + } + + /** + * An IRI + * + * @type org/apache/tinkerpop/rdf/rdf11concepts.Iri + */ + public static final class Iri extends RdfTerm { + public final Iri iri; + + /** + * Constructs an immutable Iri object + */ + public Iri(Iri iri) { + this.iri = iri; + } + + @Override + public <R> R accept(Visitor<R> visitor) { + return visitor.visit(this); + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof Iri)) { + return false; + } + Iri o = (Iri) other; + return iri.equals(o.iri); + } + + @Override + public int hashCode() { + return 2 * iri.hashCode(); + } + } + + /** + * A literal + * + * @type org/apache/tinkerpop/rdf/rdf11concepts.RdfLiteral + */ + public static final class Literal extends RdfTerm { + public final RdfLiteral literal; + + /** + * Constructs an immutable Literal object + */ + public Literal(RdfLiteral literal) { + this.literal = literal; + } + + @Override + public <R> R accept(Visitor<R> visitor) { + return visitor.visit(this); + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof Literal)) { + return false; + } + Literal o = (Literal) other; + return literal.equals(o.literal); + } + + @Override + public int hashCode() { + return 2 * literal.hashCode(); + } + } + + /** + * A blank node + * + * @type org/apache/tinkerpop/rdf/rdf11concepts.BlankNode + */ + public static final class BlankNode extends RdfTerm { + public final BlankNode blankNode; + + /** + * Constructs an immutable BlankNode object + */ + public BlankNode(BlankNode blankNode) { + this.blankNode = blankNode; + } + + @Override + public <R> R accept(Visitor<R> visitor) { + return visitor.visit(this); + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof BlankNode)) { + return false; + } + BlankNode o = (BlankNode) other; + return blankNode.equals(o.blankNode); + } + + @Override + public int hashCode() { + return 2 * blankNode.hashCode(); + } + } +} diff --git a/gremlin-language/src/gen/java/org/apache/tinkerpop/rdf/rdf11concepts/RdfTriple.java b/gremlin-language/src/gen/java/org/apache/tinkerpop/rdf/rdf11concepts/RdfTriple.java new file mode 100644 index 0000000..2acc288 --- /dev/null +++ b/gremlin-language/src/gen/java/org/apache/tinkerpop/rdf/rdf11concepts/RdfTriple.java @@ -0,0 +1,78 @@ +package org.example.org.apache.tinkerpop.rdf.rdf11concepts; + +/** + * A triple consisting of a subject, predicate, and object + * + * @seeAlso - id: "https://www.w3.org/TR/rdf11-concepts/#section-triples" + * title: "RDF 1.1 Concepts and Abstract Syntax, section 3.1: Triples" + */ +public class RdfTriple { + /** + * The subject of the triple, which is an IRI or a blank node + * + * @type org/apache/tinkerpop/rdf/rdf11concepts.RdfSubjectTerm + */ + public final RdfSubjectTerm subject; + + /** + * The predicate of the triple, which is an IRI + * + * @type org/apache/tinkerpop/rdf/rdf11concepts.Iri + */ + public final Iri predicate; + + /** + * The object of the triple, which is an IRI, a literal or a blank node + * + * @type org/apache/tinkerpop/rdf/rdf11concepts.RdfTerm + */ + public final RdfTerm object; + + /** + * Constructs an immutable RdfTriple object + */ + public RdfTriple(RdfSubjectTerm subject, Iri predicate, RdfTerm object) { + this.subject = subject; + this.predicate = predicate; + this.object = object; + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof RdfTriple)) { + return false; + } + RdfTriple o = (RdfTriple) other; + return subject.equals(o.subject) + && predicate.equals(o.predicate) + && object.equals(o.object); + } + + @Override + public int hashCode() { + return 2 * subject.hashCode() + + 3 * predicate.hashCode() + + 5 * object.hashCode(); + } + + /** + * Construct a new immutable RdfTriple object in which subject is overridden + */ + public RdfTriple withSubject(RdfSubjectTerm subject) { + return new RdfTriple(subject, predicate, object); + } + + /** + * Construct a new immutable RdfTriple object in which predicate is overridden + */ + public RdfTriple withPredicate(Iri predicate) { + return new RdfTriple(subject, predicate, object); + } + + /** + * Construct a new immutable RdfTriple object in which object is overridden + */ + public RdfTriple withObject(RdfTerm object) { + return new RdfTriple(subject, predicate, object); + } +} diff --git a/gremlin-language/src/gen/java/org/apache/tinkerpop/rdf/rdf11concepts/RdfVocabulary.java b/gremlin-language/src/gen/java/org/apache/tinkerpop/rdf/rdf11concepts/RdfVocabulary.java new file mode 100644 index 0000000..db66fc1 --- /dev/null +++ b/gremlin-language/src/gen/java/org/apache/tinkerpop/rdf/rdf11concepts/RdfVocabulary.java @@ -0,0 +1,33 @@ +package org.example.org.apache.tinkerpop.rdf.rdf11concepts; + +/** + * A collection of IRIs intended for use in RDF graphs + * + * @seeAlso - id: "https://www.w3.org/TR/rdf11-concepts/#vocabularies" + * title: "RDF 1.1 Concepts and Abstract Syntax, section 1.4: RDF Vocabularies and Namespace IRIs" + * @type set: org/apache/tinkerpop/rdf/rdf11concepts.Iri + */ +public class RdfVocabulary { + public final java.util.Set<Iri> value; + + /** + * Constructs an immutable RdfVocabulary object + */ + public RdfVocabulary(java.util.Set<Iri> value) { + this.value = value; + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof RdfVocabulary)) { + return false; + } + RdfVocabulary o = (RdfVocabulary) other; + return value.equals(o.value); + } + + @Override + public int hashCode() { + return 2 * value.hashCode(); + } +}
