github.com/cayleygraph/cayley@v0.7.7/schema/types.go (about)

     1  package schema
     2  
     3  import (
     4  	"github.com/cayleygraph/quad"
     5  	_ "github.com/cayleygraph/quad/voc/rdf"
     6  	_ "github.com/cayleygraph/quad/voc/rdfs"
     7  	"github.com/cayleygraph/quad/voc/schema"
     8  )
     9  
    10  func init() {
    11  	RegisterType(quad.IRI(schema.Class), Class{})
    12  	RegisterType(quad.IRI(schema.Property), Property{})
    13  }
    14  
    15  // Object is a basic RDF resource object.
    16  //
    17  // Deprecated: use Resource instead.
    18  type Object = Resource
    19  
    20  // Resource is a basic RDF resource object.
    21  type Resource struct {
    22  	ID quad.IRI `quad:"@id"`
    23  
    24  	Label   string `quad:"rdfs:label,optional"`
    25  	Comment string `quad:"rdfs:comment,optional"`
    26  
    27  	Name        string `quad:"schema:name,optional"`
    28  	Description string `quad:"schema:description,optional"`
    29  }
    30  
    31  type Property struct {
    32  	Resource
    33  	InverseOf    quad.IRI   `quad:"schema:inverseOf,optional"`
    34  	SupersededBy []quad.IRI `quad:"schema:supersededBy,optional"`
    35  	Expects      []quad.IRI `quad:"schema:rangeIncludes"`
    36  }
    37  
    38  type Class struct {
    39  	Resource
    40  	Properties   []Property `quad:"schema:domainIncludes < *,optional"`
    41  	SupersededBy []quad.IRI `quad:"schema:supersededBy,optional"`
    42  	Extends      []quad.IRI `quad:"rdfs:subClassOf,optional"`
    43  }
    44  
    45  type PropertiesByIRI []Property
    46  
    47  func (a PropertiesByIRI) Len() int      { return len(a) }
    48  func (a PropertiesByIRI) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
    49  func (a PropertiesByIRI) Less(i, j int) bool {
    50  	return a[i].ID < a[j].ID
    51  }
    52  
    53  type ClassesByIRI []Class
    54  
    55  func (a ClassesByIRI) Len() int      { return len(a) }
    56  func (a ClassesByIRI) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
    57  func (a ClassesByIRI) Less(i, j int) bool {
    58  	return a[i].ID < a[j].ID
    59  }