https://github.com/google/cayley
Revision 463642efb05f1cf0e1ce8815c8b68f19ea677e31 authored by Denys Smirnov on 06 January 2018, 16:26:58 UTC, committed by Denys Smirnov on 06 January 2018, 16:26:58 UTC
1 parent 1f53d04
Raw File
Tip revision: 463642efb05f1cf0e1ce8815c8b68f19ea677e31 authored by Denys Smirnov on 06 January 2018, 16:26:58 UTC
iterator: get some rough size estimates for comparisons
Tip revision: 463642e
types.go
package schema

import (
	"github.com/cayleygraph/cayley/quad"
	_ "github.com/cayleygraph/cayley/voc/rdf"
	_ "github.com/cayleygraph/cayley/voc/rdfs"
	"github.com/cayleygraph/cayley/voc/schema"
)

func init() {
	RegisterType(quad.IRI(schema.Class), Class{})
	RegisterType(quad.IRI(schema.Property), Property{})
}

type Object struct {
	ID quad.IRI `quad:"@id"`

	Label   string `quad:"rdfs:label,optional"`
	Comment string `quad:"rdfs:comment,optional"`

	Name        string `quad:"schema:name,optional"`
	Description string `quad:"schema:description,optional"`
}

type Property struct {
	Object
	InverseOf    quad.IRI   `quad:"schema:inverseOf,optional"`
	SupersededBy []quad.IRI `quad:"schema:supersededBy,optional"`
	Expects      []quad.IRI `quad:"schema:rangeIncludes"`
}

type Class struct {
	Object
	Properties   []Property `quad:"schema:domainIncludes < *,optional"`
	SupersededBy []quad.IRI `quad:"schema:supersededBy,optional"`
	Extends      []quad.IRI `quad:"rdfs:subClassOf,optional"`
}

type PropertiesByIRI []Property

func (a PropertiesByIRI) Len() int      { return len(a) }
func (a PropertiesByIRI) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a PropertiesByIRI) Less(i, j int) bool {
	return a[i].ID < a[j].ID
}

type ClassesByIRI []Class

func (a ClassesByIRI) Len() int      { return len(a) }
func (a ClassesByIRI) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ClassesByIRI) Less(i, j int) bool {
	return a[i].ID < a[j].ID
}
back to top