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
361 lines
14 KiB
Go
361 lines
14 KiB
Go
// Code generated by astool. DO NOT EDIT.
|
|
|
|
package propertyfollowers
|
|
|
|
import (
|
|
"fmt"
|
|
vocab "github.com/go-fed/activity/streams/vocab"
|
|
"net/url"
|
|
)
|
|
|
|
// ActivityStreamsFollowersProperty is the functional property "followers". 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 ActivityStreamsFollowersProperty struct {
|
|
activitystreamsOrderedCollectionMember vocab.ActivityStreamsOrderedCollection
|
|
activitystreamsCollectionMember vocab.ActivityStreamsCollection
|
|
activitystreamsCollectionPageMember vocab.ActivityStreamsCollectionPage
|
|
activitystreamsOrderedCollectionPageMember vocab.ActivityStreamsOrderedCollectionPage
|
|
unknown interface{}
|
|
iri *url.URL
|
|
alias string
|
|
}
|
|
|
|
// DeserializeFollowersProperty creates a "followers" property from an interface
|
|
// representation that has been unmarshalled from a text or binary format.
|
|
func DeserializeFollowersProperty(m map[string]interface{}, aliasMap map[string]string) (*ActivityStreamsFollowersProperty, error) {
|
|
alias := ""
|
|
if a, ok := aliasMap["https://www.w3.org/ns/activitystreams"]; ok {
|
|
alias = a
|
|
}
|
|
propName := "followers"
|
|
if len(alias) > 0 {
|
|
// Use alias both to find the property, and set within the property.
|
|
propName = fmt.Sprintf("%s:%s", alias, "followers")
|
|
}
|
|
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 := &ActivityStreamsFollowersProperty{
|
|
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 := &ActivityStreamsFollowersProperty{
|
|
activitystreamsOrderedCollectionMember: v,
|
|
alias: alias,
|
|
}
|
|
return this, nil
|
|
} else if v, err := mgr.DeserializeCollectionActivityStreams()(m, aliasMap); err == nil {
|
|
this := &ActivityStreamsFollowersProperty{
|
|
activitystreamsCollectionMember: v,
|
|
alias: alias,
|
|
}
|
|
return this, nil
|
|
} else if v, err := mgr.DeserializeCollectionPageActivityStreams()(m, aliasMap); err == nil {
|
|
this := &ActivityStreamsFollowersProperty{
|
|
activitystreamsCollectionPageMember: v,
|
|
alias: alias,
|
|
}
|
|
return this, nil
|
|
} else if v, err := mgr.DeserializeOrderedCollectionPageActivityStreams()(m, aliasMap); err == nil {
|
|
this := &ActivityStreamsFollowersProperty{
|
|
activitystreamsOrderedCollectionPageMember: v,
|
|
alias: alias,
|
|
}
|
|
return this, nil
|
|
}
|
|
}
|
|
this := &ActivityStreamsFollowersProperty{
|
|
alias: alias,
|
|
unknown: i,
|
|
}
|
|
return this, nil
|
|
}
|
|
return nil, nil
|
|
}
|
|
|
|
// NewActivityStreamsFollowersProperty creates a new followers property.
|
|
func NewActivityStreamsFollowersProperty() *ActivityStreamsFollowersProperty {
|
|
return &ActivityStreamsFollowersProperty{alias: ""}
|
|
}
|
|
|
|
// Clear ensures no value of this property is set. Calling HasAny or any of the
|
|
// 'Is' methods afterwards will return false.
|
|
func (this *ActivityStreamsFollowersProperty) Clear() {
|
|
this.activitystreamsOrderedCollectionMember = nil
|
|
this.activitystreamsCollectionMember = nil
|
|
this.activitystreamsCollectionPageMember = nil
|
|
this.activitystreamsOrderedCollectionPageMember = nil
|
|
this.unknown = nil
|
|
this.iri = nil
|
|
}
|
|
|
|
// GetActivityStreamsCollection returns the value of this property. When
|
|
// IsActivityStreamsCollection returns false, GetActivityStreamsCollection
|
|
// will return an arbitrary value.
|
|
func (this ActivityStreamsFollowersProperty) 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 ActivityStreamsFollowersProperty) 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 ActivityStreamsFollowersProperty) 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 ActivityStreamsFollowersProperty) 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 ActivityStreamsFollowersProperty) 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 ActivityStreamsFollowersProperty) 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 ActivityStreamsFollowersProperty) 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 ActivityStreamsFollowersProperty) 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 ActivityStreamsFollowersProperty) 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 ActivityStreamsFollowersProperty) 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 ActivityStreamsFollowersProperty) 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 ActivityStreamsFollowersProperty) 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 ActivityStreamsFollowersProperty) 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 ActivityStreamsFollowersProperty) 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 ActivityStreamsFollowersProperty) LessThan(o vocab.ActivityStreamsFollowersProperty) 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: "followers".
|
|
func (this ActivityStreamsFollowersProperty) Name() string {
|
|
if len(this.alias) > 0 {
|
|
return this.alias + ":" + "followers"
|
|
} else {
|
|
return "followers"
|
|
}
|
|
}
|
|
|
|
// 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 ActivityStreamsFollowersProperty) 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
|
|
}
|
|
|
|
// SetActivityStreamsCollection sets the value of this property. Calling
|
|
// IsActivityStreamsCollection afterwards returns true.
|
|
func (this *ActivityStreamsFollowersProperty) SetActivityStreamsCollection(v vocab.ActivityStreamsCollection) {
|
|
this.Clear()
|
|
this.activitystreamsCollectionMember = v
|
|
}
|
|
|
|
// SetActivityStreamsCollectionPage sets the value of this property. Calling
|
|
// IsActivityStreamsCollectionPage afterwards returns true.
|
|
func (this *ActivityStreamsFollowersProperty) SetActivityStreamsCollectionPage(v vocab.ActivityStreamsCollectionPage) {
|
|
this.Clear()
|
|
this.activitystreamsCollectionPageMember = v
|
|
}
|
|
|
|
// SetActivityStreamsOrderedCollection sets the value of this property. Calling
|
|
// IsActivityStreamsOrderedCollection afterwards returns true.
|
|
func (this *ActivityStreamsFollowersProperty) SetActivityStreamsOrderedCollection(v vocab.ActivityStreamsOrderedCollection) {
|
|
this.Clear()
|
|
this.activitystreamsOrderedCollectionMember = v
|
|
}
|
|
|
|
// SetActivityStreamsOrderedCollectionPage sets the value of this property.
|
|
// Calling IsActivityStreamsOrderedCollectionPage afterwards returns true.
|
|
func (this *ActivityStreamsFollowersProperty) SetActivityStreamsOrderedCollectionPage(v vocab.ActivityStreamsOrderedCollectionPage) {
|
|
this.Clear()
|
|
this.activitystreamsOrderedCollectionPageMember = v
|
|
}
|
|
|
|
// SetIRI sets the value of this property. Calling IsIRI afterwards returns true.
|
|
func (this *ActivityStreamsFollowersProperty) 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 *ActivityStreamsFollowersProperty) 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 followers property: %T", t)
|
|
}
|