mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-10-19 08:42:38 +02:00
98263a7de6
* 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
939 lines
36 KiB
Go
939 lines
36 KiB
Go
// Code generated by astool. DO NOT EDIT.
|
|
|
|
package propertystreams
|
|
|
|
import (
|
|
"fmt"
|
|
vocab "github.com/go-fed/activity/streams/vocab"
|
|
"net/url"
|
|
)
|
|
|
|
// ActivityStreamsStreamsPropertyIterator is an iterator for a property. It is
|
|
// permitted to be one of multiple value types. At most, one type of value can
|
|
// be present, or none at all. Setting a value will clear the other types of
|
|
// values so that only one of the 'Is' methods will return true. It is
|
|
// possible to clear all values, so that this property is empty.
|
|
type ActivityStreamsStreamsPropertyIterator struct {
|
|
activitystreamsOrderedCollectionMember vocab.ActivityStreamsOrderedCollection
|
|
activitystreamsCollectionMember vocab.ActivityStreamsCollection
|
|
activitystreamsCollectionPageMember vocab.ActivityStreamsCollectionPage
|
|
activitystreamsOrderedCollectionPageMember vocab.ActivityStreamsOrderedCollectionPage
|
|
unknown interface{}
|
|
iri *url.URL
|
|
alias string
|
|
myIdx int
|
|
parent vocab.ActivityStreamsStreamsProperty
|
|
}
|
|
|
|
// NewActivityStreamsStreamsPropertyIterator creates a new ActivityStreamsStreams
|
|
// property.
|
|
func NewActivityStreamsStreamsPropertyIterator() *ActivityStreamsStreamsPropertyIterator {
|
|
return &ActivityStreamsStreamsPropertyIterator{alias: ""}
|
|
}
|
|
|
|
// deserializeActivityStreamsStreamsPropertyIterator creates an iterator from an
|
|
// element that has been unmarshalled from a text or binary format.
|
|
func deserializeActivityStreamsStreamsPropertyIterator(i interface{}, aliasMap map[string]string) (*ActivityStreamsStreamsPropertyIterator, error) {
|
|
alias := ""
|
|
if a, ok := aliasMap["https://www.w3.org/ns/activitystreams"]; 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 := &ActivityStreamsStreamsPropertyIterator{
|
|
alias: alias,
|
|
iri: u,
|
|
}
|
|
return this, nil
|
|
}
|
|
}
|
|
if m, ok := i.(map[string]interface{}); ok {
|
|
if v, err := mgr.DeserializeOrderedCollectionActivityStreams()(m, aliasMap); err == nil {
|
|
this := &ActivityStreamsStreamsPropertyIterator{
|
|
activitystreamsOrderedCollectionMember: v,
|
|
alias: alias,
|
|
}
|
|
return this, nil
|
|
} else if v, err := mgr.DeserializeCollectionActivityStreams()(m, aliasMap); err == nil {
|
|
this := &ActivityStreamsStreamsPropertyIterator{
|
|
activitystreamsCollectionMember: v,
|
|
alias: alias,
|
|
}
|
|
return this, nil
|
|
} else if v, err := mgr.DeserializeCollectionPageActivityStreams()(m, aliasMap); err == nil {
|
|
this := &ActivityStreamsStreamsPropertyIterator{
|
|
activitystreamsCollectionPageMember: v,
|
|
alias: alias,
|
|
}
|
|
return this, nil
|
|
} else if v, err := mgr.DeserializeOrderedCollectionPageActivityStreams()(m, aliasMap); err == nil {
|
|
this := &ActivityStreamsStreamsPropertyIterator{
|
|
activitystreamsOrderedCollectionPageMember: v,
|
|
alias: alias,
|
|
}
|
|
return this, nil
|
|
}
|
|
}
|
|
this := &ActivityStreamsStreamsPropertyIterator{
|
|
alias: alias,
|
|
unknown: i,
|
|
}
|
|
return this, nil
|
|
}
|
|
|
|
// GetActivityStreamsCollection returns the value of this property. When
|
|
// IsActivityStreamsCollection returns false, GetActivityStreamsCollection
|
|
// will return an arbitrary value.
|
|
func (this ActivityStreamsStreamsPropertyIterator) GetActivityStreamsCollection() vocab.ActivityStreamsCollection {
|
|
return this.activitystreamsCollectionMember
|
|
}
|
|
|
|
// GetActivityStreamsCollectionPage returns the value of this property. When
|
|
// IsActivityStreamsCollectionPage returns false,
|
|
// GetActivityStreamsCollectionPage will return an arbitrary value.
|
|
func (this ActivityStreamsStreamsPropertyIterator) GetActivityStreamsCollectionPage() vocab.ActivityStreamsCollectionPage {
|
|
return this.activitystreamsCollectionPageMember
|
|
}
|
|
|
|
// GetActivityStreamsOrderedCollection returns the value of this property. When
|
|
// IsActivityStreamsOrderedCollection returns false,
|
|
// GetActivityStreamsOrderedCollection will return an arbitrary value.
|
|
func (this ActivityStreamsStreamsPropertyIterator) GetActivityStreamsOrderedCollection() vocab.ActivityStreamsOrderedCollection {
|
|
return this.activitystreamsOrderedCollectionMember
|
|
}
|
|
|
|
// GetActivityStreamsOrderedCollectionPage returns the value of this property.
|
|
// When IsActivityStreamsOrderedCollectionPage returns false,
|
|
// GetActivityStreamsOrderedCollectionPage will return an arbitrary value.
|
|
func (this ActivityStreamsStreamsPropertyIterator) GetActivityStreamsOrderedCollectionPage() vocab.ActivityStreamsOrderedCollectionPage {
|
|
return this.activitystreamsOrderedCollectionPageMember
|
|
}
|
|
|
|
// GetIRI returns the IRI of this property. When IsIRI returns false, GetIRI will
|
|
// return an arbitrary value.
|
|
func (this ActivityStreamsStreamsPropertyIterator) 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 ActivityStreamsStreamsPropertyIterator) GetType() vocab.Type {
|
|
if this.IsActivityStreamsOrderedCollection() {
|
|
return this.GetActivityStreamsOrderedCollection()
|
|
}
|
|
if this.IsActivityStreamsCollection() {
|
|
return this.GetActivityStreamsCollection()
|
|
}
|
|
if this.IsActivityStreamsCollectionPage() {
|
|
return this.GetActivityStreamsCollectionPage()
|
|
}
|
|
if this.IsActivityStreamsOrderedCollectionPage() {
|
|
return this.GetActivityStreamsOrderedCollectionPage()
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// HasAny returns true if any of the different values is set.
|
|
func (this ActivityStreamsStreamsPropertyIterator) HasAny() bool {
|
|
return this.IsActivityStreamsOrderedCollection() ||
|
|
this.IsActivityStreamsCollection() ||
|
|
this.IsActivityStreamsCollectionPage() ||
|
|
this.IsActivityStreamsOrderedCollectionPage() ||
|
|
this.iri != nil
|
|
}
|
|
|
|
// IsActivityStreamsCollection returns true if this property has a type of
|
|
// "Collection". When true, use the GetActivityStreamsCollection and
|
|
// SetActivityStreamsCollection methods to access and set this property.
|
|
func (this ActivityStreamsStreamsPropertyIterator) IsActivityStreamsCollection() bool {
|
|
return this.activitystreamsCollectionMember != nil
|
|
}
|
|
|
|
// IsActivityStreamsCollectionPage returns true if this property has a type of
|
|
// "CollectionPage". When true, use the GetActivityStreamsCollectionPage and
|
|
// SetActivityStreamsCollectionPage methods to access and set this property.
|
|
func (this ActivityStreamsStreamsPropertyIterator) IsActivityStreamsCollectionPage() bool {
|
|
return this.activitystreamsCollectionPageMember != nil
|
|
}
|
|
|
|
// IsActivityStreamsOrderedCollection returns true if this property has a type of
|
|
// "OrderedCollection". When true, use the GetActivityStreamsOrderedCollection
|
|
// and SetActivityStreamsOrderedCollection methods to access and set this
|
|
// property.
|
|
func (this ActivityStreamsStreamsPropertyIterator) IsActivityStreamsOrderedCollection() bool {
|
|
return this.activitystreamsOrderedCollectionMember != nil
|
|
}
|
|
|
|
// IsActivityStreamsOrderedCollectionPage returns true if this property has a type
|
|
// of "OrderedCollectionPage". When true, use the
|
|
// GetActivityStreamsOrderedCollectionPage and
|
|
// SetActivityStreamsOrderedCollectionPage methods to access and set this
|
|
// property.
|
|
func (this ActivityStreamsStreamsPropertyIterator) IsActivityStreamsOrderedCollectionPage() bool {
|
|
return this.activitystreamsOrderedCollectionPageMember != nil
|
|
}
|
|
|
|
// IsIRI returns true if this property is an IRI. When true, use GetIRI and SetIRI
|
|
// to access and set this property
|
|
func (this ActivityStreamsStreamsPropertyIterator) IsIRI() bool {
|
|
return this.iri != 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 ActivityStreamsStreamsPropertyIterator) JSONLDContext() map[string]string {
|
|
m := map[string]string{"https://www.w3.org/ns/activitystreams": this.alias}
|
|
var child map[string]string
|
|
if this.IsActivityStreamsOrderedCollection() {
|
|
child = this.GetActivityStreamsOrderedCollection().JSONLDContext()
|
|
} else if this.IsActivityStreamsCollection() {
|
|
child = this.GetActivityStreamsCollection().JSONLDContext()
|
|
} else if this.IsActivityStreamsCollectionPage() {
|
|
child = this.GetActivityStreamsCollectionPage().JSONLDContext()
|
|
} else if this.IsActivityStreamsOrderedCollectionPage() {
|
|
child = this.GetActivityStreamsOrderedCollectionPage().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 ActivityStreamsStreamsPropertyIterator) KindIndex() int {
|
|
if this.IsActivityStreamsOrderedCollection() {
|
|
return 0
|
|
}
|
|
if this.IsActivityStreamsCollection() {
|
|
return 1
|
|
}
|
|
if this.IsActivityStreamsCollectionPage() {
|
|
return 2
|
|
}
|
|
if this.IsActivityStreamsOrderedCollectionPage() {
|
|
return 3
|
|
}
|
|
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 ActivityStreamsStreamsPropertyIterator) LessThan(o vocab.ActivityStreamsStreamsPropertyIterator) bool {
|
|
idx1 := this.KindIndex()
|
|
idx2 := o.KindIndex()
|
|
if idx1 < idx2 {
|
|
return true
|
|
} else if idx1 > idx2 {
|
|
return false
|
|
} else if this.IsActivityStreamsOrderedCollection() {
|
|
return this.GetActivityStreamsOrderedCollection().LessThan(o.GetActivityStreamsOrderedCollection())
|
|
} else if this.IsActivityStreamsCollection() {
|
|
return this.GetActivityStreamsCollection().LessThan(o.GetActivityStreamsCollection())
|
|
} else if this.IsActivityStreamsCollectionPage() {
|
|
return this.GetActivityStreamsCollectionPage().LessThan(o.GetActivityStreamsCollectionPage())
|
|
} else if this.IsActivityStreamsOrderedCollectionPage() {
|
|
return this.GetActivityStreamsOrderedCollectionPage().LessThan(o.GetActivityStreamsOrderedCollectionPage())
|
|
} else if this.IsIRI() {
|
|
return this.iri.String() < o.GetIRI().String()
|
|
}
|
|
return false
|
|
}
|
|
|
|
// Name returns the name of this property: "ActivityStreamsStreams".
|
|
func (this ActivityStreamsStreamsPropertyIterator) Name() string {
|
|
if len(this.alias) > 0 {
|
|
return this.alias + ":" + "ActivityStreamsStreams"
|
|
} else {
|
|
return "ActivityStreamsStreams"
|
|
}
|
|
}
|
|
|
|
// Next returns the next iterator, or nil if there is no next iterator.
|
|
func (this ActivityStreamsStreamsPropertyIterator) Next() vocab.ActivityStreamsStreamsPropertyIterator {
|
|
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 ActivityStreamsStreamsPropertyIterator) Prev() vocab.ActivityStreamsStreamsPropertyIterator {
|
|
if this.myIdx-1 < 0 {
|
|
return nil
|
|
} else {
|
|
return this.parent.At(this.myIdx - 1)
|
|
}
|
|
}
|
|
|
|
// SetActivityStreamsCollection sets the value of this property. Calling
|
|
// IsActivityStreamsCollection afterwards returns true.
|
|
func (this *ActivityStreamsStreamsPropertyIterator) SetActivityStreamsCollection(v vocab.ActivityStreamsCollection) {
|
|
this.clear()
|
|
this.activitystreamsCollectionMember = v
|
|
}
|
|
|
|
// SetActivityStreamsCollectionPage sets the value of this property. Calling
|
|
// IsActivityStreamsCollectionPage afterwards returns true.
|
|
func (this *ActivityStreamsStreamsPropertyIterator) SetActivityStreamsCollectionPage(v vocab.ActivityStreamsCollectionPage) {
|
|
this.clear()
|
|
this.activitystreamsCollectionPageMember = v
|
|
}
|
|
|
|
// SetActivityStreamsOrderedCollection sets the value of this property. Calling
|
|
// IsActivityStreamsOrderedCollection afterwards returns true.
|
|
func (this *ActivityStreamsStreamsPropertyIterator) SetActivityStreamsOrderedCollection(v vocab.ActivityStreamsOrderedCollection) {
|
|
this.clear()
|
|
this.activitystreamsOrderedCollectionMember = v
|
|
}
|
|
|
|
// SetActivityStreamsOrderedCollectionPage sets the value of this property.
|
|
// Calling IsActivityStreamsOrderedCollectionPage afterwards returns true.
|
|
func (this *ActivityStreamsStreamsPropertyIterator) SetActivityStreamsOrderedCollectionPage(v vocab.ActivityStreamsOrderedCollectionPage) {
|
|
this.clear()
|
|
this.activitystreamsOrderedCollectionPageMember = v
|
|
}
|
|
|
|
// SetIRI sets the value of this property. Calling IsIRI afterwards returns true.
|
|
func (this *ActivityStreamsStreamsPropertyIterator) 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 *ActivityStreamsStreamsPropertyIterator) SetType(t vocab.Type) error {
|
|
if v, ok := t.(vocab.ActivityStreamsOrderedCollection); ok {
|
|
this.SetActivityStreamsOrderedCollection(v)
|
|
return nil
|
|
}
|
|
if v, ok := t.(vocab.ActivityStreamsCollection); ok {
|
|
this.SetActivityStreamsCollection(v)
|
|
return nil
|
|
}
|
|
if v, ok := t.(vocab.ActivityStreamsCollectionPage); ok {
|
|
this.SetActivityStreamsCollectionPage(v)
|
|
return nil
|
|
}
|
|
if v, ok := t.(vocab.ActivityStreamsOrderedCollectionPage); ok {
|
|
this.SetActivityStreamsOrderedCollectionPage(v)
|
|
return nil
|
|
}
|
|
|
|
return fmt.Errorf("illegal type to set on ActivityStreamsStreams property: %T", t)
|
|
}
|
|
|
|
// clear ensures no value of this property is set. Calling HasAny or any of the
|
|
// 'Is' methods afterwards will return false.
|
|
func (this *ActivityStreamsStreamsPropertyIterator) clear() {
|
|
this.activitystreamsOrderedCollectionMember = nil
|
|
this.activitystreamsCollectionMember = nil
|
|
this.activitystreamsCollectionPageMember = nil
|
|
this.activitystreamsOrderedCollectionPageMember = nil
|
|
this.unknown = nil
|
|
this.iri = 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 ActivityStreamsStreamsPropertyIterator) serialize() (interface{}, error) {
|
|
if this.IsActivityStreamsOrderedCollection() {
|
|
return this.GetActivityStreamsOrderedCollection().Serialize()
|
|
} else if this.IsActivityStreamsCollection() {
|
|
return this.GetActivityStreamsCollection().Serialize()
|
|
} else if this.IsActivityStreamsCollectionPage() {
|
|
return this.GetActivityStreamsCollectionPage().Serialize()
|
|
} else if this.IsActivityStreamsOrderedCollectionPage() {
|
|
return this.GetActivityStreamsOrderedCollectionPage().Serialize()
|
|
} else if this.IsIRI() {
|
|
return this.iri.String(), nil
|
|
}
|
|
return this.unknown, nil
|
|
}
|
|
|
|
// ActivityStreamsStreamsProperty is the non-functional property "streams". It is
|
|
// permitted to have one or more values, and of different value types.
|
|
type ActivityStreamsStreamsProperty struct {
|
|
properties []*ActivityStreamsStreamsPropertyIterator
|
|
alias string
|
|
}
|
|
|
|
// DeserializeStreamsProperty creates a "streams" property from an interface
|
|
// representation that has been unmarshalled from a text or binary format.
|
|
func DeserializeStreamsProperty(m map[string]interface{}, aliasMap map[string]string) (vocab.ActivityStreamsStreamsProperty, error) {
|
|
alias := ""
|
|
if a, ok := aliasMap["https://www.w3.org/ns/activitystreams"]; ok {
|
|
alias = a
|
|
}
|
|
propName := "streams"
|
|
if len(alias) > 0 {
|
|
propName = fmt.Sprintf("%s:%s", alias, "streams")
|
|
}
|
|
i, ok := m[propName]
|
|
|
|
if ok {
|
|
this := &ActivityStreamsStreamsProperty{
|
|
alias: alias,
|
|
properties: []*ActivityStreamsStreamsPropertyIterator{},
|
|
}
|
|
if list, ok := i.([]interface{}); ok {
|
|
for _, iterator := range list {
|
|
if p, err := deserializeActivityStreamsStreamsPropertyIterator(iterator, aliasMap); err != nil {
|
|
return this, err
|
|
} else if p != nil {
|
|
this.properties = append(this.properties, p)
|
|
}
|
|
}
|
|
} else {
|
|
if p, err := deserializeActivityStreamsStreamsPropertyIterator(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
|
|
}
|
|
|
|
// NewActivityStreamsStreamsProperty creates a new streams property.
|
|
func NewActivityStreamsStreamsProperty() *ActivityStreamsStreamsProperty {
|
|
return &ActivityStreamsStreamsProperty{alias: ""}
|
|
}
|
|
|
|
// AppendActivityStreamsCollection appends a Collection value to the back of a
|
|
// list of the property "streams". Invalidates iterators that are traversing
|
|
// using Prev.
|
|
func (this *ActivityStreamsStreamsProperty) AppendActivityStreamsCollection(v vocab.ActivityStreamsCollection) {
|
|
this.properties = append(this.properties, &ActivityStreamsStreamsPropertyIterator{
|
|
activitystreamsCollectionMember: v,
|
|
alias: this.alias,
|
|
myIdx: this.Len(),
|
|
parent: this,
|
|
})
|
|
}
|
|
|
|
// AppendActivityStreamsCollectionPage appends a CollectionPage value to the back
|
|
// of a list of the property "streams". Invalidates iterators that are
|
|
// traversing using Prev.
|
|
func (this *ActivityStreamsStreamsProperty) AppendActivityStreamsCollectionPage(v vocab.ActivityStreamsCollectionPage) {
|
|
this.properties = append(this.properties, &ActivityStreamsStreamsPropertyIterator{
|
|
activitystreamsCollectionPageMember: v,
|
|
alias: this.alias,
|
|
myIdx: this.Len(),
|
|
parent: this,
|
|
})
|
|
}
|
|
|
|
// AppendActivityStreamsOrderedCollection appends a OrderedCollection value to the
|
|
// back of a list of the property "streams". Invalidates iterators that are
|
|
// traversing using Prev.
|
|
func (this *ActivityStreamsStreamsProperty) AppendActivityStreamsOrderedCollection(v vocab.ActivityStreamsOrderedCollection) {
|
|
this.properties = append(this.properties, &ActivityStreamsStreamsPropertyIterator{
|
|
activitystreamsOrderedCollectionMember: v,
|
|
alias: this.alias,
|
|
myIdx: this.Len(),
|
|
parent: this,
|
|
})
|
|
}
|
|
|
|
// AppendActivityStreamsOrderedCollectionPage appends a OrderedCollectionPage
|
|
// value to the back of a list of the property "streams". Invalidates
|
|
// iterators that are traversing using Prev.
|
|
func (this *ActivityStreamsStreamsProperty) AppendActivityStreamsOrderedCollectionPage(v vocab.ActivityStreamsOrderedCollectionPage) {
|
|
this.properties = append(this.properties, &ActivityStreamsStreamsPropertyIterator{
|
|
activitystreamsOrderedCollectionPageMember: v,
|
|
alias: this.alias,
|
|
myIdx: this.Len(),
|
|
parent: this,
|
|
})
|
|
}
|
|
|
|
// AppendIRI appends an IRI value to the back of a list of the property "streams"
|
|
func (this *ActivityStreamsStreamsProperty) AppendIRI(v *url.URL) {
|
|
this.properties = append(this.properties, &ActivityStreamsStreamsPropertyIterator{
|
|
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 "streams". 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 *ActivityStreamsStreamsProperty) AppendType(t vocab.Type) error {
|
|
n := &ActivityStreamsStreamsPropertyIterator{
|
|
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
|
|
}
|
|
|
|
// At returns the property value for the specified index. Panics if the index is
|
|
// out of bounds.
|
|
func (this ActivityStreamsStreamsProperty) At(index int) vocab.ActivityStreamsStreamsPropertyIterator {
|
|
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 ActivityStreamsStreamsProperty) Begin() vocab.ActivityStreamsStreamsPropertyIterator {
|
|
if this.Empty() {
|
|
return nil
|
|
} else {
|
|
return this.properties[0]
|
|
}
|
|
}
|
|
|
|
// Empty returns returns true if there are no elements.
|
|
func (this ActivityStreamsStreamsProperty) 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 ActivityStreamsStreamsProperty) End() vocab.ActivityStreamsStreamsPropertyIterator {
|
|
return nil
|
|
}
|
|
|
|
// InsertActivityStreamsCollection inserts a Collection value at the specified
|
|
// index for a property "streams". Existing elements at that index and higher
|
|
// are shifted back once. Invalidates all iterators.
|
|
func (this *ActivityStreamsStreamsProperty) InsertActivityStreamsCollection(idx int, v vocab.ActivityStreamsCollection) {
|
|
this.properties = append(this.properties, nil)
|
|
copy(this.properties[idx+1:], this.properties[idx:])
|
|
this.properties[idx] = &ActivityStreamsStreamsPropertyIterator{
|
|
activitystreamsCollectionMember: v,
|
|
alias: this.alias,
|
|
myIdx: idx,
|
|
parent: this,
|
|
}
|
|
for i := idx; i < this.Len(); i++ {
|
|
(this.properties)[i].myIdx = i
|
|
}
|
|
}
|
|
|
|
// InsertActivityStreamsCollectionPage inserts a CollectionPage value at the
|
|
// specified index for a property "streams". Existing elements at that index
|
|
// and higher are shifted back once. Invalidates all iterators.
|
|
func (this *ActivityStreamsStreamsProperty) InsertActivityStreamsCollectionPage(idx int, v vocab.ActivityStreamsCollectionPage) {
|
|
this.properties = append(this.properties, nil)
|
|
copy(this.properties[idx+1:], this.properties[idx:])
|
|
this.properties[idx] = &ActivityStreamsStreamsPropertyIterator{
|
|
activitystreamsCollectionPageMember: v,
|
|
alias: this.alias,
|
|
myIdx: idx,
|
|
parent: this,
|
|
}
|
|
for i := idx; i < this.Len(); i++ {
|
|
(this.properties)[i].myIdx = i
|
|
}
|
|
}
|
|
|
|
// InsertActivityStreamsOrderedCollection inserts a OrderedCollection value at the
|
|
// specified index for a property "streams". Existing elements at that index
|
|
// and higher are shifted back once. Invalidates all iterators.
|
|
func (this *ActivityStreamsStreamsProperty) InsertActivityStreamsOrderedCollection(idx int, v vocab.ActivityStreamsOrderedCollection) {
|
|
this.properties = append(this.properties, nil)
|
|
copy(this.properties[idx+1:], this.properties[idx:])
|
|
this.properties[idx] = &ActivityStreamsStreamsPropertyIterator{
|
|
activitystreamsOrderedCollectionMember: v,
|
|
alias: this.alias,
|
|
myIdx: idx,
|
|
parent: this,
|
|
}
|
|
for i := idx; i < this.Len(); i++ {
|
|
(this.properties)[i].myIdx = i
|
|
}
|
|
}
|
|
|
|
// InsertActivityStreamsOrderedCollectionPage inserts a OrderedCollectionPage
|
|
// value at the specified index for a property "streams". Existing elements at
|
|
// that index and higher are shifted back once. Invalidates all iterators.
|
|
func (this *ActivityStreamsStreamsProperty) InsertActivityStreamsOrderedCollectionPage(idx int, v vocab.ActivityStreamsOrderedCollectionPage) {
|
|
this.properties = append(this.properties, nil)
|
|
copy(this.properties[idx+1:], this.properties[idx:])
|
|
this.properties[idx] = &ActivityStreamsStreamsPropertyIterator{
|
|
activitystreamsOrderedCollectionPageMember: v,
|
|
alias: this.alias,
|
|
myIdx: idx,
|
|
parent: this,
|
|
}
|
|
for i := idx; i < this.Len(); i++ {
|
|
(this.properties)[i].myIdx = i
|
|
}
|
|
}
|
|
|
|
// Insert inserts an IRI value at the specified index for a property "streams".
|
|
// Existing elements at that index and higher are shifted back once.
|
|
// Invalidates all iterators.
|
|
func (this *ActivityStreamsStreamsProperty) InsertIRI(idx int, v *url.URL) {
|
|
this.properties = append(this.properties, nil)
|
|
copy(this.properties[idx+1:], this.properties[idx:])
|
|
this.properties[idx] = &ActivityStreamsStreamsPropertyIterator{
|
|
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 "streams". Invalidates all iterators. Returns an error if the type
|
|
// is not a valid one to set for this property.
|
|
func (this *ActivityStreamsStreamsProperty) InsertType(idx int, t vocab.Type) error {
|
|
n := &ActivityStreamsStreamsPropertyIterator{
|
|
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
|
|
}
|
|
|
|
// 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 ActivityStreamsStreamsProperty) JSONLDContext() map[string]string {
|
|
m := map[string]string{"https://www.w3.org/ns/activitystreams": 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 ActivityStreamsStreamsProperty) KindIndex(idx int) int {
|
|
return this.properties[idx].KindIndex()
|
|
}
|
|
|
|
// Len returns the number of values that exist for the "streams" property.
|
|
func (this ActivityStreamsStreamsProperty) 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 ActivityStreamsStreamsProperty) 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].GetActivityStreamsOrderedCollection()
|
|
rhs := this.properties[j].GetActivityStreamsOrderedCollection()
|
|
return lhs.LessThan(rhs)
|
|
} else if idx1 == 1 {
|
|
lhs := this.properties[i].GetActivityStreamsCollection()
|
|
rhs := this.properties[j].GetActivityStreamsCollection()
|
|
return lhs.LessThan(rhs)
|
|
} else if idx1 == 2 {
|
|
lhs := this.properties[i].GetActivityStreamsCollectionPage()
|
|
rhs := this.properties[j].GetActivityStreamsCollectionPage()
|
|
return lhs.LessThan(rhs)
|
|
} else if idx1 == 3 {
|
|
lhs := this.properties[i].GetActivityStreamsOrderedCollectionPage()
|
|
rhs := this.properties[j].GetActivityStreamsOrderedCollectionPage()
|
|
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 ActivityStreamsStreamsProperty) LessThan(o vocab.ActivityStreamsStreamsProperty) 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 ("streams") with any alias.
|
|
func (this ActivityStreamsStreamsProperty) Name() string {
|
|
if len(this.alias) > 0 {
|
|
return this.alias + ":" + "streams"
|
|
} else {
|
|
return "streams"
|
|
}
|
|
}
|
|
|
|
// PrependActivityStreamsCollection prepends a Collection value to the front of a
|
|
// list of the property "streams". Invalidates all iterators.
|
|
func (this *ActivityStreamsStreamsProperty) PrependActivityStreamsCollection(v vocab.ActivityStreamsCollection) {
|
|
this.properties = append([]*ActivityStreamsStreamsPropertyIterator{{
|
|
activitystreamsCollectionMember: v,
|
|
alias: this.alias,
|
|
myIdx: 0,
|
|
parent: this,
|
|
}}, this.properties...)
|
|
for i := 1; i < this.Len(); i++ {
|
|
(this.properties)[i].myIdx = i
|
|
}
|
|
}
|
|
|
|
// PrependActivityStreamsCollectionPage prepends a CollectionPage value to the
|
|
// front of a list of the property "streams". Invalidates all iterators.
|
|
func (this *ActivityStreamsStreamsProperty) PrependActivityStreamsCollectionPage(v vocab.ActivityStreamsCollectionPage) {
|
|
this.properties = append([]*ActivityStreamsStreamsPropertyIterator{{
|
|
activitystreamsCollectionPageMember: v,
|
|
alias: this.alias,
|
|
myIdx: 0,
|
|
parent: this,
|
|
}}, this.properties...)
|
|
for i := 1; i < this.Len(); i++ {
|
|
(this.properties)[i].myIdx = i
|
|
}
|
|
}
|
|
|
|
// PrependActivityStreamsOrderedCollection prepends a OrderedCollection value to
|
|
// the front of a list of the property "streams". Invalidates all iterators.
|
|
func (this *ActivityStreamsStreamsProperty) PrependActivityStreamsOrderedCollection(v vocab.ActivityStreamsOrderedCollection) {
|
|
this.properties = append([]*ActivityStreamsStreamsPropertyIterator{{
|
|
activitystreamsOrderedCollectionMember: v,
|
|
alias: this.alias,
|
|
myIdx: 0,
|
|
parent: this,
|
|
}}, this.properties...)
|
|
for i := 1; i < this.Len(); i++ {
|
|
(this.properties)[i].myIdx = i
|
|
}
|
|
}
|
|
|
|
// PrependActivityStreamsOrderedCollectionPage prepends a OrderedCollectionPage
|
|
// value to the front of a list of the property "streams". Invalidates all
|
|
// iterators.
|
|
func (this *ActivityStreamsStreamsProperty) PrependActivityStreamsOrderedCollectionPage(v vocab.ActivityStreamsOrderedCollectionPage) {
|
|
this.properties = append([]*ActivityStreamsStreamsPropertyIterator{{
|
|
activitystreamsOrderedCollectionPageMember: v,
|
|
alias: this.alias,
|
|
myIdx: 0,
|
|
parent: this,
|
|
}}, this.properties...)
|
|
for i := 1; i < this.Len(); i++ {
|
|
(this.properties)[i].myIdx = i
|
|
}
|
|
}
|
|
|
|
// PrependIRI prepends an IRI value to the front of a list of the property
|
|
// "streams".
|
|
func (this *ActivityStreamsStreamsProperty) PrependIRI(v *url.URL) {
|
|
this.properties = append([]*ActivityStreamsStreamsPropertyIterator{{
|
|
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 "streams". Invalidates all iterators. Returns an error if the type
|
|
// is not a valid one to set for this property.
|
|
func (this *ActivityStreamsStreamsProperty) PrependType(t vocab.Type) error {
|
|
n := &ActivityStreamsStreamsPropertyIterator{
|
|
alias: this.alias,
|
|
myIdx: 0,
|
|
parent: this,
|
|
}
|
|
if err := n.SetType(t); err != nil {
|
|
return err
|
|
}
|
|
this.properties = append([]*ActivityStreamsStreamsPropertyIterator{n}, this.properties...)
|
|
for i := 1; i < this.Len(); i++ {
|
|
(this.properties)[i].myIdx = i
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Remove deletes an element at the specified index from a list of the property
|
|
// "streams", regardless of its type. Panics if the index is out of bounds.
|
|
// Invalidates all iterators.
|
|
func (this *ActivityStreamsStreamsProperty) Remove(idx int) {
|
|
(this.properties)[idx].parent = nil
|
|
copy((this.properties)[idx:], (this.properties)[idx+1:])
|
|
(this.properties)[len(this.properties)-1] = &ActivityStreamsStreamsPropertyIterator{}
|
|
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 ActivityStreamsStreamsProperty) 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
|
|
}
|
|
|
|
// SetActivityStreamsCollection sets a Collection value to be at the specified
|
|
// index for the property "streams". Panics if the index is out of bounds.
|
|
// Invalidates all iterators.
|
|
func (this *ActivityStreamsStreamsProperty) SetActivityStreamsCollection(idx int, v vocab.ActivityStreamsCollection) {
|
|
(this.properties)[idx].parent = nil
|
|
(this.properties)[idx] = &ActivityStreamsStreamsPropertyIterator{
|
|
activitystreamsCollectionMember: v,
|
|
alias: this.alias,
|
|
myIdx: idx,
|
|
parent: this,
|
|
}
|
|
}
|
|
|
|
// SetActivityStreamsCollectionPage sets a CollectionPage value to be at the
|
|
// specified index for the property "streams". Panics if the index is out of
|
|
// bounds. Invalidates all iterators.
|
|
func (this *ActivityStreamsStreamsProperty) SetActivityStreamsCollectionPage(idx int, v vocab.ActivityStreamsCollectionPage) {
|
|
(this.properties)[idx].parent = nil
|
|
(this.properties)[idx] = &ActivityStreamsStreamsPropertyIterator{
|
|
activitystreamsCollectionPageMember: v,
|
|
alias: this.alias,
|
|
myIdx: idx,
|
|
parent: this,
|
|
}
|
|
}
|
|
|
|
// SetActivityStreamsOrderedCollection sets a OrderedCollection value to be at the
|
|
// specified index for the property "streams". Panics if the index is out of
|
|
// bounds. Invalidates all iterators.
|
|
func (this *ActivityStreamsStreamsProperty) SetActivityStreamsOrderedCollection(idx int, v vocab.ActivityStreamsOrderedCollection) {
|
|
(this.properties)[idx].parent = nil
|
|
(this.properties)[idx] = &ActivityStreamsStreamsPropertyIterator{
|
|
activitystreamsOrderedCollectionMember: v,
|
|
alias: this.alias,
|
|
myIdx: idx,
|
|
parent: this,
|
|
}
|
|
}
|
|
|
|
// SetActivityStreamsOrderedCollectionPage sets a OrderedCollectionPage value to
|
|
// be at the specified index for the property "streams". Panics if the index
|
|
// is out of bounds. Invalidates all iterators.
|
|
func (this *ActivityStreamsStreamsProperty) SetActivityStreamsOrderedCollectionPage(idx int, v vocab.ActivityStreamsOrderedCollectionPage) {
|
|
(this.properties)[idx].parent = nil
|
|
(this.properties)[idx] = &ActivityStreamsStreamsPropertyIterator{
|
|
activitystreamsOrderedCollectionPageMember: v,
|
|
alias: this.alias,
|
|
myIdx: idx,
|
|
parent: this,
|
|
}
|
|
}
|
|
|
|
// SetIRI sets an IRI value to be at the specified index for the property
|
|
// "streams". Panics if the index is out of bounds.
|
|
func (this *ActivityStreamsStreamsProperty) SetIRI(idx int, v *url.URL) {
|
|
(this.properties)[idx].parent = nil
|
|
(this.properties)[idx] = &ActivityStreamsStreamsPropertyIterator{
|
|
alias: this.alias,
|
|
iri: v,
|
|
myIdx: idx,
|
|
parent: this,
|
|
}
|
|
}
|
|
|
|
// SetType sets an arbitrary type value to the specified index of the property
|
|
// "streams". 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 *ActivityStreamsStreamsProperty) SetType(idx int, t vocab.Type) error {
|
|
n := &ActivityStreamsStreamsPropertyIterator{
|
|
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 "streams" property.
|
|
func (this ActivityStreamsStreamsProperty) Swap(i, j int) {
|
|
this.properties[i], this.properties[j] = this.properties[j], this.properties[i]
|
|
}
|