diff options
author | 2021-08-12 21:03:24 +0200 | |
---|---|---|
committer | 2021-08-12 21:03:24 +0200 | |
commit | 98263a7de64269898a2f81207e38943b5c8e8653 (patch) | |
tree | 743c90f109a6c5d27832d1dcef2388d939f0f77a /vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1 | |
parent | Text duplication fix (#137) (diff) | |
download | gotosocial-98263a7de64269898a2f81207e38943b5c8e8653.tar.xz |
Grand test fixup (#138)
* start fixing up tests
* fix up tests + automate with drone
* fiddle with linting
* messing about with drone.yml
* some more fiddling
* hmmm
* add cache
* add vendor directory
* verbose
* ci updates
* update some little things
* update sig
Diffstat (limited to 'vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1')
12 files changed, 1469 insertions, 0 deletions
diff --git a/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/property_owner/gen_doc.go b/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/property_owner/gen_doc.go new file mode 100644 index 000000000..1c77bcd7f --- /dev/null +++ b/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/property_owner/gen_doc.go @@ -0,0 +1,17 @@ +// Code generated by astool. DO NOT EDIT. + +// Package propertyowner contains the implementation for the owner property. All +// applications are strongly encouraged to use the interface instead of this +// concrete definition. The interfaces allow applications to consume only the +// types and properties needed and be independent of the go-fed implementation +// if another alternative implementation is created. This package is +// code-generated and subject to the same license as the go-fed tool used to +// generate it. +// +// This package is independent of other types' and properties' implementations +// by having a Manager injected into it to act as a factory for the concrete +// implementations. The implementations have been generated into their own +// separate subpackages for each vocabulary. +// +// Strongly consider using the interfaces instead of this package. +package propertyowner diff --git a/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/property_owner/gen_pkg.go b/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/property_owner/gen_pkg.go new file mode 100644 index 000000000..3a38a9b85 --- /dev/null +++ b/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/property_owner/gen_pkg.go @@ -0,0 +1,15 @@ +// Code generated by astool. DO NOT EDIT. + +package propertyowner + +var mgr privateManager + +// privateManager abstracts the code-generated manager that provides access to +// concrete implementations. +type privateManager interface{} + +// SetManager sets the manager package-global variable. For internal use only, do +// not use as part of Application behavior. Must be called at golang init time. +func SetManager(m privateManager) { + mgr = m +} diff --git a/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/property_owner/gen_property_w3idsecurityv1_owner.go b/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/property_owner/gen_property_w3idsecurityv1_owner.go new file mode 100644 index 000000000..c4a2bafb4 --- /dev/null +++ b/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/property_owner/gen_property_w3idsecurityv1_owner.go @@ -0,0 +1,181 @@ +// Code generated by astool. DO NOT EDIT. + +package propertyowner + +import ( + "fmt" + anyuri "github.com/go-fed/activity/streams/values/anyURI" + vocab "github.com/go-fed/activity/streams/vocab" + "net/url" +) + +// W3IDSecurityV1OwnerProperty is the functional property "owner". It is permitted +// to be a single nilable value type. +type W3IDSecurityV1OwnerProperty struct { + xmlschemaAnyURIMember *url.URL + unknown interface{} + alias string +} + +// DeserializeOwnerProperty creates a "owner" property from an interface +// representation that has been unmarshalled from a text or binary format. +func DeserializeOwnerProperty(m map[string]interface{}, aliasMap map[string]string) (*W3IDSecurityV1OwnerProperty, error) { + alias := "" + if a, ok := aliasMap["https://w3id.org/security/v1"]; ok { + alias = a + } + propName := "owner" + if len(alias) > 0 { + // Use alias both to find the property, and set within the property. + propName = fmt.Sprintf("%s:%s", alias, "owner") + } + i, ok := m[propName] + + if ok { + if v, err := anyuri.DeserializeAnyURI(i); err == nil { + this := &W3IDSecurityV1OwnerProperty{ + alias: alias, + xmlschemaAnyURIMember: v, + } + return this, nil + } + this := &W3IDSecurityV1OwnerProperty{ + alias: alias, + unknown: i, + } + return this, nil + } + return nil, nil +} + +// NewW3IDSecurityV1OwnerProperty creates a new owner property. +func NewW3IDSecurityV1OwnerProperty() *W3IDSecurityV1OwnerProperty { + return &W3IDSecurityV1OwnerProperty{alias: ""} +} + +// Clear ensures no value of this property is set. Calling IsXMLSchemaAnyURI +// afterwards will return false. +func (this *W3IDSecurityV1OwnerProperty) Clear() { + this.unknown = nil + this.xmlschemaAnyURIMember = nil +} + +// Get returns the value of this property. When IsXMLSchemaAnyURI returns false, +// Get will return any arbitrary value. +func (this W3IDSecurityV1OwnerProperty) Get() *url.URL { + return this.xmlschemaAnyURIMember +} + +// GetIRI returns the IRI of this property. When IsIRI returns false, GetIRI will +// return any arbitrary value. +func (this W3IDSecurityV1OwnerProperty) GetIRI() *url.URL { + return this.xmlschemaAnyURIMember +} + +// HasAny returns true if the value or IRI is set. +func (this W3IDSecurityV1OwnerProperty) HasAny() bool { + return this.IsXMLSchemaAnyURI() +} + +// IsIRI returns true if this property is an IRI. +func (this W3IDSecurityV1OwnerProperty) IsIRI() bool { + return this.xmlschemaAnyURIMember != nil +} + +// IsXMLSchemaAnyURI returns true if this property is set and not an IRI. +func (this W3IDSecurityV1OwnerProperty) IsXMLSchemaAnyURI() bool { + return this.xmlschemaAnyURIMember != nil +} + +// JSONLDContext returns the JSONLD URIs required in the context string for this +// property and the specific values that are set. The value in the map is the +// alias used to import the property's value or values. +func (this W3IDSecurityV1OwnerProperty) JSONLDContext() map[string]string { + m := map[string]string{"https://w3id.org/security/v1": this.alias} + var child map[string]string + + /* + Since the literal maps in this function are determined at + code-generation time, this loop should not overwrite an existing key with a + new value. + */ + for k, v := range child { + m[k] = v + } + return m +} + +// KindIndex computes an arbitrary value for indexing this kind of value. This is +// a leaky API detail only for folks looking to replace the go-fed +// implementation. Applications should not use this method. +func (this W3IDSecurityV1OwnerProperty) KindIndex() int { + if this.IsXMLSchemaAnyURI() { + return 0 + } + if this.IsIRI() { + return -2 + } + return -1 +} + +// LessThan compares two instances of this property with an arbitrary but stable +// comparison. Applications should not use this because it is only meant to +// help alternative implementations to go-fed to be able to normalize +// nonfunctional properties. +func (this W3IDSecurityV1OwnerProperty) LessThan(o vocab.W3IDSecurityV1OwnerProperty) bool { + if this.IsIRI() { + // IRIs are always less than other values, none, or unknowns + return true + } else if o.IsIRI() { + // This other, none, or unknown value is always greater than IRIs + return false + } + // LessThan comparison for the single value or unknown value. + if !this.IsXMLSchemaAnyURI() && !o.IsXMLSchemaAnyURI() { + // Both are unknowns. + return false + } else if this.IsXMLSchemaAnyURI() && !o.IsXMLSchemaAnyURI() { + // Values are always greater than unknown values. + return false + } else if !this.IsXMLSchemaAnyURI() && o.IsXMLSchemaAnyURI() { + // Unknowns are always less than known values. + return true + } else { + // Actual comparison. + return anyuri.LessAnyURI(this.Get(), o.Get()) + } +} + +// Name returns the name of this property: "owner". +func (this W3IDSecurityV1OwnerProperty) Name() string { + if len(this.alias) > 0 { + return this.alias + ":" + "owner" + } else { + return "owner" + } +} + +// Serialize converts this into an interface representation suitable for +// marshalling into a text or binary format. Applications should not need this +// function as most typical use cases serialize types instead of individual +// properties. It is exposed for alternatives to go-fed implementations to use. +func (this W3IDSecurityV1OwnerProperty) Serialize() (interface{}, error) { + if this.IsXMLSchemaAnyURI() { + return anyuri.SerializeAnyURI(this.Get()) + } + return this.unknown, nil +} + +// Set sets the value of this property. Calling IsXMLSchemaAnyURI afterwards will +// return true. +func (this *W3IDSecurityV1OwnerProperty) Set(v *url.URL) { + this.Clear() + this.xmlschemaAnyURIMember = v +} + +// SetIRI sets the value of this property. Calling IsIRI afterwards will return +// true. +func (this *W3IDSecurityV1OwnerProperty) SetIRI(v *url.URL) { + this.Clear() + this.Set(v) +} diff --git a/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/property_publickey/gen_doc.go b/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/property_publickey/gen_doc.go new file mode 100644 index 000000000..59947096d --- /dev/null +++ b/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/property_publickey/gen_doc.go @@ -0,0 +1,17 @@ +// Code generated by astool. DO NOT EDIT. + +// Package propertypublickey contains the implementation for the publicKey +// property. All applications are strongly encouraged to use the interface +// instead of this concrete definition. The interfaces allow applications to +// consume only the types and properties needed and be independent of the +// go-fed implementation if another alternative implementation is created. +// This package is code-generated and subject to the same license as the +// go-fed tool used to generate it. +// +// This package is independent of other types' and properties' implementations +// by having a Manager injected into it to act as a factory for the concrete +// implementations. The implementations have been generated into their own +// separate subpackages for each vocabulary. +// +// Strongly consider using the interfaces instead of this package. +package propertypublickey diff --git a/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/property_publickey/gen_pkg.go b/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/property_publickey/gen_pkg.go new file mode 100644 index 000000000..3ebfa0897 --- /dev/null +++ b/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/property_publickey/gen_pkg.go @@ -0,0 +1,22 @@ +// Code generated by astool. DO NOT EDIT. + +package propertypublickey + +import vocab "github.com/go-fed/activity/streams/vocab" + +var mgr privateManager + +// privateManager abstracts the code-generated manager that provides access to +// concrete implementations. +type privateManager interface { + // DeserializePublicKeyW3IDSecurityV1 returns the deserialization method + // for the "W3IDSecurityV1PublicKey" non-functional property in the + // vocabulary "W3IDSecurityV1" + DeserializePublicKeyW3IDSecurityV1() func(map[string]interface{}, map[string]string) (vocab.W3IDSecurityV1PublicKey, error) +} + +// SetManager sets the manager package-global variable. For internal use only, do +// not use as part of Application behavior. Must be called at golang init time. +func SetManager(m privateManager) { + mgr = m +} diff --git a/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/property_publickey/gen_property_w3idsecurityv1_publicKey.go b/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/property_publickey/gen_property_w3idsecurityv1_publicKey.go new file mode 100644 index 000000000..d88d7ac38 --- /dev/null +++ b/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/property_publickey/gen_property_w3idsecurityv1_publicKey.go @@ -0,0 +1,621 @@ +// Code generated by astool. DO NOT EDIT. + +package propertypublickey + +import ( + "fmt" + vocab "github.com/go-fed/activity/streams/vocab" + "net/url" +) + +// W3IDSecurityV1PublicKeyPropertyIterator is an iterator for a property. It is +// permitted to be a single nilable value type. +type W3IDSecurityV1PublicKeyPropertyIterator struct { + w3idsecurityv1PublicKeyMember vocab.W3IDSecurityV1PublicKey + unknown interface{} + iri *url.URL + alias string + myIdx int + parent vocab.W3IDSecurityV1PublicKeyProperty +} + +// NewW3IDSecurityV1PublicKeyPropertyIterator creates a new +// W3IDSecurityV1PublicKey property. +func NewW3IDSecurityV1PublicKeyPropertyIterator() *W3IDSecurityV1PublicKeyPropertyIterator { + return &W3IDSecurityV1PublicKeyPropertyIterator{alias: ""} +} + +// deserializeW3IDSecurityV1PublicKeyPropertyIterator creates an iterator from an +// element that has been unmarshalled from a text or binary format. +func deserializeW3IDSecurityV1PublicKeyPropertyIterator(i interface{}, aliasMap map[string]string) (*W3IDSecurityV1PublicKeyPropertyIterator, error) { + alias := "" + if a, ok := aliasMap["https://w3id.org/security/v1"]; ok { + alias = a + } + if s, ok := i.(string); ok { + u, err := url.Parse(s) + // If error exists, don't error out -- skip this and treat as unknown string ([]byte) at worst + // Also, if no scheme exists, don't treat it as a URL -- net/url is greedy + if err == nil && len(u.Scheme) > 0 { + this := &W3IDSecurityV1PublicKeyPropertyIterator{ + alias: alias, + iri: u, + } + return this, nil + } + } + if m, ok := i.(map[string]interface{}); ok { + if v, err := mgr.DeserializePublicKeyW3IDSecurityV1()(m, aliasMap); err == nil { + this := &W3IDSecurityV1PublicKeyPropertyIterator{ + alias: alias, + w3idsecurityv1PublicKeyMember: v, + } + return this, nil + } + } + this := &W3IDSecurityV1PublicKeyPropertyIterator{ + alias: alias, + unknown: i, + } + return this, nil +} + +// Get returns the value of this property. When IsW3IDSecurityV1PublicKey returns +// false, Get will return any arbitrary value. +func (this W3IDSecurityV1PublicKeyPropertyIterator) Get() vocab.W3IDSecurityV1PublicKey { + return this.w3idsecurityv1PublicKeyMember +} + +// GetIRI returns the IRI of this property. When IsIRI returns false, GetIRI will +// return any arbitrary value. +func (this W3IDSecurityV1PublicKeyPropertyIterator) GetIRI() *url.URL { + return this.iri +} + +// GetType returns the value in this property as a Type. Returns nil if the value +// is not an ActivityStreams type, such as an IRI or another value. +func (this W3IDSecurityV1PublicKeyPropertyIterator) GetType() vocab.Type { + if this.IsW3IDSecurityV1PublicKey() { + return this.Get() + } + + return nil +} + +// HasAny returns true if the value or IRI is set. +func (this W3IDSecurityV1PublicKeyPropertyIterator) HasAny() bool { + return this.IsW3IDSecurityV1PublicKey() || this.iri != nil +} + +// IsIRI returns true if this property is an IRI. +func (this W3IDSecurityV1PublicKeyPropertyIterator) IsIRI() bool { + return this.iri != nil +} + +// IsW3IDSecurityV1PublicKey returns true if this property is set and not an IRI. +func (this W3IDSecurityV1PublicKeyPropertyIterator) IsW3IDSecurityV1PublicKey() bool { + return this.w3idsecurityv1PublicKeyMember != nil +} + +// JSONLDContext returns the JSONLD URIs required in the context string for this +// property and the specific values that are set. The value in the map is the +// alias used to import the property's value or values. +func (this W3IDSecurityV1PublicKeyPropertyIterator) JSONLDContext() map[string]string { + m := map[string]string{"https://w3id.org/security/v1": this.alias} + var child map[string]string + if this.IsW3IDSecurityV1PublicKey() { + child = this.Get().JSONLDContext() + } + /* + Since the literal maps in this function are determined at + code-generation time, this loop should not overwrite an existing key with a + new value. + */ + for k, v := range child { + m[k] = v + } + return m +} + +// KindIndex computes an arbitrary value for indexing this kind of value. This is +// a leaky API detail only for folks looking to replace the go-fed +// implementation. Applications should not use this method. +func (this W3IDSecurityV1PublicKeyPropertyIterator) KindIndex() int { + if this.IsW3IDSecurityV1PublicKey() { + return 0 + } + if this.IsIRI() { + return -2 + } + return -1 +} + +// LessThan compares two instances of this property with an arbitrary but stable +// comparison. Applications should not use this because it is only meant to +// help alternative implementations to go-fed to be able to normalize +// nonfunctional properties. +func (this W3IDSecurityV1PublicKeyPropertyIterator) LessThan(o vocab.W3IDSecurityV1PublicKeyPropertyIterator) bool { + // LessThan comparison for if either or both are IRIs. + if this.IsIRI() && o.IsIRI() { + return this.iri.String() < o.GetIRI().String() + } else if this.IsIRI() { + // IRIs are always less than other values, none, or unknowns + return true + } else if o.IsIRI() { + // This other, none, or unknown value is always greater than IRIs + return false + } + // LessThan comparison for the single value or unknown value. + if !this.IsW3IDSecurityV1PublicKey() && !o.IsW3IDSecurityV1PublicKey() { + // Both are unknowns. + return false + } else if this.IsW3IDSecurityV1PublicKey() && !o.IsW3IDSecurityV1PublicKey() { + // Values are always greater than unknown values. + return false + } else if !this.IsW3IDSecurityV1PublicKey() && o.IsW3IDSecurityV1PublicKey() { + // Unknowns are always less than known values. + return true + } else { + // Actual comparison. + return this.Get().LessThan(o.Get()) + } +} + +// Name returns the name of this property: "W3IDSecurityV1PublicKey". +func (this W3IDSecurityV1PublicKeyPropertyIterator) Name() string { + if len(this.alias) > 0 { + return this.alias + ":" + "W3IDSecurityV1PublicKey" + } else { + return "W3IDSecurityV1PublicKey" + } +} + +// Next returns the next iterator, or nil if there is no next iterator. +func (this W3IDSecurityV1PublicKeyPropertyIterator) Next() vocab.W3IDSecurityV1PublicKeyPropertyIterator { + if this.myIdx+1 >= this.parent.Len() { + return nil + } else { + return this.parent.At(this.myIdx + 1) + } +} + +// Prev returns the previous iterator, or nil if there is no previous iterator. +func (this W3IDSecurityV1PublicKeyPropertyIterator) Prev() vocab.W3IDSecurityV1PublicKeyPropertyIterator { + if this.myIdx-1 < 0 { + return nil + } else { + return this.parent.At(this.myIdx - 1) + } +} + +// Set sets the value of this property. Calling IsW3IDSecurityV1PublicKey +// afterwards will return true. +func (this *W3IDSecurityV1PublicKeyPropertyIterator) Set(v vocab.W3IDSecurityV1PublicKey) { + this.clear() + this.w3idsecurityv1PublicKeyMember = v +} + +// SetIRI sets the value of this property. Calling IsIRI afterwards will return +// true. +func (this *W3IDSecurityV1PublicKeyPropertyIterator) SetIRI(v *url.URL) { + this.clear() + this.iri = v +} + +// SetType attempts to set the property for the arbitrary type. Returns an error +// if it is not a valid type to set on this property. +func (this *W3IDSecurityV1PublicKeyPropertyIterator) SetType(t vocab.Type) error { + if v, ok := t.(vocab.W3IDSecurityV1PublicKey); ok { + this.Set(v) + return nil + } + + return fmt.Errorf("illegal type to set on W3IDSecurityV1PublicKey property: %T", t) +} + +// clear ensures no value of this property is set. Calling +// IsW3IDSecurityV1PublicKey afterwards will return false. +func (this *W3IDSecurityV1PublicKeyPropertyIterator) clear() { + this.unknown = nil + this.iri = nil + this.w3idsecurityv1PublicKeyMember = nil +} + +// serialize converts this into an interface representation suitable for +// marshalling into a text or binary format. Applications should not need this +// function as most typical use cases serialize types instead of individual +// properties. It is exposed for alternatives to go-fed implementations to use. +func (this W3IDSecurityV1PublicKeyPropertyIterator) serialize() (interface{}, error) { + if this.IsW3IDSecurityV1PublicKey() { + return this.Get().Serialize() + } else if this.IsIRI() { + return this.iri.String(), nil + } + return this.unknown, nil +} + +// W3IDSecurityV1PublicKeyProperty is the non-functional property "publicKey". It +// is permitted to have one or more values, and of different value types. +type W3IDSecurityV1PublicKeyProperty struct { + properties []*W3IDSecurityV1PublicKeyPropertyIterator + alias string +} + +// DeserializePublicKeyProperty creates a "publicKey" property from an interface +// representation that has been unmarshalled from a text or binary format. +func DeserializePublicKeyProperty(m map[string]interface{}, aliasMap map[string]string) (vocab.W3IDSecurityV1PublicKeyProperty, error) { + alias := "" + if a, ok := aliasMap["https://w3id.org/security/v1"]; ok { + alias = a + } + propName := "publicKey" + if len(alias) > 0 { + propName = fmt.Sprintf("%s:%s", alias, "publicKey") + } + i, ok := m[propName] + + if ok { + this := &W3IDSecurityV1PublicKeyProperty{ + alias: alias, + properties: []*W3IDSecurityV1PublicKeyPropertyIterator{}, + } + if list, ok := i.([]interface{}); ok { + for _, iterator := range list { + if p, err := deserializeW3IDSecurityV1PublicKeyPropertyIterator(iterator, aliasMap); err != nil { + return this, err + } else if p != nil { + this.properties = append(this.properties, p) + } + } + } else { + if p, err := deserializeW3IDSecurityV1PublicKeyPropertyIterator(i, aliasMap); err != nil { + return this, err + } else if p != nil { + this.properties = append(this.properties, p) + } + } + // Set up the properties for iteration. + for idx, ele := range this.properties { + ele.parent = this + ele.myIdx = idx + } + return this, nil + } + return nil, nil +} + +// NewW3IDSecurityV1PublicKeyProperty creates a new publicKey property. +func NewW3IDSecurityV1PublicKeyProperty() *W3IDSecurityV1PublicKeyProperty { + return &W3IDSecurityV1PublicKeyProperty{alias: ""} +} + +// AppendIRI appends an IRI value to the back of a list of the property "publicKey" +func (this *W3IDSecurityV1PublicKeyProperty) AppendIRI(v *url.URL) { + this.properties = append(this.properties, &W3IDSecurityV1PublicKeyPropertyIterator{ + alias: this.alias, + iri: v, + myIdx: this.Len(), + parent: this, + }) +} + +// PrependType prepends an arbitrary type value to the front of a list of the +// property "publicKey". Invalidates iterators that are traversing using Prev. +// Returns an error if the type is not a valid one to set for this property. +func (this *W3IDSecurityV1PublicKeyProperty) AppendType(t vocab.Type) error { + n := &W3IDSecurityV1PublicKeyPropertyIterator{ + alias: this.alias, + myIdx: this.Len(), + parent: this, + } + if err := n.SetType(t); err != nil { + return err + } + this.properties = append(this.properties, n) + return nil +} + +// AppendW3IDSecurityV1PublicKey appends a PublicKey value to the back of a list +// of the property "publicKey". Invalidates iterators that are traversing +// using Prev. +func (this *W3IDSecurityV1PublicKeyProperty) AppendW3IDSecurityV1PublicKey(v vocab.W3IDSecurityV1PublicKey) { + this.properties = append(this.properties, &W3IDSecurityV1PublicKeyPropertyIterator{ + alias: this.alias, + myIdx: this.Len(), + parent: this, + w3idsecurityv1PublicKeyMember: v, + }) +} + +// At returns the property value for the specified index. Panics if the index is +// out of bounds. +func (this W3IDSecurityV1PublicKeyProperty) At(index int) vocab.W3IDSecurityV1PublicKeyPropertyIterator { + return this.properties[index] +} + +// Begin returns the first iterator, or nil if empty. Can be used with the +// iterator's Next method and this property's End method to iterate from front +// to back through all values. +func (this W3IDSecurityV1PublicKeyProperty) Begin() vocab.W3IDSecurityV1PublicKeyPropertyIterator { + if this.Empty() { + return nil + } else { + return this.properties[0] + } +} + +// Empty returns returns true if there are no elements. +func (this W3IDSecurityV1PublicKeyProperty) Empty() bool { + return this.Len() == 0 +} + +// End returns beyond-the-last iterator, which is nil. Can be used with the +// iterator's Next method and this property's Begin method to iterate from +// front to back through all values. +func (this W3IDSecurityV1PublicKeyProperty) End() vocab.W3IDSecurityV1PublicKeyPropertyIterator { + return nil +} + +// Insert inserts an IRI value at the specified index for a property "publicKey". +// Existing elements at that index and higher are shifted back once. +// Invalidates all iterators. +func (this *W3IDSecurityV1PublicKeyProperty) InsertIRI(idx int, v *url.URL) { + this.properties = append(this.properties, nil) + copy(this.properties[idx+1:], this.properties[idx:]) + this.properties[idx] = &W3IDSecurityV1PublicKeyPropertyIterator{ + alias: this.alias, + iri: v, + myIdx: idx, + parent: this, + } + for i := idx; i < this.Len(); i++ { + (this.properties)[i].myIdx = i + } +} + +// PrependType prepends an arbitrary type value to the front of a list of the +// property "publicKey". Invalidates all iterators. Returns an error if the +// type is not a valid one to set for this property. +func (this *W3IDSecurityV1PublicKeyProperty) InsertType(idx int, t vocab.Type) error { + n := &W3IDSecurityV1PublicKeyPropertyIterator{ + alias: this.alias, + myIdx: idx, + parent: this, + } + if err := n.SetType(t); err != nil { + return err + } + this.properties = append(this.properties, nil) + copy(this.properties[idx+1:], this.properties[idx:]) + this.properties[idx] = n + for i := idx; i < this.Len(); i++ { + (this.properties)[i].myIdx = i + } + return nil +} + +// InsertW3IDSecurityV1PublicKey inserts a PublicKey value at the specified index +// for a property "publicKey". Existing elements at that index and higher are +// shifted back once. Invalidates all iterators. +func (this *W3IDSecurityV1PublicKeyProperty) InsertW3IDSecurityV1PublicKey(idx int, v vocab.W3IDSecurityV1PublicKey) { + this.properties = append(this.properties, nil) + copy(this.properties[idx+1:], this.properties[idx:]) + this.properties[idx] = &W3IDSecurityV1PublicKeyPropertyIterator{ + alias: this.alias, + myIdx: idx, + parent: this, + w3idsecurityv1PublicKeyMember: v, + } + for i := idx; i < this.Len(); i++ { + (this.properties)[i].myIdx = i + } +} + +// JSONLDContext returns the JSONLD URIs required in the context string for this +// property and the specific values that are set. The value in the map is the +// alias used to import the property's value or values. +func (this W3IDSecurityV1PublicKeyProperty) JSONLDContext() map[string]string { + m := map[string]string{"https://w3id.org/security/v1": this.alias} + for _, elem := range this.properties { + child := elem.JSONLDContext() + /* + Since the literal maps in this function are determined at + code-generation time, this loop should not overwrite an existing key with a + new value. + */ + for k, v := range child { + m[k] = v + } + } + return m +} + +// KindIndex computes an arbitrary value for indexing this kind of value. This is +// a leaky API method specifically needed only for alternate implementations +// for go-fed. Applications should not use this method. Panics if the index is +// out of bounds. +func (this W3IDSecurityV1PublicKeyProperty) KindIndex(idx int) int { + return this.properties[idx].KindIndex() +} + +// Len returns the number of values that exist for the "publicKey" property. +func (this W3IDSecurityV1PublicKeyProperty) Len() (length int) { + return len(this.properties) +} + +// Less computes whether another property is less than this one. Mixing types +// results in a consistent but arbitrary ordering +func (this W3IDSecurityV1PublicKeyProperty) Less(i, j int) bool { + idx1 := this.KindIndex(i) + idx2 := this.KindIndex(j) + if idx1 < idx2 { + return true + } else if idx1 == idx2 { + if idx1 == 0 { + lhs := this.properties[i].Get() + rhs := this.properties[j].Get() + return lhs.LessThan(rhs) + } else if idx1 == -2 { + lhs := this.properties[i].GetIRI() + rhs := this.properties[j].GetIRI() + return lhs.String() < rhs.String() + } + } + return false +} + +// LessThan compares two instances of this property with an arbitrary but stable +// comparison. Applications should not use this because it is only meant to +// help alternative implementations to go-fed to be able to normalize +// nonfunctional properties. +func (this W3IDSecurityV1PublicKeyProperty) LessThan(o vocab.W3IDSecurityV1PublicKeyProperty) bool { + l1 := this.Len() + l2 := o.Len() + l := l1 + if l2 < l1 { + l = l2 + } + for i := 0; i < l; i++ { + if this.properties[i].LessThan(o.At(i)) { + return true + } else if o.At(i).LessThan(this.properties[i]) { + return false + } + } + return l1 < l2 +} + +// Name returns the name of this property ("publicKey") with any alias. +func (this W3IDSecurityV1PublicKeyProperty) Name() string { + if len(this.alias) > 0 { + return this.alias + ":" + "publicKey" + } else { + return "publicKey" + } +} + +// PrependIRI prepends an IRI value to the front of a list of the property +// "publicKey". +func (this *W3IDSecurityV1PublicKeyProperty) PrependIRI(v *url.URL) { + this.properties = append([]*W3IDSecurityV1PublicKeyPropertyIterator{{ + alias: this.alias, + iri: v, + myIdx: 0, + parent: this, + }}, this.properties...) + for i := 1; i < this.Len(); i++ { + (this.properties)[i].myIdx = i + } +} + +// PrependType prepends an arbitrary type value to the front of a list of the +// property "publicKey". Invalidates all iterators. Returns an error if the +// type is not a valid one to set for this property. +func (this *W3IDSecurityV1PublicKeyProperty) PrependType(t vocab.Type) error { + n := &W3IDSecurityV1PublicKeyPropertyIterator{ + alias: this.alias, + myIdx: 0, + parent: this, + } + if err := n.SetType(t); err != nil { + return err + } + this.properties = append([]*W3IDSecurityV1PublicKeyPropertyIterator{n}, this.properties...) + for i := 1; i < this.Len(); i++ { + (this.properties)[i].myIdx = i + } + return nil +} + +// PrependW3IDSecurityV1PublicKey prepends a PublicKey value to the front of a +// list of the property "publicKey". Invalidates all iterators. +func (this *W3IDSecurityV1PublicKeyProperty) PrependW3IDSecurityV1PublicKey(v vocab.W3IDSecurityV1PublicKey) { + this.properties = append([]*W3IDSecurityV1PublicKeyPropertyIterator{{ + alias: this.alias, + myIdx: 0, + parent: this, + w3idsecurityv1PublicKeyMember: v, + }}, this.properties...) + for i := 1; i < this.Len(); i++ { + (this.properties)[i].myIdx = i + } +} + +// Remove deletes an element at the specified index from a list of the property +// "publicKey", regardless of its type. Panics if the index is out of bounds. +// Invalidates all iterators. +func (this *W3IDSecurityV1PublicKeyProperty) Remove(idx int) { + (this.properties)[idx].parent = nil + copy((this.properties)[idx:], (this.properties)[idx+1:]) + (this.properties)[len(this.properties)-1] = &W3IDSecurityV1PublicKeyPropertyIterator{} + this.properties = (this.properties)[:len(this.properties)-1] + for i := idx; i < this.Len(); i++ { + (this.properties)[i].myIdx = i + } +} + +// Serialize converts this into an interface representation suitable for +// marshalling into a text or binary format. Applications should not need this +// function as most typical use cases serialize types instead of individual +// properties. It is exposed for alternatives to go-fed implementations to use. +func (this W3IDSecurityV1PublicKeyProperty) Serialize() (interface{}, error) { + s := make([]interface{}, 0, len(this.properties)) + for _, iterator := range this.properties { + if b, err := iterator.serialize(); err != nil { + return s, err + } else { + s = append(s, b) + } + } + // Shortcut: if serializing one value, don't return an array -- pretty sure other Fediverse software would choke on a "type" value with array, for example. + if len(s) == 1 { + return s[0], nil + } + return s, nil +} + +// Set sets a PublicKey value to be at the specified index for the property +// "publicKey". Panics if the index is out of bounds. Invalidates all +// iterators. +func (this *W3IDSecurityV1PublicKeyProperty) Set(idx int, v vocab.W3IDSecurityV1PublicKey) { + (this.properties)[idx].parent = nil + (this.properties)[idx] = &W3IDSecurityV1PublicKeyPropertyIterator{ + alias: this.alias, + myIdx: idx, + parent: this, + w3idsecurityv1PublicKeyMember: v, + } +} + +// SetIRI sets an IRI value to be at the specified index for the property +// "publicKey". Panics if the index is out of bounds. +func (this *W3IDSecurityV1PublicKeyProperty) SetIRI(idx int, v *url.URL) { + (this.properties)[idx].parent = nil + (this.properties)[idx] = &W3IDSecurityV1PublicKeyPropertyIterator{ + alias: this.alias, + iri: v, + myIdx: idx, + parent: this, + } +} + +// SetType sets an arbitrary type value to the specified index of the property +// "publicKey". Invalidates all iterators. Returns an error if the type is not +// a valid one to set for this property. Panics if the index is out of bounds. +func (this *W3IDSecurityV1PublicKeyProperty) SetType(idx int, t vocab.Type) error { + n := &W3IDSecurityV1PublicKeyPropertyIterator{ + alias: this.alias, + myIdx: idx, + parent: this, + } + if err := n.SetType(t); err != nil { + return err + } + (this.properties)[idx] = n + return nil +} + +// Swap swaps the location of values at two indices for the "publicKey" property. +func (this W3IDSecurityV1PublicKeyProperty) Swap(i, j int) { + this.properties[i], this.properties[j] = this.properties[j], this.properties[i] +} diff --git a/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/property_publickeypem/gen_doc.go b/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/property_publickeypem/gen_doc.go new file mode 100644 index 000000000..e1282c8f3 --- /dev/null +++ b/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/property_publickeypem/gen_doc.go @@ -0,0 +1,17 @@ +// Code generated by astool. DO NOT EDIT. + +// Package propertypublickeypem contains the implementation for the publicKeyPem +// property. All applications are strongly encouraged to use the interface +// instead of this concrete definition. The interfaces allow applications to +// consume only the types and properties needed and be independent of the +// go-fed implementation if another alternative implementation is created. +// This package is code-generated and subject to the same license as the +// go-fed tool used to generate it. +// +// This package is independent of other types' and properties' implementations +// by having a Manager injected into it to act as a factory for the concrete +// implementations. The implementations have been generated into their own +// separate subpackages for each vocabulary. +// +// Strongly consider using the interfaces instead of this package. +package propertypublickeypem diff --git a/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/property_publickeypem/gen_pkg.go b/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/property_publickeypem/gen_pkg.go new file mode 100644 index 000000000..764de7fa5 --- /dev/null +++ b/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/property_publickeypem/gen_pkg.go @@ -0,0 +1,15 @@ +// Code generated by astool. DO NOT EDIT. + +package propertypublickeypem + +var mgr privateManager + +// privateManager abstracts the code-generated manager that provides access to +// concrete implementations. +type privateManager interface{} + +// SetManager sets the manager package-global variable. For internal use only, do +// not use as part of Application behavior. Must be called at golang init time. +func SetManager(m privateManager) { + mgr = m +} diff --git a/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/property_publickeypem/gen_property_w3idsecurityv1_publicKeyPem.go b/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/property_publickeypem/gen_property_w3idsecurityv1_publicKeyPem.go new file mode 100644 index 000000000..fd3826d26 --- /dev/null +++ b/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/property_publickeypem/gen_property_w3idsecurityv1_publicKeyPem.go @@ -0,0 +1,204 @@ +// Code generated by astool. DO NOT EDIT. + +package propertypublickeypem + +import ( + "fmt" + string1 "github.com/go-fed/activity/streams/values/string" + vocab "github.com/go-fed/activity/streams/vocab" + "net/url" +) + +// W3IDSecurityV1PublicKeyPemProperty is the functional property "publicKeyPem". +// It is permitted to be a single default-valued value type. +type W3IDSecurityV1PublicKeyPemProperty struct { + xmlschemaStringMember string + hasStringMember bool + unknown interface{} + iri *url.URL + alias string +} + +// DeserializePublicKeyPemProperty creates a "publicKeyPem" property from an +// interface representation that has been unmarshalled from a text or binary +// format. +func DeserializePublicKeyPemProperty(m map[string]interface{}, aliasMap map[string]string) (*W3IDSecurityV1PublicKeyPemProperty, error) { + alias := "" + if a, ok := aliasMap["https://w3id.org/security/v1"]; ok { + alias = a + } + propName := "publicKeyPem" + if len(alias) > 0 { + // Use alias both to find the property, and set within the property. + propName = fmt.Sprintf("%s:%s", alias, "publicKeyPem") + } + i, ok := m[propName] + + if ok { + if s, ok := i.(string); ok { + u, err := url.Parse(s) + // If error exists, don't error out -- skip this and treat as unknown string ([]byte) at worst + // Also, if no scheme exists, don't treat it as a URL -- net/url is greedy + if err == nil && len(u.Scheme) > 0 { + this := &W3IDSecurityV1PublicKeyPemProperty{ + alias: alias, + iri: u, + } + return this, nil + } + } + if v, err := string1.DeserializeString(i); err == nil { + this := &W3IDSecurityV1PublicKeyPemProperty{ + alias: alias, + hasStringMember: true, + xmlschemaStringMember: v, + } + return this, nil + } + this := &W3IDSecurityV1PublicKeyPemProperty{ + alias: alias, + unknown: i, + } + return this, nil + } + return nil, nil +} + +// NewW3IDSecurityV1PublicKeyPemProperty creates a new publicKeyPem property. +func NewW3IDSecurityV1PublicKeyPemProperty() *W3IDSecurityV1PublicKeyPemProperty { + return &W3IDSecurityV1PublicKeyPemProperty{alias: ""} +} + +// Clear ensures no value of this property is set. Calling IsXMLSchemaString +// afterwards will return false. +func (this *W3IDSecurityV1PublicKeyPemProperty) Clear() { + this.unknown = nil + this.iri = nil + this.hasStringMember = false +} + +// Get returns the value of this property. When IsXMLSchemaString returns false, +// Get will return any arbitrary value. +func (this W3IDSecurityV1PublicKeyPemProperty) Get() string { + return this.xmlschemaStringMember +} + +// GetIRI returns the IRI of this property. When IsIRI returns false, GetIRI will +// return any arbitrary value. +func (this W3IDSecurityV1PublicKeyPemProperty) GetIRI() *url.URL { + return this.iri +} + +// HasAny returns true if the value or IRI is set. +func (this W3IDSecurityV1PublicKeyPemProperty) HasAny() bool { + return this.IsXMLSchemaString() || this.iri != nil +} + +// IsIRI returns true if this property is an IRI. +func (this W3IDSecurityV1PublicKeyPemProperty) IsIRI() bool { + return this.iri != nil +} + +// IsXMLSchemaString returns true if this property is set and not an IRI. +func (this W3IDSecurityV1PublicKeyPemProperty) IsXMLSchemaString() bool { + return this.hasStringMember +} + +// JSONLDContext returns the JSONLD URIs required in the context string for this +// property and the specific values that are set. The value in the map is the +// alias used to import the property's value or values. +func (this W3IDSecurityV1PublicKeyPemProperty) JSONLDContext() map[string]string { + m := map[string]string{"https://w3id.org/security/v1": this.alias} + var child map[string]string + + /* + Since the literal maps in this function are determined at + code-generation time, this loop should not overwrite an existing key with a + new value. + */ + for k, v := range child { + m[k] = v + } + return m +} + +// KindIndex computes an arbitrary value for indexing this kind of value. This is +// a leaky API detail only for folks looking to replace the go-fed +// implementation. Applications should not use this method. +func (this W3IDSecurityV1PublicKeyPemProperty) KindIndex() int { + if this.IsXMLSchemaString() { + return 0 + } + if this.IsIRI() { + return -2 + } + return -1 +} + +// LessThan compares two instances of this property with an arbitrary but stable +// comparison. Applications should not use this because it is only meant to +// help alternative implementations to go-fed to be able to normalize +// nonfunctional properties. +func (this W3IDSecurityV1PublicKeyPemProperty) LessThan(o vocab.W3IDSecurityV1PublicKeyPemProperty) bool { + // LessThan comparison for if either or both are IRIs. + if this.IsIRI() && o.IsIRI() { + return this.iri.String() < o.GetIRI().String() + } else if this.IsIRI() { + // IRIs are always less than other values, none, or unknowns + return true + } else if o.IsIRI() { + // This other, none, or unknown value is always greater than IRIs + return false + } + // LessThan comparison for the single value or unknown value. + if !this.IsXMLSchemaString() && !o.IsXMLSchemaString() { + // Both are unknowns. + return false + } else if this.IsXMLSchemaString() && !o.IsXMLSchemaString() { + // Values are always greater than unknown values. + return false + } else if !this.IsXMLSchemaString() && o.IsXMLSchemaString() { + // Unknowns are always less than known values. + return true + } else { + // Actual comparison. + return string1.LessString(this.Get(), o.Get()) + } +} + +// Name returns the name of this property: "publicKeyPem". +func (this W3IDSecurityV1PublicKeyPemProperty) Name() string { + if len(this.alias) > 0 { + return this.alias + ":" + "publicKeyPem" + } else { + return "publicKeyPem" + } +} + +// Serialize converts this into an interface representation suitable for +// marshalling into a text or binary format. Applications should not need this +// function as most typical use cases serialize types instead of individual +// properties. It is exposed for alternatives to go-fed implementations to use. +func (this W3IDSecurityV1PublicKeyPemProperty) Serialize() (interface{}, error) { + if this.IsXMLSchemaString() { + return string1.SerializeString(this.Get()) + } else if this.IsIRI() { + return this.iri.String(), nil + } + return this.unknown, nil +} + +// Set sets the value of this property. Calling IsXMLSchemaString afterwards will +// return true. +func (this *W3IDSecurityV1PublicKeyPemProperty) Set(v string) { + this.Clear() + this.xmlschemaStringMember = v + this.hasStringMember = true +} + +// SetIRI sets the value of this property. Calling IsIRI afterwards will return +// true. +func (this *W3IDSecurityV1PublicKeyPemProperty) SetIRI(v *url.URL) { + this.Clear() + this.iri = v +} diff --git a/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/type_publickey/gen_doc.go b/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/type_publickey/gen_doc.go new file mode 100644 index 000000000..c353f6f2f --- /dev/null +++ b/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/type_publickey/gen_doc.go @@ -0,0 +1,17 @@ +// Code generated by astool. DO NOT EDIT. + +// Package typepublickey contains the implementation for the PublicKey type. All +// applications are strongly encouraged to use the interface instead of this +// concrete definition. The interfaces allow applications to consume only the +// types and properties needed and be independent of the go-fed implementation +// if another alternative implementation is created. This package is +// code-generated and subject to the same license as the go-fed tool used to +// generate it. +// +// This package is independent of other types' and properties' implementations +// by having a Manager injected into it to act as a factory for the concrete +// implementations. The implementations have been generated into their own +// separate subpackages for each vocabulary. +// +// Strongly consider using the interfaces instead of this package. +package typepublickey diff --git a/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/type_publickey/gen_pkg.go b/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/type_publickey/gen_pkg.go new file mode 100644 index 000000000..4204375d5 --- /dev/null +++ b/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/type_publickey/gen_pkg.go @@ -0,0 +1,54 @@ +// Code generated by astool. DO NOT EDIT. + +package typepublickey + +import vocab "github.com/go-fed/activity/streams/vocab" + +var mgr privateManager + +var typePropertyConstructor func() vocab.JSONLDTypeProperty + +// privateManager abstracts the code-generated manager that provides access to +// concrete implementations. +type privateManager interface { + // DeserializeIdPropertyJSONLD returns the deserialization method for the + // "JSONLDIdProperty" non-functional property in the vocabulary + // "JSONLD" + DeserializeIdPropertyJSONLD() func(map[string]interface{}, map[string]string) (vocab.JSONLDIdProperty, error) + // DeserializeOwnerPropertyW3IDSecurityV1 returns the deserialization + // method for the "W3IDSecurityV1OwnerProperty" non-functional + // property in the vocabulary "W3IDSecurityV1" + DeserializeOwnerPropertyW3IDSecurityV1() func(map[string]interface{}, map[string]string) (vocab.W3IDSecurityV1OwnerProperty, error) + // DeserializePublicKeyPemPropertyW3IDSecurityV1 returns the + // deserialization method for the "W3IDSecurityV1PublicKeyPemProperty" + // non-functional property in the vocabulary "W3IDSecurityV1" + DeserializePublicKeyPemPropertyW3IDSecurityV1() func(map[string]interface{}, map[string]string) (vocab.W3IDSecurityV1PublicKeyPemProperty, error) +} + +// jsonldContexter is a private interface to determine the JSON-LD contexts and +// aliases needed for functional and non-functional properties. It is a helper +// interface for this implementation. +type jsonldContexter interface { + // JSONLDContext returns the JSONLD URIs required in the context string + // for this property and the specific values that are set. The value + // in the map is the alias used to import the property's value or + // values. + JSONLDContext() map[string]string +} + +// SetManager sets the manager package-global variable. For internal use only, do +// not use as part of Application behavior. Must be called at golang init time. +func SetManager(m privateManager) { + mgr = m +} + +// SetTypePropertyConstructor sets the "type" property's constructor in the +// package-global variable. For internal use only, do not use as part of +// Application behavior. Must be called at golang init time. Permits +// ActivityStreams types to correctly set their "type" property at +// construction time, so users don't have to remember to do so each time. It +// is dependency injected so other go-fed compatible implementations could +// inject their own type. +func SetTypePropertyConstructor(f func() vocab.JSONLDTypeProperty) { + typePropertyConstructor = f +} diff --git a/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/type_publickey/gen_type_w3idsecurityv1_publickey.go b/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/type_publickey/gen_type_w3idsecurityv1_publickey.go new file mode 100644 index 000000000..92c90b20d --- /dev/null +++ b/vendor/github.com/go-fed/activity/streams/impl/w3idsecurityv1/type_publickey/gen_type_w3idsecurityv1_publickey.go @@ -0,0 +1,289 @@ +// Code generated by astool. DO NOT EDIT. + +package typepublickey + +import vocab "github.com/go-fed/activity/streams/vocab" + +// A public key represents a public cryptographical key for a user +type W3IDSecurityV1PublicKey struct { + JSONLDId vocab.JSONLDIdProperty + W3IDSecurityV1Owner vocab.W3IDSecurityV1OwnerProperty + W3IDSecurityV1PublicKeyPem vocab.W3IDSecurityV1PublicKeyPemProperty + alias string + unknown map[string]interface{} +} + +// DeserializePublicKey creates a PublicKey from a map representation that has +// been unmarshalled from a text or binary format. +func DeserializePublicKey(m map[string]interface{}, aliasMap map[string]string) (*W3IDSecurityV1PublicKey, error) { + alias := "" + if a, ok := aliasMap["https://w3id.org/security/v1"]; ok { + alias = a + } + this := &W3IDSecurityV1PublicKey{ + alias: alias, + unknown: make(map[string]interface{}), + } + + // Begin: Known property deserialization + if p, err := mgr.DeserializeIdPropertyJSONLD()(m, aliasMap); err != nil { + return nil, err + } else if p != nil { + this.JSONLDId = p + } + if p, err := mgr.DeserializeOwnerPropertyW3IDSecurityV1()(m, aliasMap); err != nil { + return nil, err + } else if p != nil { + this.W3IDSecurityV1Owner = p + } + if p, err := mgr.DeserializePublicKeyPemPropertyW3IDSecurityV1()(m, aliasMap); err != nil { + return nil, err + } else if p != nil { + this.W3IDSecurityV1PublicKeyPem = p + } + // End: Known property deserialization + + // Begin: Unknown deserialization + for k, v := range m { + // Begin: Code that ensures a property name is unknown + if k == "id" { + continue + } else if k == "owner" { + continue + } else if k == "publicKeyPem" { + continue + } // End: Code that ensures a property name is unknown + + this.unknown[k] = v + } + // End: Unknown deserialization + + return this, nil +} + +// IsOrExtendsPublicKey returns true if the other provided type is the PublicKey +// type or extends from the PublicKey type. +func IsOrExtendsPublicKey(other vocab.Type) bool { + if other.GetTypeName() == "PublicKey" { + return true + } + return PublicKeyIsExtendedBy(other) +} + +// NewW3IDSecurityV1PublicKey creates a new PublicKey type +func NewW3IDSecurityV1PublicKey() *W3IDSecurityV1PublicKey { + return &W3IDSecurityV1PublicKey{ + alias: "", + unknown: make(map[string]interface{}), + } +} + +// PublicKeyIsDisjointWith returns true if the other provided type is disjoint +// with the PublicKey type. +func PublicKeyIsDisjointWith(other vocab.Type) bool { + // Shortcut implementation: is not disjoint with anything. + return false +} + +// PublicKeyIsExtendedBy returns true if the other provided type extends from the +// PublicKey type. Note that it returns false if the types are the same; see +// the "IsOrExtendsPublicKey" variant instead. +func PublicKeyIsExtendedBy(other vocab.Type) bool { + // Shortcut implementation: is not extended by anything. + return false +} + +// W3IDSecurityV1PublicKeyExtends returns true if the PublicKey type extends from +// the other type. +func W3IDSecurityV1PublicKeyExtends(other vocab.Type) bool { + // Shortcut implementation: this does not extend anything. + return false +} + +// GetJSONLDId returns the "id" property if it exists, and nil otherwise. +func (this W3IDSecurityV1PublicKey) GetJSONLDId() vocab.JSONLDIdProperty { + return this.JSONLDId +} + +// GetTypeName returns the name of this type. +func (this W3IDSecurityV1PublicKey) GetTypeName() string { + return "PublicKey" +} + +// GetUnknownProperties returns the unknown properties for the PublicKey type. +// Note that this should not be used by app developers. It is only used to +// help determine which implementation is LessThan the other. Developers who +// are creating a different implementation of this type's interface can use +// this method in their LessThan implementation, but routine ActivityPub +// applications should not use this to bypass the code generation tool. +func (this W3IDSecurityV1PublicKey) GetUnknownProperties() map[string]interface{} { + return this.unknown +} + +// GetW3IDSecurityV1Owner returns the "owner" property if it exists, and nil +// otherwise. +func (this W3IDSecurityV1PublicKey) GetW3IDSecurityV1Owner() vocab.W3IDSecurityV1OwnerProperty { + return this.W3IDSecurityV1Owner +} + +// GetW3IDSecurityV1PublicKeyPem returns the "publicKeyPem" property if it exists, +// and nil otherwise. +func (this W3IDSecurityV1PublicKey) GetW3IDSecurityV1PublicKeyPem() vocab.W3IDSecurityV1PublicKeyPemProperty { + return this.W3IDSecurityV1PublicKeyPem +} + +// IsExtending returns true if the PublicKey type extends from the other type. +func (this W3IDSecurityV1PublicKey) IsExtending(other vocab.Type) bool { + return W3IDSecurityV1PublicKeyExtends(other) +} + +// JSONLDContext returns the JSONLD URIs required in the context string for this +// type and the specific properties that are set. The value in the map is the +// alias used to import the type and its properties. +func (this W3IDSecurityV1PublicKey) JSONLDContext() map[string]string { + m := map[string]string{"https://w3id.org/security/v1": this.alias} + m = this.helperJSONLDContext(this.JSONLDId, m) + m = this.helperJSONLDContext(this.W3IDSecurityV1Owner, m) + m = this.helperJSONLDContext(this.W3IDSecurityV1PublicKeyPem, m) + + return m +} + +// LessThan computes if this PublicKey is lesser, with an arbitrary but stable +// determination. +func (this W3IDSecurityV1PublicKey) LessThan(o vocab.W3IDSecurityV1PublicKey) bool { + // Begin: Compare known properties + // Compare property "id" + if lhs, rhs := this.JSONLDId, o.GetJSONLDId(); lhs != nil && rhs != nil { + if lhs.LessThan(rhs) { + return true + } else if rhs.LessThan(lhs) { + return false + } + } else if lhs == nil && rhs != nil { + // Nil is less than anything else + return true + } else if rhs != nil && rhs == nil { + // Anything else is greater than nil + return false + } // Else: Both are nil + // Compare property "owner" + if lhs, rhs := this.W3IDSecurityV1Owner, o.GetW3IDSecurityV1Owner(); lhs != nil && rhs != nil { + if lhs.LessThan(rhs) { + return true + } else if rhs.LessThan(lhs) { + return false + } + } else if lhs == nil && rhs != nil { + // Nil is less than anything else + return true + } else if rhs != nil && rhs == nil { + // Anything else is greater than nil + return false + } // Else: Both are nil + // Compare property "publicKeyPem" + if lhs, rhs := this.W3IDSecurityV1PublicKeyPem, o.GetW3IDSecurityV1PublicKeyPem(); lhs != nil && rhs != nil { + if lhs.LessThan(rhs) { + return true + } else if rhs.LessThan(lhs) { + return false + } + } else if lhs == nil && rhs != nil { + // Nil is less than anything else + return true + } else if rhs != nil && rhs == nil { + // Anything else is greater than nil + return false + } // Else: Both are nil + // End: Compare known properties + + // Begin: Compare unknown properties (only by number of them) + if len(this.unknown) < len(o.GetUnknownProperties()) { + return true + } else if len(o.GetUnknownProperties()) < len(this.unknown) { + return false + } // End: Compare unknown properties (only by number of them) + + // All properties are the same. + return false +} + +// Serialize converts this into an interface representation suitable for +// marshalling into a text or binary format. +func (this W3IDSecurityV1PublicKey) Serialize() (map[string]interface{}, error) { + m := make(map[string]interface{}) + // Begin: Serialize known properties + // Maybe serialize property "id" + if this.JSONLDId != nil { + if i, err := this.JSONLDId.Serialize(); err != nil { + return nil, err + } else if i != nil { + m[this.JSONLDId.Name()] = i + } + } + // Maybe serialize property "owner" + if this.W3IDSecurityV1Owner != nil { + if i, err := this.W3IDSecurityV1Owner.Serialize(); err != nil { + return nil, err + } else if i != nil { + m[this.W3IDSecurityV1Owner.Name()] = i + } + } + // Maybe serialize property "publicKeyPem" + if this.W3IDSecurityV1PublicKeyPem != nil { + if i, err := this.W3IDSecurityV1PublicKeyPem.Serialize(); err != nil { + return nil, err + } else if i != nil { + m[this.W3IDSecurityV1PublicKeyPem.Name()] = i + } + } + // End: Serialize known properties + + // Begin: Serialize unknown properties + for k, v := range this.unknown { + // To be safe, ensure we aren't overwriting a known property + if _, has := m[k]; !has { + m[k] = v + } + } + // End: Serialize unknown properties + + return m, nil +} + +// SetJSONLDId sets the "id" property. +func (this *W3IDSecurityV1PublicKey) SetJSONLDId(i vocab.JSONLDIdProperty) { + this.JSONLDId = i +} + +// SetW3IDSecurityV1Owner sets the "owner" property. +func (this *W3IDSecurityV1PublicKey) SetW3IDSecurityV1Owner(i vocab.W3IDSecurityV1OwnerProperty) { + this.W3IDSecurityV1Owner = i +} + +// SetW3IDSecurityV1PublicKeyPem sets the "publicKeyPem" property. +func (this *W3IDSecurityV1PublicKey) SetW3IDSecurityV1PublicKeyPem(i vocab.W3IDSecurityV1PublicKeyPemProperty) { + this.W3IDSecurityV1PublicKeyPem = i +} + +// VocabularyURI returns the vocabulary's URI as a string. +func (this W3IDSecurityV1PublicKey) VocabularyURI() string { + return "https://w3id.org/security/v1" +} + +// helperJSONLDContext obtains the context uris and their aliases from a property, +// if it is not nil. +func (this W3IDSecurityV1PublicKey) helperJSONLDContext(i jsonldContexter, toMerge map[string]string) map[string]string { + if i == nil { + return toMerge + } + for k, v := range i.JSONLDContext() { + /* + Since the literal maps in this function are determined at + code-generation time, this loop should not overwrite an existing key with a + new value. + */ + toMerge[k] = v + } + return toMerge +} |