Regenerate streams package with previous commit fixes.

This commit is contained in:
Cory Slep 2019-02-06 00:26:21 +01:00
parent f90d161ed1
commit 9f79250293
263 changed files with 15706 additions and 2664 deletions

View file

@ -20,6 +20,8 @@ import (
propertyduration "github.com/go-fed/activity/streams/impl/activitystreams/property_duration"
propertyendtime "github.com/go-fed/activity/streams/impl/activitystreams/property_endtime"
propertyfirst "github.com/go-fed/activity/streams/impl/activitystreams/property_first"
propertyfollowers "github.com/go-fed/activity/streams/impl/activitystreams/property_followers"
propertyfollowing "github.com/go-fed/activity/streams/impl/activitystreams/property_following"
propertyformertype "github.com/go-fed/activity/streams/impl/activitystreams/property_formertype"
propertygenerator "github.com/go-fed/activity/streams/impl/activitystreams/property_generator"
propertyheight "github.com/go-fed/activity/streams/impl/activitystreams/property_height"
@ -28,11 +30,14 @@ import (
propertyicon "github.com/go-fed/activity/streams/impl/activitystreams/property_icon"
propertyid "github.com/go-fed/activity/streams/impl/activitystreams/property_id"
propertyimage "github.com/go-fed/activity/streams/impl/activitystreams/property_image"
propertyinbox "github.com/go-fed/activity/streams/impl/activitystreams/property_inbox"
propertyinreplyto "github.com/go-fed/activity/streams/impl/activitystreams/property_inreplyto"
propertyinstrument "github.com/go-fed/activity/streams/impl/activitystreams/property_instrument"
propertyitems "github.com/go-fed/activity/streams/impl/activitystreams/property_items"
propertylast "github.com/go-fed/activity/streams/impl/activitystreams/property_last"
propertylatitude "github.com/go-fed/activity/streams/impl/activitystreams/property_latitude"
propertyliked "github.com/go-fed/activity/streams/impl/activitystreams/property_liked"
propertylikes "github.com/go-fed/activity/streams/impl/activitystreams/property_likes"
propertylocation "github.com/go-fed/activity/streams/impl/activitystreams/property_location"
propertylongitude "github.com/go-fed/activity/streams/impl/activitystreams/property_longitude"
propertymediatype "github.com/go-fed/activity/streams/impl/activitystreams/property_mediatype"
@ -41,7 +46,9 @@ import (
propertyobject "github.com/go-fed/activity/streams/impl/activitystreams/property_object"
propertyoneof "github.com/go-fed/activity/streams/impl/activitystreams/property_oneof"
propertyorigin "github.com/go-fed/activity/streams/impl/activitystreams/property_origin"
propertyoutbox "github.com/go-fed/activity/streams/impl/activitystreams/property_outbox"
propertypartof "github.com/go-fed/activity/streams/impl/activitystreams/property_partof"
propertypreferredusername "github.com/go-fed/activity/streams/impl/activitystreams/property_preferredusername"
propertyprev "github.com/go-fed/activity/streams/impl/activitystreams/property_prev"
propertypreview "github.com/go-fed/activity/streams/impl/activitystreams/property_preview"
propertypublished "github.com/go-fed/activity/streams/impl/activitystreams/property_published"
@ -50,8 +57,10 @@ import (
propertyrelationship "github.com/go-fed/activity/streams/impl/activitystreams/property_relationship"
propertyreplies "github.com/go-fed/activity/streams/impl/activitystreams/property_replies"
propertyresult "github.com/go-fed/activity/streams/impl/activitystreams/property_result"
propertyshares "github.com/go-fed/activity/streams/impl/activitystreams/property_shares"
propertystartindex "github.com/go-fed/activity/streams/impl/activitystreams/property_startindex"
propertystarttime "github.com/go-fed/activity/streams/impl/activitystreams/property_starttime"
propertystreams "github.com/go-fed/activity/streams/impl/activitystreams/property_streams"
propertysubject "github.com/go-fed/activity/streams/impl/activitystreams/property_subject"
propertysummary "github.com/go-fed/activity/streams/impl/activitystreams/property_summary"
propertytag "github.com/go-fed/activity/streams/impl/activitystreams/property_tag"
@ -151,6 +160,8 @@ func init() {
propertyduration.SetManager(mgr)
propertyendtime.SetManager(mgr)
propertyfirst.SetManager(mgr)
propertyfollowers.SetManager(mgr)
propertyfollowing.SetManager(mgr)
propertyformertype.SetManager(mgr)
propertygenerator.SetManager(mgr)
propertyheight.SetManager(mgr)
@ -159,11 +170,14 @@ func init() {
propertyicon.SetManager(mgr)
propertyid.SetManager(mgr)
propertyimage.SetManager(mgr)
propertyinbox.SetManager(mgr)
propertyinreplyto.SetManager(mgr)
propertyinstrument.SetManager(mgr)
propertyitems.SetManager(mgr)
propertylast.SetManager(mgr)
propertylatitude.SetManager(mgr)
propertyliked.SetManager(mgr)
propertylikes.SetManager(mgr)
propertylocation.SetManager(mgr)
propertylongitude.SetManager(mgr)
propertymediatype.SetManager(mgr)
@ -172,7 +186,9 @@ func init() {
propertyobject.SetManager(mgr)
propertyoneof.SetManager(mgr)
propertyorigin.SetManager(mgr)
propertyoutbox.SetManager(mgr)
propertypartof.SetManager(mgr)
propertypreferredusername.SetManager(mgr)
propertyprev.SetManager(mgr)
propertypreview.SetManager(mgr)
propertypublished.SetManager(mgr)
@ -181,8 +197,10 @@ func init() {
propertyrelationship.SetManager(mgr)
propertyreplies.SetManager(mgr)
propertyresult.SetManager(mgr)
propertyshares.SetManager(mgr)
propertystartindex.SetManager(mgr)
propertystarttime.SetManager(mgr)
propertystreams.SetManager(mgr)
propertysubject.SetManager(mgr)
propertysummary.SetManager(mgr)
propertytag.SetManager(mgr)

View file

@ -23,7 +23,7 @@ type InterfaceResolver struct {
// where TypeInterface is the code-generated interface for an ActivityStream
// type. An error is returned if a callback function does not match this
// signature.
func NewInterfaceResolver(callbacks []interface{}) (*InterfaceResolver, error) {
func NewInterfaceResolver(callbacks ...interface{}) (*InterfaceResolver, error) {
for _, cb := range callbacks {
// Each callback function must satisfy one known function signature, or else we will generate a runtime error instead of silently fail.
switch cb.(type) {

View file

@ -25,7 +25,7 @@ type JSONResolver struct {
// where TypeInterface is the code-generated interface for an ActivityStream
// type. An error is returned if a callback function does not match this
// signature.
func NewJSONResolver(callbacks []interface{}) (*JSONResolver, error) {
func NewJSONResolver(callbacks ...interface{}) (*JSONResolver, error) {
for _, cb := range callbacks {
// Each callback function must satisfy one known function signature, or else we will generate a runtime error instead of silently fail.
switch cb.(type) {

View file

@ -20,6 +20,8 @@ import (
propertyduration "github.com/go-fed/activity/streams/impl/activitystreams/property_duration"
propertyendtime "github.com/go-fed/activity/streams/impl/activitystreams/property_endtime"
propertyfirst "github.com/go-fed/activity/streams/impl/activitystreams/property_first"
propertyfollowers "github.com/go-fed/activity/streams/impl/activitystreams/property_followers"
propertyfollowing "github.com/go-fed/activity/streams/impl/activitystreams/property_following"
propertyformertype "github.com/go-fed/activity/streams/impl/activitystreams/property_formertype"
propertygenerator "github.com/go-fed/activity/streams/impl/activitystreams/property_generator"
propertyheight "github.com/go-fed/activity/streams/impl/activitystreams/property_height"
@ -28,11 +30,14 @@ import (
propertyicon "github.com/go-fed/activity/streams/impl/activitystreams/property_icon"
propertyid "github.com/go-fed/activity/streams/impl/activitystreams/property_id"
propertyimage "github.com/go-fed/activity/streams/impl/activitystreams/property_image"
propertyinbox "github.com/go-fed/activity/streams/impl/activitystreams/property_inbox"
propertyinreplyto "github.com/go-fed/activity/streams/impl/activitystreams/property_inreplyto"
propertyinstrument "github.com/go-fed/activity/streams/impl/activitystreams/property_instrument"
propertyitems "github.com/go-fed/activity/streams/impl/activitystreams/property_items"
propertylast "github.com/go-fed/activity/streams/impl/activitystreams/property_last"
propertylatitude "github.com/go-fed/activity/streams/impl/activitystreams/property_latitude"
propertyliked "github.com/go-fed/activity/streams/impl/activitystreams/property_liked"
propertylikes "github.com/go-fed/activity/streams/impl/activitystreams/property_likes"
propertylocation "github.com/go-fed/activity/streams/impl/activitystreams/property_location"
propertylongitude "github.com/go-fed/activity/streams/impl/activitystreams/property_longitude"
propertymediatype "github.com/go-fed/activity/streams/impl/activitystreams/property_mediatype"
@ -41,7 +46,9 @@ import (
propertyobject "github.com/go-fed/activity/streams/impl/activitystreams/property_object"
propertyoneof "github.com/go-fed/activity/streams/impl/activitystreams/property_oneof"
propertyorigin "github.com/go-fed/activity/streams/impl/activitystreams/property_origin"
propertyoutbox "github.com/go-fed/activity/streams/impl/activitystreams/property_outbox"
propertypartof "github.com/go-fed/activity/streams/impl/activitystreams/property_partof"
propertypreferredusername "github.com/go-fed/activity/streams/impl/activitystreams/property_preferredusername"
propertyprev "github.com/go-fed/activity/streams/impl/activitystreams/property_prev"
propertypreview "github.com/go-fed/activity/streams/impl/activitystreams/property_preview"
propertypublished "github.com/go-fed/activity/streams/impl/activitystreams/property_published"
@ -50,8 +57,10 @@ import (
propertyrelationship "github.com/go-fed/activity/streams/impl/activitystreams/property_relationship"
propertyreplies "github.com/go-fed/activity/streams/impl/activitystreams/property_replies"
propertyresult "github.com/go-fed/activity/streams/impl/activitystreams/property_result"
propertyshares "github.com/go-fed/activity/streams/impl/activitystreams/property_shares"
propertystartindex "github.com/go-fed/activity/streams/impl/activitystreams/property_startindex"
propertystarttime "github.com/go-fed/activity/streams/impl/activitystreams/property_starttime"
propertystreams "github.com/go-fed/activity/streams/impl/activitystreams/property_streams"
propertysubject "github.com/go-fed/activity/streams/impl/activitystreams/property_subject"
propertysummary "github.com/go-fed/activity/streams/impl/activitystreams/property_summary"
propertytag "github.com/go-fed/activity/streams/impl/activitystreams/property_tag"
@ -602,6 +611,32 @@ func (this Manager) DeserializeFollowActivityStreams() func(map[string]interface
}
}
// DeserializeFollowersPropertyActivityStreams returns the deserialization method
// for the "FollowersPropertyInterface" non-functional property in the
// vocabulary "ActivityStreams"
func (this Manager) DeserializeFollowersPropertyActivityStreams() func(map[string]interface{}, map[string]string) (vocab.FollowersPropertyInterface, error) {
return func(m map[string]interface{}, aliasMap map[string]string) (vocab.FollowersPropertyInterface, error) {
i, err := propertyfollowers.DeserializeFollowersProperty(m, aliasMap)
if i == nil {
return nil, err
}
return i, err
}
}
// DeserializeFollowingPropertyActivityStreams returns the deserialization method
// for the "FollowingPropertyInterface" non-functional property in the
// vocabulary "ActivityStreams"
func (this Manager) DeserializeFollowingPropertyActivityStreams() func(map[string]interface{}, map[string]string) (vocab.FollowingPropertyInterface, error) {
return func(m map[string]interface{}, aliasMap map[string]string) (vocab.FollowingPropertyInterface, error) {
i, err := propertyfollowing.DeserializeFollowingProperty(m, aliasMap)
if i == nil {
return nil, err
}
return i, err
}
}
// DeserializeFormerTypePropertyActivityStreams returns the deserialization method
// for the "FormerTypePropertyInterface" non-functional property in the
// vocabulary "ActivityStreams"
@ -756,6 +791,19 @@ func (this Manager) DeserializeInReplyToPropertyActivityStreams() func(map[strin
}
}
// DeserializeInboxPropertyActivityStreams returns the deserialization method for
// the "InboxPropertyInterface" non-functional property in the vocabulary
// "ActivityStreams"
func (this Manager) DeserializeInboxPropertyActivityStreams() func(map[string]interface{}, map[string]string) (vocab.InboxPropertyInterface, error) {
return func(m map[string]interface{}, aliasMap map[string]string) (vocab.InboxPropertyInterface, error) {
i, err := propertyinbox.DeserializeInboxProperty(m, aliasMap)
if i == nil {
return nil, err
}
return i, err
}
}
// DeserializeInstrumentPropertyActivityStreams returns the deserialization method
// for the "InstrumentPropertyInterface" non-functional property in the
// vocabulary "ActivityStreams"
@ -870,6 +918,32 @@ func (this Manager) DeserializeLikeActivityStreams() func(map[string]interface{}
}
}
// DeserializeLikedPropertyActivityStreams returns the deserialization method for
// the "LikedPropertyInterface" non-functional property in the vocabulary
// "ActivityStreams"
func (this Manager) DeserializeLikedPropertyActivityStreams() func(map[string]interface{}, map[string]string) (vocab.LikedPropertyInterface, error) {
return func(m map[string]interface{}, aliasMap map[string]string) (vocab.LikedPropertyInterface, error) {
i, err := propertyliked.DeserializeLikedProperty(m, aliasMap)
if i == nil {
return nil, err
}
return i, err
}
}
// DeserializeLikesPropertyActivityStreams returns the deserialization method for
// the "LikesPropertyInterface" non-functional property in the vocabulary
// "ActivityStreams"
func (this Manager) DeserializeLikesPropertyActivityStreams() func(map[string]interface{}, map[string]string) (vocab.LikesPropertyInterface, error) {
return func(m map[string]interface{}, aliasMap map[string]string) (vocab.LikesPropertyInterface, error) {
i, err := propertylikes.DeserializeLikesProperty(m, aliasMap)
if i == nil {
return nil, err
}
return i, err
}
}
// DeserializeLinkActivityStreams returns the deserialization method for the
// "LinkInterface" non-functional property in the vocabulary "ActivityStreams"
func (this Manager) DeserializeLinkActivityStreams() func(map[string]interface{}, map[string]string) (vocab.LinkInterface, error) {
@ -1100,6 +1174,19 @@ func (this Manager) DeserializeOriginPropertyActivityStreams() func(map[string]i
}
}
// DeserializeOutboxPropertyActivityStreams returns the deserialization method for
// the "OutboxPropertyInterface" non-functional property in the vocabulary
// "ActivityStreams"
func (this Manager) DeserializeOutboxPropertyActivityStreams() func(map[string]interface{}, map[string]string) (vocab.OutboxPropertyInterface, error) {
return func(m map[string]interface{}, aliasMap map[string]string) (vocab.OutboxPropertyInterface, error) {
i, err := propertyoutbox.DeserializeOutboxProperty(m, aliasMap)
if i == nil {
return nil, err
}
return i, err
}
}
// DeserializePageActivityStreams returns the deserialization method for the
// "PageInterface" non-functional property in the vocabulary "ActivityStreams"
func (this Manager) DeserializePageActivityStreams() func(map[string]interface{}, map[string]string) (vocab.PageInterface, error) {
@ -1150,6 +1237,19 @@ func (this Manager) DeserializePlaceActivityStreams() func(map[string]interface{
}
}
// DeserializePreferredUsernamePropertyActivityStreams returns the deserialization
// method for the "PreferredUsernamePropertyInterface" non-functional property
// in the vocabulary "ActivityStreams"
func (this Manager) DeserializePreferredUsernamePropertyActivityStreams() func(map[string]interface{}, map[string]string) (vocab.PreferredUsernamePropertyInterface, error) {
return func(m map[string]interface{}, aliasMap map[string]string) (vocab.PreferredUsernamePropertyInterface, error) {
i, err := propertypreferredusername.DeserializePreferredUsernameProperty(m, aliasMap)
if i == nil {
return nil, err
}
return i, err
}
}
// DeserializePrevPropertyActivityStreams returns the deserialization method for
// the "PrevPropertyInterface" non-functional property in the vocabulary
// "ActivityStreams"
@ -1344,6 +1444,19 @@ func (this Manager) DeserializeServiceActivityStreams() func(map[string]interfac
}
}
// DeserializeSharesPropertyActivityStreams returns the deserialization method for
// the "SharesPropertyInterface" non-functional property in the vocabulary
// "ActivityStreams"
func (this Manager) DeserializeSharesPropertyActivityStreams() func(map[string]interface{}, map[string]string) (vocab.SharesPropertyInterface, error) {
return func(m map[string]interface{}, aliasMap map[string]string) (vocab.SharesPropertyInterface, error) {
i, err := propertyshares.DeserializeSharesProperty(m, aliasMap)
if i == nil {
return nil, err
}
return i, err
}
}
// DeserializeStartIndexPropertyActivityStreams returns the deserialization method
// for the "StartIndexPropertyInterface" non-functional property in the
// vocabulary "ActivityStreams"
@ -1370,6 +1483,19 @@ func (this Manager) DeserializeStartTimePropertyActivityStreams() func(map[strin
}
}
// DeserializeStreamsPropertyActivityStreams returns the deserialization method
// for the "StreamsPropertyInterface" non-functional property in the
// vocabulary "ActivityStreams"
func (this Manager) DeserializeStreamsPropertyActivityStreams() func(map[string]interface{}, map[string]string) (vocab.StreamsPropertyInterface, error) {
return func(m map[string]interface{}, aliasMap map[string]string) (vocab.StreamsPropertyInterface, error) {
i, err := propertystreams.DeserializeStreamsProperty(m, aliasMap)
if i == nil {
return nil, err
}
return i, err
}
}
// DeserializeSubjectPropertyActivityStreams returns the deserialization method
// for the "SubjectPropertyInterface" non-functional property in the
// vocabulary "ActivityStreams"

View file

@ -20,6 +20,8 @@ import (
propertyduration "github.com/go-fed/activity/streams/impl/activitystreams/property_duration"
propertyendtime "github.com/go-fed/activity/streams/impl/activitystreams/property_endtime"
propertyfirst "github.com/go-fed/activity/streams/impl/activitystreams/property_first"
propertyfollowers "github.com/go-fed/activity/streams/impl/activitystreams/property_followers"
propertyfollowing "github.com/go-fed/activity/streams/impl/activitystreams/property_following"
propertyformertype "github.com/go-fed/activity/streams/impl/activitystreams/property_formertype"
propertygenerator "github.com/go-fed/activity/streams/impl/activitystreams/property_generator"
propertyheight "github.com/go-fed/activity/streams/impl/activitystreams/property_height"
@ -28,11 +30,14 @@ import (
propertyicon "github.com/go-fed/activity/streams/impl/activitystreams/property_icon"
propertyid "github.com/go-fed/activity/streams/impl/activitystreams/property_id"
propertyimage "github.com/go-fed/activity/streams/impl/activitystreams/property_image"
propertyinbox "github.com/go-fed/activity/streams/impl/activitystreams/property_inbox"
propertyinreplyto "github.com/go-fed/activity/streams/impl/activitystreams/property_inreplyto"
propertyinstrument "github.com/go-fed/activity/streams/impl/activitystreams/property_instrument"
propertyitems "github.com/go-fed/activity/streams/impl/activitystreams/property_items"
propertylast "github.com/go-fed/activity/streams/impl/activitystreams/property_last"
propertylatitude "github.com/go-fed/activity/streams/impl/activitystreams/property_latitude"
propertyliked "github.com/go-fed/activity/streams/impl/activitystreams/property_liked"
propertylikes "github.com/go-fed/activity/streams/impl/activitystreams/property_likes"
propertylocation "github.com/go-fed/activity/streams/impl/activitystreams/property_location"
propertylongitude "github.com/go-fed/activity/streams/impl/activitystreams/property_longitude"
propertymediatype "github.com/go-fed/activity/streams/impl/activitystreams/property_mediatype"
@ -41,7 +46,9 @@ import (
propertyobject "github.com/go-fed/activity/streams/impl/activitystreams/property_object"
propertyoneof "github.com/go-fed/activity/streams/impl/activitystreams/property_oneof"
propertyorigin "github.com/go-fed/activity/streams/impl/activitystreams/property_origin"
propertyoutbox "github.com/go-fed/activity/streams/impl/activitystreams/property_outbox"
propertypartof "github.com/go-fed/activity/streams/impl/activitystreams/property_partof"
propertypreferredusername "github.com/go-fed/activity/streams/impl/activitystreams/property_preferredusername"
propertyprev "github.com/go-fed/activity/streams/impl/activitystreams/property_prev"
propertypreview "github.com/go-fed/activity/streams/impl/activitystreams/property_preview"
propertypublished "github.com/go-fed/activity/streams/impl/activitystreams/property_published"
@ -50,8 +57,10 @@ import (
propertyrelationship "github.com/go-fed/activity/streams/impl/activitystreams/property_relationship"
propertyreplies "github.com/go-fed/activity/streams/impl/activitystreams/property_replies"
propertyresult "github.com/go-fed/activity/streams/impl/activitystreams/property_result"
propertyshares "github.com/go-fed/activity/streams/impl/activitystreams/property_shares"
propertystartindex "github.com/go-fed/activity/streams/impl/activitystreams/property_startindex"
propertystarttime "github.com/go-fed/activity/streams/impl/activitystreams/property_starttime"
propertystreams "github.com/go-fed/activity/streams/impl/activitystreams/property_streams"
propertysubject "github.com/go-fed/activity/streams/impl/activitystreams/property_subject"
propertysummary "github.com/go-fed/activity/streams/impl/activitystreams/property_summary"
propertytag "github.com/go-fed/activity/streams/impl/activitystreams/property_tag"
@ -162,6 +171,16 @@ func NewActivityStreamsFirstProperty() vocab.FirstPropertyInterface {
return propertyfirst.NewFirstProperty()
}
// NewActivityStreamsFollowersProperty creates a new FollowersPropertyInterface
func NewActivityStreamsFollowersProperty() vocab.FollowersPropertyInterface {
return propertyfollowers.NewFollowersProperty()
}
// NewActivityStreamsFollowingProperty creates a new FollowingPropertyInterface
func NewActivityStreamsFollowingProperty() vocab.FollowingPropertyInterface {
return propertyfollowing.NewFollowingProperty()
}
// NewActivityStreamsFormerTypeProperty creates a new FormerTypePropertyInterface
func NewActivityStreamsFormerTypeProperty() vocab.FormerTypePropertyInterface {
return propertyformertype.NewFormerTypeProperty()
@ -207,6 +226,11 @@ func NewActivityStreamsInReplyToProperty() vocab.InReplyToPropertyInterface {
return propertyinreplyto.NewInReplyToProperty()
}
// NewActivityStreamsInboxProperty creates a new InboxPropertyInterface
func NewActivityStreamsInboxProperty() vocab.InboxPropertyInterface {
return propertyinbox.NewInboxProperty()
}
// NewActivityStreamsInstrumentProperty creates a new InstrumentPropertyInterface
func NewActivityStreamsInstrumentProperty() vocab.InstrumentPropertyInterface {
return propertyinstrument.NewInstrumentProperty()
@ -227,6 +251,16 @@ func NewActivityStreamsLatitudeProperty() vocab.LatitudePropertyInterface {
return propertylatitude.NewLatitudeProperty()
}
// NewActivityStreamsLikedProperty creates a new LikedPropertyInterface
func NewActivityStreamsLikedProperty() vocab.LikedPropertyInterface {
return propertyliked.NewLikedProperty()
}
// NewActivityStreamsLikesProperty creates a new LikesPropertyInterface
func NewActivityStreamsLikesProperty() vocab.LikesPropertyInterface {
return propertylikes.NewLikesProperty()
}
// NewActivityStreamsLocationProperty creates a new LocationPropertyInterface
func NewActivityStreamsLocationProperty() vocab.LocationPropertyInterface {
return propertylocation.NewLocationProperty()
@ -267,11 +301,22 @@ func NewActivityStreamsOriginProperty() vocab.OriginPropertyInterface {
return propertyorigin.NewOriginProperty()
}
// NewActivityStreamsOutboxProperty creates a new OutboxPropertyInterface
func NewActivityStreamsOutboxProperty() vocab.OutboxPropertyInterface {
return propertyoutbox.NewOutboxProperty()
}
// NewActivityStreamsPartOfProperty creates a new PartOfPropertyInterface
func NewActivityStreamsPartOfProperty() vocab.PartOfPropertyInterface {
return propertypartof.NewPartOfProperty()
}
// NewActivityStreamsPreferredUsernameProperty creates a new
// PreferredUsernamePropertyInterface
func NewActivityStreamsPreferredUsernameProperty() vocab.PreferredUsernamePropertyInterface {
return propertypreferredusername.NewPreferredUsernameProperty()
}
// NewActivityStreamsPrevProperty creates a new PrevPropertyInterface
func NewActivityStreamsPrevProperty() vocab.PrevPropertyInterface {
return propertyprev.NewPrevProperty()
@ -313,6 +358,11 @@ func NewActivityStreamsResultProperty() vocab.ResultPropertyInterface {
return propertyresult.NewResultProperty()
}
// NewActivityStreamsSharesProperty creates a new SharesPropertyInterface
func NewActivityStreamsSharesProperty() vocab.SharesPropertyInterface {
return propertyshares.NewSharesProperty()
}
// NewActivityStreamsStartIndexProperty creates a new StartIndexPropertyInterface
func NewActivityStreamsStartIndexProperty() vocab.StartIndexPropertyInterface {
return propertystartindex.NewStartIndexProperty()
@ -323,6 +373,11 @@ func NewActivityStreamsStartTimeProperty() vocab.StartTimePropertyInterface {
return propertystarttime.NewStartTimeProperty()
}
// NewActivityStreamsStreamsProperty creates a new StreamsPropertyInterface
func NewActivityStreamsStreamsProperty() vocab.StreamsPropertyInterface {
return propertystreams.NewStreamsProperty()
}
// NewActivityStreamsSubjectProperty creates a new SubjectPropertyInterface
func NewActivityStreamsSubjectProperty() vocab.SubjectPropertyInterface {
return propertysubject.NewSubjectProperty()

View file

@ -22,7 +22,7 @@ type TypeResolver struct {
// where TypeInterface is the code-generated interface for an ActivityStream
// type. An error is returned if a callback function does not match this
// signature.
func NewTypeResolver(callbacks []interface{}) (*TypeResolver, error) {
func NewTypeResolver(callbacks ...interface{}) (*TypeResolver, error) {
for _, cb := range callbacks {
// Each callback function must satisfy one known function signature, or else we will generate a runtime error instead of silently fail.
switch cb.(type) {

View file

@ -12,7 +12,7 @@ import (
type AccuracyProperty struct {
floatMember float64
hasFloatMember bool
unknown []byte
unknown interface{}
iri *url.URL
alias string
}
@ -49,15 +49,12 @@ func DeserializeAccuracyProperty(m map[string]interface{}, aliasMap map[string]s
hasFloatMember: true,
}
return this, nil
} else if str, ok := i.(string); ok {
this := &AccuracyProperty{
alias: alias,
unknown: []byte(str),
}
return this, nil
} else {
return nil, fmt.Errorf("could not deserialize %q property", "accuracy")
}
this := &AccuracyProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
@ -179,7 +176,7 @@ func (this AccuracyProperty) Serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// Set sets the value of this property. Calling IsFloat afterwards will return

View file

@ -66,7 +66,7 @@ type ActorPropertyIterator struct {
UpdateMember vocab.UpdateInterface
VideoMember vocab.VideoInterface
ViewMember vocab.ViewInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
myIdx int
@ -423,13 +423,12 @@ func deserializeActorPropertyIterator(i interface{}, aliasMap map[string]string)
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &ActorPropertyIterator{
alias: alias,
unknown: []byte(str),
}
return this, nil
}
this := &ActorPropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "actor")
}
@ -2162,7 +2161,7 @@ func (this ActorPropertyIterator) serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// ActorProperty is the non-functional property "actor". It is permitted to have

View file

@ -12,7 +12,7 @@ import (
type AltitudeProperty struct {
floatMember float64
hasFloatMember bool
unknown []byte
unknown interface{}
iri *url.URL
alias string
}
@ -49,15 +49,12 @@ func DeserializeAltitudeProperty(m map[string]interface{}, aliasMap map[string]s
hasFloatMember: true,
}
return this, nil
} else if str, ok := i.(string); ok {
this := &AltitudeProperty{
alias: alias,
unknown: []byte(str),
}
return this, nil
} else {
return nil, fmt.Errorf("could not deserialize %q property", "altitude")
}
this := &AltitudeProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
@ -179,7 +176,7 @@ func (this AltitudeProperty) Serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// Set sets the value of this property. Calling IsFloat afterwards will return

View file

@ -66,7 +66,7 @@ type AnyOfPropertyIterator struct {
UpdateMember vocab.UpdateInterface
VideoMember vocab.VideoInterface
ViewMember vocab.ViewInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
myIdx int
@ -423,13 +423,12 @@ func deserializeAnyOfPropertyIterator(i interface{}, aliasMap map[string]string)
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &AnyOfPropertyIterator{
alias: alias,
unknown: []byte(str),
}
return this, nil
}
this := &AnyOfPropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "anyOf")
}
@ -2162,7 +2161,7 @@ func (this AnyOfPropertyIterator) serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// AnyOfProperty is the non-functional property "anyOf". It is permitted to have

View file

@ -66,7 +66,7 @@ type AttachmentPropertyIterator struct {
UpdateMember vocab.UpdateInterface
VideoMember vocab.VideoInterface
ViewMember vocab.ViewInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
myIdx int
@ -423,13 +423,12 @@ func deserializeAttachmentPropertyIterator(i interface{}, aliasMap map[string]st
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &AttachmentPropertyIterator{
alias: alias,
unknown: []byte(str),
}
return this, nil
}
this := &AttachmentPropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "attachment")
}
@ -2162,7 +2161,7 @@ func (this AttachmentPropertyIterator) serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// AttachmentProperty is the non-functional property "attachment". It is permitted

View file

@ -66,7 +66,7 @@ type AttributedToPropertyIterator struct {
UpdateMember vocab.UpdateInterface
VideoMember vocab.VideoInterface
ViewMember vocab.ViewInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
myIdx int
@ -423,13 +423,12 @@ func deserializeAttributedToPropertyIterator(i interface{}, aliasMap map[string]
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &AttributedToPropertyIterator{
alias: alias,
unknown: []byte(str),
}
return this, nil
}
this := &AttributedToPropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "attributedTo")
}
@ -2162,7 +2161,7 @@ func (this AttributedToPropertyIterator) serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// AttributedToProperty is the non-functional property "attributedTo". It is

View file

@ -66,7 +66,7 @@ type AudiencePropertyIterator struct {
UpdateMember vocab.UpdateInterface
VideoMember vocab.VideoInterface
ViewMember vocab.ViewInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
myIdx int
@ -423,13 +423,12 @@ func deserializeAudiencePropertyIterator(i interface{}, aliasMap map[string]stri
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &AudiencePropertyIterator{
alias: alias,
unknown: []byte(str),
}
return this, nil
}
this := &AudiencePropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "audience")
}
@ -2162,7 +2161,7 @@ func (this AudiencePropertyIterator) serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// AudienceProperty is the non-functional property "audience". It is permitted to

View file

@ -66,7 +66,7 @@ type BccPropertyIterator struct {
UpdateMember vocab.UpdateInterface
VideoMember vocab.VideoInterface
ViewMember vocab.ViewInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
myIdx int
@ -423,13 +423,12 @@ func deserializeBccPropertyIterator(i interface{}, aliasMap map[string]string) (
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &BccPropertyIterator{
alias: alias,
unknown: []byte(str),
}
return this, nil
}
this := &BccPropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "bcc")
}
@ -2162,7 +2161,7 @@ func (this BccPropertyIterator) serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// BccProperty is the non-functional property "bcc". It is permitted to have one

View file

@ -66,7 +66,7 @@ type BtoPropertyIterator struct {
UpdateMember vocab.UpdateInterface
VideoMember vocab.VideoInterface
ViewMember vocab.ViewInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
myIdx int
@ -423,13 +423,12 @@ func deserializeBtoPropertyIterator(i interface{}, aliasMap map[string]string) (
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &BtoPropertyIterator{
alias: alias,
unknown: []byte(str),
}
return this, nil
}
this := &BtoPropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "bto")
}
@ -2162,7 +2161,7 @@ func (this BtoPropertyIterator) serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// BtoProperty is the non-functional property "bto". It is permitted to have one

View file

@ -66,7 +66,7 @@ type CcPropertyIterator struct {
UpdateMember vocab.UpdateInterface
VideoMember vocab.VideoInterface
ViewMember vocab.ViewInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
myIdx int
@ -423,13 +423,12 @@ func deserializeCcPropertyIterator(i interface{}, aliasMap map[string]string) (*
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &CcPropertyIterator{
alias: alias,
unknown: []byte(str),
}
return this, nil
}
this := &CcPropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "cc")
}
@ -2162,7 +2161,7 @@ func (this CcPropertyIterator) serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// CcProperty is the non-functional property "cc". It is permitted to have one or

View file

@ -73,7 +73,7 @@ type ClosedPropertyIterator struct {
UpdateMember vocab.UpdateInterface
VideoMember vocab.VideoInterface
ViewMember vocab.ViewInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
myIdx int
@ -430,7 +430,8 @@ func deserializeClosedPropertyIterator(i interface{}, aliasMap map[string]string
}
return this, nil
}
} else if v, err := datetime.DeserializeDateTime(i); err == nil {
}
if v, err := datetime.DeserializeDateTime(i); err == nil {
this := &ClosedPropertyIterator{
alias: alias,
dateTimeMember: v,
@ -444,13 +445,12 @@ func deserializeClosedPropertyIterator(i interface{}, aliasMap map[string]string
hasBooleanMember: true,
}
return this, nil
} else if str, ok := i.(string); ok {
this := &ClosedPropertyIterator{
alias: alias,
unknown: []byte(str),
}
return this, nil
}
this := &ClosedPropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "closed")
}
@ -2241,7 +2241,7 @@ func (this ClosedPropertyIterator) serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// ClosedProperty is the non-functional property "closed". It is permitted to have

View file

@ -17,7 +17,7 @@ type ContentPropertyIterator struct {
stringMember string
hasStringMember bool
langStringMember map[string]string
unknown []byte
unknown interface{}
iri *url.URL
alias string
langMap map[string]string
@ -62,13 +62,12 @@ func deserializeContentPropertyIterator(i interface{}, aliasMap map[string]strin
langStringMember: v,
}
return this, nil
} else if str, ok := i.(string); ok {
this := &ContentPropertyIterator{
alias: alias,
unknown: []byte(str),
}
return this, nil
}
this := &ContentPropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "content")
}
@ -291,7 +290,7 @@ func (this ContentPropertyIterator) serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// ContentProperty is the non-functional property "content". It is permitted to

View file

@ -66,7 +66,7 @@ type ContextPropertyIterator struct {
UpdateMember vocab.UpdateInterface
VideoMember vocab.VideoInterface
ViewMember vocab.ViewInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
myIdx int
@ -423,13 +423,12 @@ func deserializeContextPropertyIterator(i interface{}, aliasMap map[string]strin
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &ContextPropertyIterator{
alias: alias,
unknown: []byte(str),
}
return this, nil
}
this := &ContextPropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "context")
}
@ -2162,7 +2161,7 @@ func (this ContextPropertyIterator) serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// ContextProperty is the non-functional property "context". It is permitted to

View file

@ -16,7 +16,7 @@ type CurrentProperty struct {
LinkMember vocab.LinkInterface
MentionMember vocab.MentionInterface
OrderedCollectionPageMember vocab.OrderedCollectionPageInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
}
@ -72,15 +72,12 @@ func DeserializeCurrentProperty(m map[string]interface{}, aliasMap map[string]st
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &CurrentProperty{
alias: alias,
unknown: []byte(str),
}
return this, nil
} else {
return nil, fmt.Errorf("could not deserialize %q property", "current")
}
this := &CurrentProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
@ -267,7 +264,7 @@ func (this CurrentProperty) Serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// SetCollectionPage sets the value of this property. Calling IsCollectionPage

View file

@ -13,7 +13,7 @@ import (
type DeletedProperty struct {
dateTimeMember time.Time
hasDateTimeMember bool
unknown []byte
unknown interface{}
iri *url.URL
alias string
}
@ -50,15 +50,12 @@ func DeserializeDeletedProperty(m map[string]interface{}, aliasMap map[string]st
hasDateTimeMember: true,
}
return this, nil
} else if str, ok := i.(string); ok {
this := &DeletedProperty{
alias: alias,
unknown: []byte(str),
}
return this, nil
} else {
return nil, fmt.Errorf("could not deserialize %q property", "deleted")
}
this := &DeletedProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
@ -180,7 +177,7 @@ func (this DeletedProperty) Serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// Set sets the value of this property. Calling IsDateTime afterwards will return

View file

@ -64,7 +64,7 @@ type DescribesProperty struct {
UpdateMember vocab.UpdateInterface
VideoMember vocab.VideoInterface
ViewMember vocab.ViewInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
}
@ -408,15 +408,12 @@ func DeserializeDescribesProperty(m map[string]interface{}, aliasMap map[string]
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &DescribesProperty{
alias: alias,
unknown: []byte(str),
}
return this, nil
} else {
return nil, fmt.Errorf("could not deserialize %q property", "describes")
}
this := &DescribesProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
@ -1718,7 +1715,7 @@ func (this DescribesProperty) Serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// SetAccept sets the value of this property. Calling IsAccept afterwards returns

View file

@ -13,7 +13,7 @@ import (
type DurationProperty struct {
durationMember time.Duration
hasDurationMember bool
unknown []byte
unknown interface{}
iri *url.URL
alias string
}
@ -50,15 +50,12 @@ func DeserializeDurationProperty(m map[string]interface{}, aliasMap map[string]s
hasDurationMember: true,
}
return this, nil
} else if str, ok := i.(string); ok {
this := &DurationProperty{
alias: alias,
unknown: []byte(str),
}
return this, nil
} else {
return nil, fmt.Errorf("could not deserialize %q property", "duration")
}
this := &DurationProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
@ -180,7 +177,7 @@ func (this DurationProperty) Serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// Set sets the value of this property. Calling IsDuration afterwards will return

View file

@ -13,7 +13,7 @@ import (
type EndTimeProperty struct {
dateTimeMember time.Time
hasDateTimeMember bool
unknown []byte
unknown interface{}
iri *url.URL
alias string
}
@ -50,15 +50,12 @@ func DeserializeEndTimeProperty(m map[string]interface{}, aliasMap map[string]st
hasDateTimeMember: true,
}
return this, nil
} else if str, ok := i.(string); ok {
this := &EndTimeProperty{
alias: alias,
unknown: []byte(str),
}
return this, nil
} else {
return nil, fmt.Errorf("could not deserialize %q property", "endTime")
}
this := &EndTimeProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
@ -180,7 +177,7 @@ func (this EndTimeProperty) Serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// Set sets the value of this property. Calling IsDateTime afterwards will return

View file

@ -16,7 +16,7 @@ type FirstProperty struct {
LinkMember vocab.LinkInterface
MentionMember vocab.MentionInterface
OrderedCollectionPageMember vocab.OrderedCollectionPageInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
}
@ -72,15 +72,12 @@ func DeserializeFirstProperty(m map[string]interface{}, aliasMap map[string]stri
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &FirstProperty{
alias: alias,
unknown: []byte(str),
}
return this, nil
} else {
return nil, fmt.Errorf("could not deserialize %q property", "first")
}
this := &FirstProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
@ -267,7 +264,7 @@ func (this FirstProperty) Serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// SetCollectionPage sets the value of this property. Calling IsCollectionPage

View file

@ -0,0 +1,15 @@
// Package propertyfollowers contains the implementation for the followers
// 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 propertyfollowers

View file

@ -0,0 +1,32 @@
package propertyfollowers
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 {
// DeserializeCollectionActivityStreams returns the deserialization method
// for the "CollectionInterface" non-functional property in the
// vocabulary "ActivityStreams"
DeserializeCollectionActivityStreams() func(map[string]interface{}, map[string]string) (vocab.CollectionInterface, error)
// DeserializeCollectionPageActivityStreams returns the deserialization
// method for the "CollectionPageInterface" non-functional property in
// the vocabulary "ActivityStreams"
DeserializeCollectionPageActivityStreams() func(map[string]interface{}, map[string]string) (vocab.CollectionPageInterface, error)
// DeserializeOrderedCollectionActivityStreams returns the deserialization
// method for the "OrderedCollectionInterface" non-functional property
// in the vocabulary "ActivityStreams"
DeserializeOrderedCollectionActivityStreams() func(map[string]interface{}, map[string]string) (vocab.OrderedCollectionInterface, error)
// DeserializeOrderedCollectionPageActivityStreams returns the
// deserialization method for the "OrderedCollectionPageInterface"
// non-functional property in the vocabulary "ActivityStreams"
DeserializeOrderedCollectionPageActivityStreams() func(map[string]interface{}, map[string]string) (vocab.OrderedCollectionPageInterface, 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
}

View file

@ -0,0 +1,305 @@
package propertyfollowers
import (
"fmt"
vocab "github.com/go-fed/activity/streams/vocab"
"net/url"
)
// FollowersProperty 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 FollowersProperty struct {
OrderedCollectionMember vocab.OrderedCollectionInterface
CollectionMember vocab.CollectionInterface
CollectionPageMember vocab.CollectionPageInterface
OrderedCollectionPageMember vocab.OrderedCollectionPageInterface
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) (*FollowersProperty, error) {
alias := ""
if a, ok := aliasMap["https://www.w3.org/TR/activitystreams-vocabulary"]; 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")
}
if i, ok := m[propName]; 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 := &FollowersProperty{
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 := &FollowersProperty{
OrderedCollectionMember: v,
alias: alias,
}
return this, nil
} else if v, err := mgr.DeserializeCollectionActivityStreams()(m, aliasMap); err == nil {
this := &FollowersProperty{
CollectionMember: v,
alias: alias,
}
return this, nil
} else if v, err := mgr.DeserializeCollectionPageActivityStreams()(m, aliasMap); err == nil {
this := &FollowersProperty{
CollectionPageMember: v,
alias: alias,
}
return this, nil
} else if v, err := mgr.DeserializeOrderedCollectionPageActivityStreams()(m, aliasMap); err == nil {
this := &FollowersProperty{
OrderedCollectionPageMember: v,
alias: alias,
}
return this, nil
}
}
this := &FollowersProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
// NewFollowersProperty creates a new followers property.
func NewFollowersProperty() *FollowersProperty {
return &FollowersProperty{alias: ""}
}
// Clear ensures no value of this property is set. Calling HasAny or any of the
// 'Is' methods afterwards will return false.
func (this *FollowersProperty) Clear() {
this.OrderedCollectionMember = nil
this.CollectionMember = nil
this.CollectionPageMember = nil
this.OrderedCollectionPageMember = nil
this.unknown = nil
this.iri = nil
}
// GetCollection returns the value of this property. When IsCollection returns
// false, GetCollection will return an arbitrary value.
func (this FollowersProperty) GetCollection() vocab.CollectionInterface {
return this.CollectionMember
}
// GetCollectionPage returns the value of this property. When IsCollectionPage
// returns false, GetCollectionPage will return an arbitrary value.
func (this FollowersProperty) GetCollectionPage() vocab.CollectionPageInterface {
return this.CollectionPageMember
}
// GetIRI returns the IRI of this property. When IsIRI returns false, GetIRI will
// return an arbitrary value.
func (this FollowersProperty) GetIRI() *url.URL {
return this.iri
}
// GetOrderedCollection returns the value of this property. When
// IsOrderedCollection returns false, GetOrderedCollection will return an
// arbitrary value.
func (this FollowersProperty) GetOrderedCollection() vocab.OrderedCollectionInterface {
return this.OrderedCollectionMember
}
// GetOrderedCollectionPage returns the value of this property. When
// IsOrderedCollectionPage returns false, GetOrderedCollectionPage will return
// an arbitrary value.
func (this FollowersProperty) GetOrderedCollectionPage() vocab.OrderedCollectionPageInterface {
return this.OrderedCollectionPageMember
}
// HasAny returns true if any of the different values is set.
func (this FollowersProperty) HasAny() bool {
return this.IsOrderedCollection() ||
this.IsCollection() ||
this.IsCollectionPage() ||
this.IsOrderedCollectionPage() ||
this.iri != nil
}
// IsCollection returns true if this property has a type of "Collection". When
// true, use the GetCollection and SetCollection methods to access and set
// this property.
func (this FollowersProperty) IsCollection() bool {
return this.CollectionMember != nil
}
// IsCollectionPage returns true if this property has a type of "CollectionPage".
// When true, use the GetCollectionPage and SetCollectionPage methods to
// access and set this property.
func (this FollowersProperty) IsCollectionPage() bool {
return this.CollectionPageMember != nil
}
// IsIRI returns true if this property is an IRI. When true, use GetIRI and SetIRI
// to access and set this property
func (this FollowersProperty) IsIRI() bool {
return this.iri != nil
}
// IsOrderedCollection returns true if this property has a type of
// "OrderedCollection". When true, use the GetOrderedCollection and
// SetOrderedCollection methods to access and set this property.
func (this FollowersProperty) IsOrderedCollection() bool {
return this.OrderedCollectionMember != nil
}
// IsOrderedCollectionPage returns true if this property has a type of
// "OrderedCollectionPage". When true, use the GetOrderedCollectionPage and
// SetOrderedCollectionPage methods to access and set this property.
func (this FollowersProperty) IsOrderedCollectionPage() bool {
return this.OrderedCollectionPageMember != 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 FollowersProperty) JSONLDContext() map[string]string {
m := map[string]string{"https://www.w3.org/TR/activitystreams-vocabulary": this.alias}
var child map[string]string
if this.IsOrderedCollection() {
child = this.GetOrderedCollection().JSONLDContext()
} else if this.IsCollection() {
child = this.GetCollection().JSONLDContext()
} else if this.IsCollectionPage() {
child = this.GetCollectionPage().JSONLDContext()
} else if this.IsOrderedCollectionPage() {
child = this.GetOrderedCollectionPage().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 FollowersProperty) KindIndex() int {
if this.IsOrderedCollection() {
return 0
}
if this.IsCollection() {
return 1
}
if this.IsCollectionPage() {
return 2
}
if this.IsOrderedCollectionPage() {
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 FollowersProperty) LessThan(o vocab.FollowersPropertyInterface) bool {
idx1 := this.KindIndex()
idx2 := o.KindIndex()
if idx1 < idx2 {
return true
} else if idx1 > idx2 {
return false
} else if this.IsOrderedCollection() {
return this.GetOrderedCollection().LessThan(o.GetOrderedCollection())
} else if this.IsCollection() {
return this.GetCollection().LessThan(o.GetCollection())
} else if this.IsCollectionPage() {
return this.GetCollectionPage().LessThan(o.GetCollectionPage())
} else if this.IsOrderedCollectionPage() {
return this.GetOrderedCollectionPage().LessThan(o.GetOrderedCollectionPage())
} else if this.IsIRI() {
return this.iri.String() < o.GetIRI().String()
}
return false
}
// Name returns the name of this property: "followers".
func (this FollowersProperty) Name() string {
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 FollowersProperty) Serialize() (interface{}, error) {
if this.IsOrderedCollection() {
return this.GetOrderedCollection().Serialize()
} else if this.IsCollection() {
return this.GetCollection().Serialize()
} else if this.IsCollectionPage() {
return this.GetCollectionPage().Serialize()
} else if this.IsOrderedCollectionPage() {
return this.GetOrderedCollectionPage().Serialize()
} else if this.IsIRI() {
return this.iri.String(), nil
}
return this.unknown, nil
}
// SetCollection sets the value of this property. Calling IsCollection afterwards
// returns true.
func (this *FollowersProperty) SetCollection(v vocab.CollectionInterface) {
this.Clear()
this.CollectionMember = v
}
// SetCollectionPage sets the value of this property. Calling IsCollectionPage
// afterwards returns true.
func (this *FollowersProperty) SetCollectionPage(v vocab.CollectionPageInterface) {
this.Clear()
this.CollectionPageMember = v
}
// SetIRI sets the value of this property. Calling IsIRI afterwards returns true.
func (this *FollowersProperty) SetIRI(v *url.URL) {
this.Clear()
this.iri = v
}
// SetOrderedCollection sets the value of this property. Calling
// IsOrderedCollection afterwards returns true.
func (this *FollowersProperty) SetOrderedCollection(v vocab.OrderedCollectionInterface) {
this.Clear()
this.OrderedCollectionMember = v
}
// SetOrderedCollectionPage sets the value of this property. Calling
// IsOrderedCollectionPage afterwards returns true.
func (this *FollowersProperty) SetOrderedCollectionPage(v vocab.OrderedCollectionPageInterface) {
this.Clear()
this.OrderedCollectionPageMember = v
}

View file

@ -0,0 +1,15 @@
// Package propertyfollowing contains the implementation for the following
// 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 propertyfollowing

View file

@ -0,0 +1,32 @@
package propertyfollowing
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 {
// DeserializeCollectionActivityStreams returns the deserialization method
// for the "CollectionInterface" non-functional property in the
// vocabulary "ActivityStreams"
DeserializeCollectionActivityStreams() func(map[string]interface{}, map[string]string) (vocab.CollectionInterface, error)
// DeserializeCollectionPageActivityStreams returns the deserialization
// method for the "CollectionPageInterface" non-functional property in
// the vocabulary "ActivityStreams"
DeserializeCollectionPageActivityStreams() func(map[string]interface{}, map[string]string) (vocab.CollectionPageInterface, error)
// DeserializeOrderedCollectionActivityStreams returns the deserialization
// method for the "OrderedCollectionInterface" non-functional property
// in the vocabulary "ActivityStreams"
DeserializeOrderedCollectionActivityStreams() func(map[string]interface{}, map[string]string) (vocab.OrderedCollectionInterface, error)
// DeserializeOrderedCollectionPageActivityStreams returns the
// deserialization method for the "OrderedCollectionPageInterface"
// non-functional property in the vocabulary "ActivityStreams"
DeserializeOrderedCollectionPageActivityStreams() func(map[string]interface{}, map[string]string) (vocab.OrderedCollectionPageInterface, 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
}

View file

@ -0,0 +1,305 @@
package propertyfollowing
import (
"fmt"
vocab "github.com/go-fed/activity/streams/vocab"
"net/url"
)
// FollowingProperty is the functional property "following". 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 FollowingProperty struct {
OrderedCollectionMember vocab.OrderedCollectionInterface
CollectionMember vocab.CollectionInterface
CollectionPageMember vocab.CollectionPageInterface
OrderedCollectionPageMember vocab.OrderedCollectionPageInterface
unknown interface{}
iri *url.URL
alias string
}
// DeserializeFollowingProperty creates a "following" property from an interface
// representation that has been unmarshalled from a text or binary format.
func DeserializeFollowingProperty(m map[string]interface{}, aliasMap map[string]string) (*FollowingProperty, error) {
alias := ""
if a, ok := aliasMap["https://www.w3.org/TR/activitystreams-vocabulary"]; ok {
alias = a
}
propName := "following"
if len(alias) > 0 {
// Use alias both to find the property, and set within the property.
propName = fmt.Sprintf("%s:%s", alias, "following")
}
if i, ok := m[propName]; 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 := &FollowingProperty{
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 := &FollowingProperty{
OrderedCollectionMember: v,
alias: alias,
}
return this, nil
} else if v, err := mgr.DeserializeCollectionActivityStreams()(m, aliasMap); err == nil {
this := &FollowingProperty{
CollectionMember: v,
alias: alias,
}
return this, nil
} else if v, err := mgr.DeserializeCollectionPageActivityStreams()(m, aliasMap); err == nil {
this := &FollowingProperty{
CollectionPageMember: v,
alias: alias,
}
return this, nil
} else if v, err := mgr.DeserializeOrderedCollectionPageActivityStreams()(m, aliasMap); err == nil {
this := &FollowingProperty{
OrderedCollectionPageMember: v,
alias: alias,
}
return this, nil
}
}
this := &FollowingProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
// NewFollowingProperty creates a new following property.
func NewFollowingProperty() *FollowingProperty {
return &FollowingProperty{alias: ""}
}
// Clear ensures no value of this property is set. Calling HasAny or any of the
// 'Is' methods afterwards will return false.
func (this *FollowingProperty) Clear() {
this.OrderedCollectionMember = nil
this.CollectionMember = nil
this.CollectionPageMember = nil
this.OrderedCollectionPageMember = nil
this.unknown = nil
this.iri = nil
}
// GetCollection returns the value of this property. When IsCollection returns
// false, GetCollection will return an arbitrary value.
func (this FollowingProperty) GetCollection() vocab.CollectionInterface {
return this.CollectionMember
}
// GetCollectionPage returns the value of this property. When IsCollectionPage
// returns false, GetCollectionPage will return an arbitrary value.
func (this FollowingProperty) GetCollectionPage() vocab.CollectionPageInterface {
return this.CollectionPageMember
}
// GetIRI returns the IRI of this property. When IsIRI returns false, GetIRI will
// return an arbitrary value.
func (this FollowingProperty) GetIRI() *url.URL {
return this.iri
}
// GetOrderedCollection returns the value of this property. When
// IsOrderedCollection returns false, GetOrderedCollection will return an
// arbitrary value.
func (this FollowingProperty) GetOrderedCollection() vocab.OrderedCollectionInterface {
return this.OrderedCollectionMember
}
// GetOrderedCollectionPage returns the value of this property. When
// IsOrderedCollectionPage returns false, GetOrderedCollectionPage will return
// an arbitrary value.
func (this FollowingProperty) GetOrderedCollectionPage() vocab.OrderedCollectionPageInterface {
return this.OrderedCollectionPageMember
}
// HasAny returns true if any of the different values is set.
func (this FollowingProperty) HasAny() bool {
return this.IsOrderedCollection() ||
this.IsCollection() ||
this.IsCollectionPage() ||
this.IsOrderedCollectionPage() ||
this.iri != nil
}
// IsCollection returns true if this property has a type of "Collection". When
// true, use the GetCollection and SetCollection methods to access and set
// this property.
func (this FollowingProperty) IsCollection() bool {
return this.CollectionMember != nil
}
// IsCollectionPage returns true if this property has a type of "CollectionPage".
// When true, use the GetCollectionPage and SetCollectionPage methods to
// access and set this property.
func (this FollowingProperty) IsCollectionPage() bool {
return this.CollectionPageMember != nil
}
// IsIRI returns true if this property is an IRI. When true, use GetIRI and SetIRI
// to access and set this property
func (this FollowingProperty) IsIRI() bool {
return this.iri != nil
}
// IsOrderedCollection returns true if this property has a type of
// "OrderedCollection". When true, use the GetOrderedCollection and
// SetOrderedCollection methods to access and set this property.
func (this FollowingProperty) IsOrderedCollection() bool {
return this.OrderedCollectionMember != nil
}
// IsOrderedCollectionPage returns true if this property has a type of
// "OrderedCollectionPage". When true, use the GetOrderedCollectionPage and
// SetOrderedCollectionPage methods to access and set this property.
func (this FollowingProperty) IsOrderedCollectionPage() bool {
return this.OrderedCollectionPageMember != 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 FollowingProperty) JSONLDContext() map[string]string {
m := map[string]string{"https://www.w3.org/TR/activitystreams-vocabulary": this.alias}
var child map[string]string
if this.IsOrderedCollection() {
child = this.GetOrderedCollection().JSONLDContext()
} else if this.IsCollection() {
child = this.GetCollection().JSONLDContext()
} else if this.IsCollectionPage() {
child = this.GetCollectionPage().JSONLDContext()
} else if this.IsOrderedCollectionPage() {
child = this.GetOrderedCollectionPage().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 FollowingProperty) KindIndex() int {
if this.IsOrderedCollection() {
return 0
}
if this.IsCollection() {
return 1
}
if this.IsCollectionPage() {
return 2
}
if this.IsOrderedCollectionPage() {
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 FollowingProperty) LessThan(o vocab.FollowingPropertyInterface) bool {
idx1 := this.KindIndex()
idx2 := o.KindIndex()
if idx1 < idx2 {
return true
} else if idx1 > idx2 {
return false
} else if this.IsOrderedCollection() {
return this.GetOrderedCollection().LessThan(o.GetOrderedCollection())
} else if this.IsCollection() {
return this.GetCollection().LessThan(o.GetCollection())
} else if this.IsCollectionPage() {
return this.GetCollectionPage().LessThan(o.GetCollectionPage())
} else if this.IsOrderedCollectionPage() {
return this.GetOrderedCollectionPage().LessThan(o.GetOrderedCollectionPage())
} else if this.IsIRI() {
return this.iri.String() < o.GetIRI().String()
}
return false
}
// Name returns the name of this property: "following".
func (this FollowingProperty) Name() string {
return "following"
}
// 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 FollowingProperty) Serialize() (interface{}, error) {
if this.IsOrderedCollection() {
return this.GetOrderedCollection().Serialize()
} else if this.IsCollection() {
return this.GetCollection().Serialize()
} else if this.IsCollectionPage() {
return this.GetCollectionPage().Serialize()
} else if this.IsOrderedCollectionPage() {
return this.GetOrderedCollectionPage().Serialize()
} else if this.IsIRI() {
return this.iri.String(), nil
}
return this.unknown, nil
}
// SetCollection sets the value of this property. Calling IsCollection afterwards
// returns true.
func (this *FollowingProperty) SetCollection(v vocab.CollectionInterface) {
this.Clear()
this.CollectionMember = v
}
// SetCollectionPage sets the value of this property. Calling IsCollectionPage
// afterwards returns true.
func (this *FollowingProperty) SetCollectionPage(v vocab.CollectionPageInterface) {
this.Clear()
this.CollectionPageMember = v
}
// SetIRI sets the value of this property. Calling IsIRI afterwards returns true.
func (this *FollowingProperty) SetIRI(v *url.URL) {
this.Clear()
this.iri = v
}
// SetOrderedCollection sets the value of this property. Calling
// IsOrderedCollection afterwards returns true.
func (this *FollowingProperty) SetOrderedCollection(v vocab.OrderedCollectionInterface) {
this.Clear()
this.OrderedCollectionMember = v
}
// SetOrderedCollectionPage sets the value of this property. Calling
// IsOrderedCollectionPage afterwards returns true.
func (this *FollowingProperty) SetOrderedCollectionPage(v vocab.OrderedCollectionPageInterface) {
this.Clear()
this.OrderedCollectionPageMember = v
}

View file

@ -64,7 +64,7 @@ type FormerTypePropertyIterator struct {
UpdateMember vocab.UpdateInterface
VideoMember vocab.VideoInterface
ViewMember vocab.ViewInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
myIdx int
@ -409,13 +409,12 @@ func deserializeFormerTypePropertyIterator(i interface{}, aliasMap map[string]st
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &FormerTypePropertyIterator{
alias: alias,
unknown: []byte(str),
}
return this, nil
}
this := &FormerTypePropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "formerType")
}
@ -2089,7 +2088,7 @@ func (this FormerTypePropertyIterator) serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// FormerTypeProperty is the non-functional property "formerType". It is permitted

View file

@ -66,7 +66,7 @@ type GeneratorPropertyIterator struct {
UpdateMember vocab.UpdateInterface
VideoMember vocab.VideoInterface
ViewMember vocab.ViewInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
myIdx int
@ -423,13 +423,12 @@ func deserializeGeneratorPropertyIterator(i interface{}, aliasMap map[string]str
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &GeneratorPropertyIterator{
alias: alias,
unknown: []byte(str),
}
return this, nil
}
this := &GeneratorPropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "generator")
}
@ -2162,7 +2161,7 @@ func (this GeneratorPropertyIterator) serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// GeneratorProperty is the non-functional property "generator". It is permitted

View file

@ -12,7 +12,7 @@ import (
type HeightProperty struct {
nonNegativeIntegerMember int
hasNonNegativeIntegerMember bool
unknown []byte
unknown interface{}
iri *url.URL
alias string
}
@ -49,15 +49,12 @@ func DeserializeHeightProperty(m map[string]interface{}, aliasMap map[string]str
nonNegativeIntegerMember: v,
}
return this, nil
} else if str, ok := i.(string); ok {
this := &HeightProperty{
alias: alias,
unknown: []byte(str),
}
return this, nil
} else {
return nil, fmt.Errorf("could not deserialize %q property", "height")
}
this := &HeightProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
@ -179,7 +176,7 @@ func (this HeightProperty) Serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// Set sets the value of this property. Calling IsNonNegativeInteger afterwards

View file

@ -11,7 +11,7 @@ import (
// nilable value type.
type HrefProperty struct {
anyURIMember *url.URL
unknown []byte
unknown interface{}
alias string
}
@ -34,15 +34,12 @@ func DeserializeHrefProperty(m map[string]interface{}, aliasMap map[string]strin
anyURIMember: v,
}
return this, nil
} else if str, ok := i.(string); ok {
this := &HrefProperty{
alias: alias,
unknown: []byte(str),
}
return this, nil
} else {
return nil, fmt.Errorf("could not deserialize %q property", "href")
}
this := &HrefProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
@ -158,7 +155,7 @@ func (this HrefProperty) Serialize() (interface{}, error) {
if this.IsAnyURI() {
return anyuri.SerializeAnyURI(this.Get())
}
return string(this.unknown), nil
return this.unknown, nil
}
// Set sets the value of this property. Calling IsAnyURI afterwards will return

View file

@ -12,7 +12,7 @@ import (
type HreflangProperty struct {
bcp47Member string
hasBcp47Member bool
unknown []byte
unknown interface{}
iri *url.URL
alias string
}
@ -49,15 +49,12 @@ func DeserializeHreflangProperty(m map[string]interface{}, aliasMap map[string]s
hasBcp47Member: true,
}
return this, nil
} else if str, ok := i.(string); ok {
this := &HreflangProperty{
alias: alias,
unknown: []byte(str),
}
return this, nil
} else {
return nil, fmt.Errorf("could not deserialize %q property", "hreflang")
}
this := &HreflangProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
@ -179,7 +176,7 @@ func (this HreflangProperty) Serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// Set sets the value of this property. Calling IsBcp47 afterwards will return

View file

@ -15,7 +15,7 @@ type IconPropertyIterator struct {
ImageMember vocab.ImageInterface
LinkMember vocab.LinkInterface
MentionMember vocab.MentionInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
myIdx int
@ -66,13 +66,12 @@ func deserializeIconPropertyIterator(i interface{}, aliasMap map[string]string)
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &IconPropertyIterator{
alias: alias,
unknown: []byte(str),
}
return this, nil
}
this := &IconPropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "icon")
}
@ -271,7 +270,7 @@ func (this IconPropertyIterator) serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// IconProperty is the non-functional property "icon". It is permitted to have one

View file

@ -11,7 +11,7 @@ import (
// nilable value type.
type IdProperty struct {
anyURIMember *url.URL
unknown []byte
unknown interface{}
alias string
}
@ -34,15 +34,12 @@ func DeserializeIdProperty(m map[string]interface{}, aliasMap map[string]string)
anyURIMember: v,
}
return this, nil
} else if str, ok := i.(string); ok {
this := &IdProperty{
alias: alias,
unknown: []byte(str),
}
return this, nil
} else {
return nil, fmt.Errorf("could not deserialize %q property", "id")
}
this := &IdProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
@ -158,7 +155,7 @@ func (this IdProperty) Serialize() (interface{}, error) {
if this.IsAnyURI() {
return anyuri.SerializeAnyURI(this.Get())
}
return string(this.unknown), nil
return this.unknown, nil
}
// Set sets the value of this property. Calling IsAnyURI afterwards will return

View file

@ -15,7 +15,7 @@ type ImagePropertyIterator struct {
ImageMember vocab.ImageInterface
LinkMember vocab.LinkInterface
MentionMember vocab.MentionInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
myIdx int
@ -66,13 +66,12 @@ func deserializeImagePropertyIterator(i interface{}, aliasMap map[string]string)
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &ImagePropertyIterator{
alias: alias,
unknown: []byte(str),
}
return this, nil
}
this := &ImagePropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "image")
}
@ -271,7 +270,7 @@ func (this ImagePropertyIterator) serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// ImageProperty is the non-functional property "image". It is permitted to have

View file

@ -0,0 +1,15 @@
// Package propertyinbox contains the implementation for the inbox 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 propertyinbox

View file

@ -0,0 +1,20 @@
package propertyinbox
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 {
// DeserializeOrderedCollectionActivityStreams returns the deserialization
// method for the "OrderedCollectionInterface" non-functional property
// in the vocabulary "ActivityStreams"
DeserializeOrderedCollectionActivityStreams() func(map[string]interface{}, map[string]string) (vocab.OrderedCollectionInterface, 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
}

View file

@ -0,0 +1,195 @@
package propertyinbox
import (
"fmt"
vocab "github.com/go-fed/activity/streams/vocab"
"net/url"
)
// InboxProperty is the functional property "inbox". It is permitted to be a
// single nilable value type.
type InboxProperty struct {
OrderedCollectionMember vocab.OrderedCollectionInterface
unknown interface{}
iri *url.URL
alias string
}
// DeserializeInboxProperty creates a "inbox" property from an interface
// representation that has been unmarshalled from a text or binary format.
func DeserializeInboxProperty(m map[string]interface{}, aliasMap map[string]string) (*InboxProperty, error) {
alias := ""
if a, ok := aliasMap["https://www.w3.org/TR/activitystreams-vocabulary"]; ok {
alias = a
}
propName := "inbox"
if len(alias) > 0 {
// Use alias both to find the property, and set within the property.
propName = fmt.Sprintf("%s:%s", alias, "inbox")
}
if i, ok := m[propName]; 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 := &InboxProperty{
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 := &InboxProperty{
OrderedCollectionMember: v,
alias: alias,
}
return this, nil
}
}
this := &InboxProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
// NewInboxProperty creates a new inbox property.
func NewInboxProperty() *InboxProperty {
return &InboxProperty{alias: ""}
}
// Clear ensures no value of this property is set. Calling IsOrderedCollection
// afterwards will return false.
func (this *InboxProperty) Clear() {
this.unknown = nil
this.iri = nil
this.OrderedCollectionMember = nil
}
// Get returns the value of this property. When IsOrderedCollection returns false,
// Get will return any arbitrary value.
func (this InboxProperty) Get() vocab.OrderedCollectionInterface {
return this.OrderedCollectionMember
}
// GetIRI returns the IRI of this property. When IsIRI returns false, GetIRI will
// return any arbitrary value.
func (this InboxProperty) GetIRI() *url.URL {
return this.iri
}
// HasAny returns true if the value or IRI is set.
func (this InboxProperty) HasAny() bool {
return this.IsOrderedCollection() || this.iri != nil
}
// IsIRI returns true if this property is an IRI.
func (this InboxProperty) IsIRI() bool {
return this.iri != nil
}
// IsOrderedCollection returns true if this property is set and not an IRI.
func (this InboxProperty) IsOrderedCollection() bool {
return this.OrderedCollectionMember != 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 InboxProperty) JSONLDContext() map[string]string {
m := map[string]string{"https://www.w3.org/TR/activitystreams-vocabulary": this.alias}
var child map[string]string
if this.IsOrderedCollection() {
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 InboxProperty) KindIndex() int {
if this.IsOrderedCollection() {
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 InboxProperty) LessThan(o vocab.InboxPropertyInterface) 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.IsOrderedCollection() && !o.IsOrderedCollection() {
// Both are unknowns.
return false
} else if this.IsOrderedCollection() && !o.IsOrderedCollection() {
// Values are always greater than unknown values.
return false
} else if !this.IsOrderedCollection() && o.IsOrderedCollection() {
// 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: "inbox".
func (this InboxProperty) Name() string {
return "inbox"
}
// 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 InboxProperty) Serialize() (interface{}, error) {
if this.IsOrderedCollection() {
return this.Get().Serialize()
} else if this.IsIRI() {
return this.iri.String(), nil
}
return this.unknown, nil
}
// Set sets the value of this property. Calling IsOrderedCollection afterwards
// will return true.
func (this *InboxProperty) Set(v vocab.OrderedCollectionInterface) {
this.Clear()
this.OrderedCollectionMember = v
}
// SetIRI sets the value of this property. Calling IsIRI afterwards will return
// true.
func (this *InboxProperty) SetIRI(v *url.URL) {
this.Clear()
this.iri = v
}

View file

@ -66,7 +66,7 @@ type InReplyToPropertyIterator struct {
UpdateMember vocab.UpdateInterface
VideoMember vocab.VideoInterface
ViewMember vocab.ViewInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
myIdx int
@ -423,13 +423,12 @@ func deserializeInReplyToPropertyIterator(i interface{}, aliasMap map[string]str
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &InReplyToPropertyIterator{
alias: alias,
unknown: []byte(str),
}
return this, nil
}
this := &InReplyToPropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "inReplyTo")
}
@ -2162,7 +2161,7 @@ func (this InReplyToPropertyIterator) serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// InReplyToProperty is the non-functional property "inReplyTo". It is permitted

View file

@ -66,7 +66,7 @@ type InstrumentPropertyIterator struct {
UpdateMember vocab.UpdateInterface
VideoMember vocab.VideoInterface
ViewMember vocab.ViewInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
myIdx int
@ -423,13 +423,12 @@ func deserializeInstrumentPropertyIterator(i interface{}, aliasMap map[string]st
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &InstrumentPropertyIterator{
alias: alias,
unknown: []byte(str),
}
return this, nil
}
this := &InstrumentPropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "instrument")
}
@ -2162,7 +2161,7 @@ func (this InstrumentPropertyIterator) serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// InstrumentProperty is the non-functional property "instrument". It is permitted

View file

@ -66,7 +66,7 @@ type ItemsPropertyIterator struct {
UpdateMember vocab.UpdateInterface
VideoMember vocab.VideoInterface
ViewMember vocab.ViewInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
myIdx int
@ -423,13 +423,12 @@ func deserializeItemsPropertyIterator(i interface{}, aliasMap map[string]string)
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &ItemsPropertyIterator{
alias: alias,
unknown: []byte(str),
}
return this, nil
}
this := &ItemsPropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "items")
}
@ -2162,7 +2161,7 @@ func (this ItemsPropertyIterator) serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// ItemsProperty is the non-functional property "items". It is permitted to have

View file

@ -16,7 +16,7 @@ type LastProperty struct {
LinkMember vocab.LinkInterface
MentionMember vocab.MentionInterface
OrderedCollectionPageMember vocab.OrderedCollectionPageInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
}
@ -72,15 +72,12 @@ func DeserializeLastProperty(m map[string]interface{}, aliasMap map[string]strin
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &LastProperty{
alias: alias,
unknown: []byte(str),
}
return this, nil
} else {
return nil, fmt.Errorf("could not deserialize %q property", "last")
}
this := &LastProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
@ -267,7 +264,7 @@ func (this LastProperty) Serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// SetCollectionPage sets the value of this property. Calling IsCollectionPage

View file

@ -12,7 +12,7 @@ import (
type LatitudeProperty struct {
floatMember float64
hasFloatMember bool
unknown []byte
unknown interface{}
iri *url.URL
alias string
}
@ -49,15 +49,12 @@ func DeserializeLatitudeProperty(m map[string]interface{}, aliasMap map[string]s
hasFloatMember: true,
}
return this, nil
} else if str, ok := i.(string); ok {
this := &LatitudeProperty{
alias: alias,
unknown: []byte(str),
}
return this, nil
} else {
return nil, fmt.Errorf("could not deserialize %q property", "latitude")
}
this := &LatitudeProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
@ -179,7 +176,7 @@ func (this LatitudeProperty) Serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// Set sets the value of this property. Calling IsFloat afterwards will return

View file

@ -0,0 +1,15 @@
// Package propertyliked contains the implementation for the liked 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 propertyliked

View file

@ -0,0 +1,32 @@
package propertyliked
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 {
// DeserializeCollectionActivityStreams returns the deserialization method
// for the "CollectionInterface" non-functional property in the
// vocabulary "ActivityStreams"
DeserializeCollectionActivityStreams() func(map[string]interface{}, map[string]string) (vocab.CollectionInterface, error)
// DeserializeCollectionPageActivityStreams returns the deserialization
// method for the "CollectionPageInterface" non-functional property in
// the vocabulary "ActivityStreams"
DeserializeCollectionPageActivityStreams() func(map[string]interface{}, map[string]string) (vocab.CollectionPageInterface, error)
// DeserializeOrderedCollectionActivityStreams returns the deserialization
// method for the "OrderedCollectionInterface" non-functional property
// in the vocabulary "ActivityStreams"
DeserializeOrderedCollectionActivityStreams() func(map[string]interface{}, map[string]string) (vocab.OrderedCollectionInterface, error)
// DeserializeOrderedCollectionPageActivityStreams returns the
// deserialization method for the "OrderedCollectionPageInterface"
// non-functional property in the vocabulary "ActivityStreams"
DeserializeOrderedCollectionPageActivityStreams() func(map[string]interface{}, map[string]string) (vocab.OrderedCollectionPageInterface, 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
}

View file

@ -0,0 +1,305 @@
package propertyliked
import (
"fmt"
vocab "github.com/go-fed/activity/streams/vocab"
"net/url"
)
// LikedProperty is the functional property "liked". 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 LikedProperty struct {
OrderedCollectionMember vocab.OrderedCollectionInterface
CollectionMember vocab.CollectionInterface
CollectionPageMember vocab.CollectionPageInterface
OrderedCollectionPageMember vocab.OrderedCollectionPageInterface
unknown interface{}
iri *url.URL
alias string
}
// DeserializeLikedProperty creates a "liked" property from an interface
// representation that has been unmarshalled from a text or binary format.
func DeserializeLikedProperty(m map[string]interface{}, aliasMap map[string]string) (*LikedProperty, error) {
alias := ""
if a, ok := aliasMap["https://www.w3.org/TR/activitystreams-vocabulary"]; ok {
alias = a
}
propName := "liked"
if len(alias) > 0 {
// Use alias both to find the property, and set within the property.
propName = fmt.Sprintf("%s:%s", alias, "liked")
}
if i, ok := m[propName]; 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 := &LikedProperty{
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 := &LikedProperty{
OrderedCollectionMember: v,
alias: alias,
}
return this, nil
} else if v, err := mgr.DeserializeCollectionActivityStreams()(m, aliasMap); err == nil {
this := &LikedProperty{
CollectionMember: v,
alias: alias,
}
return this, nil
} else if v, err := mgr.DeserializeCollectionPageActivityStreams()(m, aliasMap); err == nil {
this := &LikedProperty{
CollectionPageMember: v,
alias: alias,
}
return this, nil
} else if v, err := mgr.DeserializeOrderedCollectionPageActivityStreams()(m, aliasMap); err == nil {
this := &LikedProperty{
OrderedCollectionPageMember: v,
alias: alias,
}
return this, nil
}
}
this := &LikedProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
// NewLikedProperty creates a new liked property.
func NewLikedProperty() *LikedProperty {
return &LikedProperty{alias: ""}
}
// Clear ensures no value of this property is set. Calling HasAny or any of the
// 'Is' methods afterwards will return false.
func (this *LikedProperty) Clear() {
this.OrderedCollectionMember = nil
this.CollectionMember = nil
this.CollectionPageMember = nil
this.OrderedCollectionPageMember = nil
this.unknown = nil
this.iri = nil
}
// GetCollection returns the value of this property. When IsCollection returns
// false, GetCollection will return an arbitrary value.
func (this LikedProperty) GetCollection() vocab.CollectionInterface {
return this.CollectionMember
}
// GetCollectionPage returns the value of this property. When IsCollectionPage
// returns false, GetCollectionPage will return an arbitrary value.
func (this LikedProperty) GetCollectionPage() vocab.CollectionPageInterface {
return this.CollectionPageMember
}
// GetIRI returns the IRI of this property. When IsIRI returns false, GetIRI will
// return an arbitrary value.
func (this LikedProperty) GetIRI() *url.URL {
return this.iri
}
// GetOrderedCollection returns the value of this property. When
// IsOrderedCollection returns false, GetOrderedCollection will return an
// arbitrary value.
func (this LikedProperty) GetOrderedCollection() vocab.OrderedCollectionInterface {
return this.OrderedCollectionMember
}
// GetOrderedCollectionPage returns the value of this property. When
// IsOrderedCollectionPage returns false, GetOrderedCollectionPage will return
// an arbitrary value.
func (this LikedProperty) GetOrderedCollectionPage() vocab.OrderedCollectionPageInterface {
return this.OrderedCollectionPageMember
}
// HasAny returns true if any of the different values is set.
func (this LikedProperty) HasAny() bool {
return this.IsOrderedCollection() ||
this.IsCollection() ||
this.IsCollectionPage() ||
this.IsOrderedCollectionPage() ||
this.iri != nil
}
// IsCollection returns true if this property has a type of "Collection". When
// true, use the GetCollection and SetCollection methods to access and set
// this property.
func (this LikedProperty) IsCollection() bool {
return this.CollectionMember != nil
}
// IsCollectionPage returns true if this property has a type of "CollectionPage".
// When true, use the GetCollectionPage and SetCollectionPage methods to
// access and set this property.
func (this LikedProperty) IsCollectionPage() bool {
return this.CollectionPageMember != nil
}
// IsIRI returns true if this property is an IRI. When true, use GetIRI and SetIRI
// to access and set this property
func (this LikedProperty) IsIRI() bool {
return this.iri != nil
}
// IsOrderedCollection returns true if this property has a type of
// "OrderedCollection". When true, use the GetOrderedCollection and
// SetOrderedCollection methods to access and set this property.
func (this LikedProperty) IsOrderedCollection() bool {
return this.OrderedCollectionMember != nil
}
// IsOrderedCollectionPage returns true if this property has a type of
// "OrderedCollectionPage". When true, use the GetOrderedCollectionPage and
// SetOrderedCollectionPage methods to access and set this property.
func (this LikedProperty) IsOrderedCollectionPage() bool {
return this.OrderedCollectionPageMember != 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 LikedProperty) JSONLDContext() map[string]string {
m := map[string]string{"https://www.w3.org/TR/activitystreams-vocabulary": this.alias}
var child map[string]string
if this.IsOrderedCollection() {
child = this.GetOrderedCollection().JSONLDContext()
} else if this.IsCollection() {
child = this.GetCollection().JSONLDContext()
} else if this.IsCollectionPage() {
child = this.GetCollectionPage().JSONLDContext()
} else if this.IsOrderedCollectionPage() {
child = this.GetOrderedCollectionPage().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 LikedProperty) KindIndex() int {
if this.IsOrderedCollection() {
return 0
}
if this.IsCollection() {
return 1
}
if this.IsCollectionPage() {
return 2
}
if this.IsOrderedCollectionPage() {
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 LikedProperty) LessThan(o vocab.LikedPropertyInterface) bool {
idx1 := this.KindIndex()
idx2 := o.KindIndex()
if idx1 < idx2 {
return true
} else if idx1 > idx2 {
return false
} else if this.IsOrderedCollection() {
return this.GetOrderedCollection().LessThan(o.GetOrderedCollection())
} else if this.IsCollection() {
return this.GetCollection().LessThan(o.GetCollection())
} else if this.IsCollectionPage() {
return this.GetCollectionPage().LessThan(o.GetCollectionPage())
} else if this.IsOrderedCollectionPage() {
return this.GetOrderedCollectionPage().LessThan(o.GetOrderedCollectionPage())
} else if this.IsIRI() {
return this.iri.String() < o.GetIRI().String()
}
return false
}
// Name returns the name of this property: "liked".
func (this LikedProperty) Name() string {
return "liked"
}
// 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 LikedProperty) Serialize() (interface{}, error) {
if this.IsOrderedCollection() {
return this.GetOrderedCollection().Serialize()
} else if this.IsCollection() {
return this.GetCollection().Serialize()
} else if this.IsCollectionPage() {
return this.GetCollectionPage().Serialize()
} else if this.IsOrderedCollectionPage() {
return this.GetOrderedCollectionPage().Serialize()
} else if this.IsIRI() {
return this.iri.String(), nil
}
return this.unknown, nil
}
// SetCollection sets the value of this property. Calling IsCollection afterwards
// returns true.
func (this *LikedProperty) SetCollection(v vocab.CollectionInterface) {
this.Clear()
this.CollectionMember = v
}
// SetCollectionPage sets the value of this property. Calling IsCollectionPage
// afterwards returns true.
func (this *LikedProperty) SetCollectionPage(v vocab.CollectionPageInterface) {
this.Clear()
this.CollectionPageMember = v
}
// SetIRI sets the value of this property. Calling IsIRI afterwards returns true.
func (this *LikedProperty) SetIRI(v *url.URL) {
this.Clear()
this.iri = v
}
// SetOrderedCollection sets the value of this property. Calling
// IsOrderedCollection afterwards returns true.
func (this *LikedProperty) SetOrderedCollection(v vocab.OrderedCollectionInterface) {
this.Clear()
this.OrderedCollectionMember = v
}
// SetOrderedCollectionPage sets the value of this property. Calling
// IsOrderedCollectionPage afterwards returns true.
func (this *LikedProperty) SetOrderedCollectionPage(v vocab.OrderedCollectionPageInterface) {
this.Clear()
this.OrderedCollectionPageMember = v
}

View file

@ -0,0 +1,15 @@
// Package propertylikes contains the implementation for the likes 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 propertylikes

View file

@ -0,0 +1,32 @@
package propertylikes
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 {
// DeserializeCollectionActivityStreams returns the deserialization method
// for the "CollectionInterface" non-functional property in the
// vocabulary "ActivityStreams"
DeserializeCollectionActivityStreams() func(map[string]interface{}, map[string]string) (vocab.CollectionInterface, error)
// DeserializeCollectionPageActivityStreams returns the deserialization
// method for the "CollectionPageInterface" non-functional property in
// the vocabulary "ActivityStreams"
DeserializeCollectionPageActivityStreams() func(map[string]interface{}, map[string]string) (vocab.CollectionPageInterface, error)
// DeserializeOrderedCollectionActivityStreams returns the deserialization
// method for the "OrderedCollectionInterface" non-functional property
// in the vocabulary "ActivityStreams"
DeserializeOrderedCollectionActivityStreams() func(map[string]interface{}, map[string]string) (vocab.OrderedCollectionInterface, error)
// DeserializeOrderedCollectionPageActivityStreams returns the
// deserialization method for the "OrderedCollectionPageInterface"
// non-functional property in the vocabulary "ActivityStreams"
DeserializeOrderedCollectionPageActivityStreams() func(map[string]interface{}, map[string]string) (vocab.OrderedCollectionPageInterface, 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
}

View file

@ -0,0 +1,305 @@
package propertylikes
import (
"fmt"
vocab "github.com/go-fed/activity/streams/vocab"
"net/url"
)
// LikesProperty is the functional property "likes". 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 LikesProperty struct {
OrderedCollectionMember vocab.OrderedCollectionInterface
CollectionMember vocab.CollectionInterface
CollectionPageMember vocab.CollectionPageInterface
OrderedCollectionPageMember vocab.OrderedCollectionPageInterface
unknown interface{}
iri *url.URL
alias string
}
// DeserializeLikesProperty creates a "likes" property from an interface
// representation that has been unmarshalled from a text or binary format.
func DeserializeLikesProperty(m map[string]interface{}, aliasMap map[string]string) (*LikesProperty, error) {
alias := ""
if a, ok := aliasMap["https://www.w3.org/TR/activitystreams-vocabulary"]; ok {
alias = a
}
propName := "likes"
if len(alias) > 0 {
// Use alias both to find the property, and set within the property.
propName = fmt.Sprintf("%s:%s", alias, "likes")
}
if i, ok := m[propName]; 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 := &LikesProperty{
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 := &LikesProperty{
OrderedCollectionMember: v,
alias: alias,
}
return this, nil
} else if v, err := mgr.DeserializeCollectionActivityStreams()(m, aliasMap); err == nil {
this := &LikesProperty{
CollectionMember: v,
alias: alias,
}
return this, nil
} else if v, err := mgr.DeserializeCollectionPageActivityStreams()(m, aliasMap); err == nil {
this := &LikesProperty{
CollectionPageMember: v,
alias: alias,
}
return this, nil
} else if v, err := mgr.DeserializeOrderedCollectionPageActivityStreams()(m, aliasMap); err == nil {
this := &LikesProperty{
OrderedCollectionPageMember: v,
alias: alias,
}
return this, nil
}
}
this := &LikesProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
// NewLikesProperty creates a new likes property.
func NewLikesProperty() *LikesProperty {
return &LikesProperty{alias: ""}
}
// Clear ensures no value of this property is set. Calling HasAny or any of the
// 'Is' methods afterwards will return false.
func (this *LikesProperty) Clear() {
this.OrderedCollectionMember = nil
this.CollectionMember = nil
this.CollectionPageMember = nil
this.OrderedCollectionPageMember = nil
this.unknown = nil
this.iri = nil
}
// GetCollection returns the value of this property. When IsCollection returns
// false, GetCollection will return an arbitrary value.
func (this LikesProperty) GetCollection() vocab.CollectionInterface {
return this.CollectionMember
}
// GetCollectionPage returns the value of this property. When IsCollectionPage
// returns false, GetCollectionPage will return an arbitrary value.
func (this LikesProperty) GetCollectionPage() vocab.CollectionPageInterface {
return this.CollectionPageMember
}
// GetIRI returns the IRI of this property. When IsIRI returns false, GetIRI will
// return an arbitrary value.
func (this LikesProperty) GetIRI() *url.URL {
return this.iri
}
// GetOrderedCollection returns the value of this property. When
// IsOrderedCollection returns false, GetOrderedCollection will return an
// arbitrary value.
func (this LikesProperty) GetOrderedCollection() vocab.OrderedCollectionInterface {
return this.OrderedCollectionMember
}
// GetOrderedCollectionPage returns the value of this property. When
// IsOrderedCollectionPage returns false, GetOrderedCollectionPage will return
// an arbitrary value.
func (this LikesProperty) GetOrderedCollectionPage() vocab.OrderedCollectionPageInterface {
return this.OrderedCollectionPageMember
}
// HasAny returns true if any of the different values is set.
func (this LikesProperty) HasAny() bool {
return this.IsOrderedCollection() ||
this.IsCollection() ||
this.IsCollectionPage() ||
this.IsOrderedCollectionPage() ||
this.iri != nil
}
// IsCollection returns true if this property has a type of "Collection". When
// true, use the GetCollection and SetCollection methods to access and set
// this property.
func (this LikesProperty) IsCollection() bool {
return this.CollectionMember != nil
}
// IsCollectionPage returns true if this property has a type of "CollectionPage".
// When true, use the GetCollectionPage and SetCollectionPage methods to
// access and set this property.
func (this LikesProperty) IsCollectionPage() bool {
return this.CollectionPageMember != nil
}
// IsIRI returns true if this property is an IRI. When true, use GetIRI and SetIRI
// to access and set this property
func (this LikesProperty) IsIRI() bool {
return this.iri != nil
}
// IsOrderedCollection returns true if this property has a type of
// "OrderedCollection". When true, use the GetOrderedCollection and
// SetOrderedCollection methods to access and set this property.
func (this LikesProperty) IsOrderedCollection() bool {
return this.OrderedCollectionMember != nil
}
// IsOrderedCollectionPage returns true if this property has a type of
// "OrderedCollectionPage". When true, use the GetOrderedCollectionPage and
// SetOrderedCollectionPage methods to access and set this property.
func (this LikesProperty) IsOrderedCollectionPage() bool {
return this.OrderedCollectionPageMember != 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 LikesProperty) JSONLDContext() map[string]string {
m := map[string]string{"https://www.w3.org/TR/activitystreams-vocabulary": this.alias}
var child map[string]string
if this.IsOrderedCollection() {
child = this.GetOrderedCollection().JSONLDContext()
} else if this.IsCollection() {
child = this.GetCollection().JSONLDContext()
} else if this.IsCollectionPage() {
child = this.GetCollectionPage().JSONLDContext()
} else if this.IsOrderedCollectionPage() {
child = this.GetOrderedCollectionPage().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 LikesProperty) KindIndex() int {
if this.IsOrderedCollection() {
return 0
}
if this.IsCollection() {
return 1
}
if this.IsCollectionPage() {
return 2
}
if this.IsOrderedCollectionPage() {
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 LikesProperty) LessThan(o vocab.LikesPropertyInterface) bool {
idx1 := this.KindIndex()
idx2 := o.KindIndex()
if idx1 < idx2 {
return true
} else if idx1 > idx2 {
return false
} else if this.IsOrderedCollection() {
return this.GetOrderedCollection().LessThan(o.GetOrderedCollection())
} else if this.IsCollection() {
return this.GetCollection().LessThan(o.GetCollection())
} else if this.IsCollectionPage() {
return this.GetCollectionPage().LessThan(o.GetCollectionPage())
} else if this.IsOrderedCollectionPage() {
return this.GetOrderedCollectionPage().LessThan(o.GetOrderedCollectionPage())
} else if this.IsIRI() {
return this.iri.String() < o.GetIRI().String()
}
return false
}
// Name returns the name of this property: "likes".
func (this LikesProperty) Name() string {
return "likes"
}
// 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 LikesProperty) Serialize() (interface{}, error) {
if this.IsOrderedCollection() {
return this.GetOrderedCollection().Serialize()
} else if this.IsCollection() {
return this.GetCollection().Serialize()
} else if this.IsCollectionPage() {
return this.GetCollectionPage().Serialize()
} else if this.IsOrderedCollectionPage() {
return this.GetOrderedCollectionPage().Serialize()
} else if this.IsIRI() {
return this.iri.String(), nil
}
return this.unknown, nil
}
// SetCollection sets the value of this property. Calling IsCollection afterwards
// returns true.
func (this *LikesProperty) SetCollection(v vocab.CollectionInterface) {
this.Clear()
this.CollectionMember = v
}
// SetCollectionPage sets the value of this property. Calling IsCollectionPage
// afterwards returns true.
func (this *LikesProperty) SetCollectionPage(v vocab.CollectionPageInterface) {
this.Clear()
this.CollectionPageMember = v
}
// SetIRI sets the value of this property. Calling IsIRI afterwards returns true.
func (this *LikesProperty) SetIRI(v *url.URL) {
this.Clear()
this.iri = v
}
// SetOrderedCollection sets the value of this property. Calling
// IsOrderedCollection afterwards returns true.
func (this *LikesProperty) SetOrderedCollection(v vocab.OrderedCollectionInterface) {
this.Clear()
this.OrderedCollectionMember = v
}
// SetOrderedCollectionPage sets the value of this property. Calling
// IsOrderedCollectionPage afterwards returns true.
func (this *LikesProperty) SetOrderedCollectionPage(v vocab.OrderedCollectionPageInterface) {
this.Clear()
this.OrderedCollectionPageMember = v
}

View file

@ -66,7 +66,7 @@ type LocationPropertyIterator struct {
UpdateMember vocab.UpdateInterface
VideoMember vocab.VideoInterface
ViewMember vocab.ViewInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
myIdx int
@ -423,13 +423,12 @@ func deserializeLocationPropertyIterator(i interface{}, aliasMap map[string]stri
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &LocationPropertyIterator{
alias: alias,
unknown: []byte(str),
}
return this, nil
}
this := &LocationPropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "location")
}
@ -2162,7 +2161,7 @@ func (this LocationPropertyIterator) serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// LocationProperty is the non-functional property "location". It is permitted to

View file

@ -12,7 +12,7 @@ import (
type LongitudeProperty struct {
floatMember float64
hasFloatMember bool
unknown []byte
unknown interface{}
iri *url.URL
alias string
}
@ -49,15 +49,12 @@ func DeserializeLongitudeProperty(m map[string]interface{}, aliasMap map[string]
hasFloatMember: true,
}
return this, nil
} else if str, ok := i.(string); ok {
this := &LongitudeProperty{
alias: alias,
unknown: []byte(str),
}
return this, nil
} else {
return nil, fmt.Errorf("could not deserialize %q property", "longitude")
}
this := &LongitudeProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
@ -179,7 +176,7 @@ func (this LongitudeProperty) Serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// Set sets the value of this property. Calling IsFloat afterwards will return

View file

@ -12,7 +12,7 @@ import (
type MediaTypeProperty struct {
rfc2045Member string
hasRfc2045Member bool
unknown []byte
unknown interface{}
iri *url.URL
alias string
}
@ -49,15 +49,12 @@ func DeserializeMediaTypeProperty(m map[string]interface{}, aliasMap map[string]
rfc2045Member: v,
}
return this, nil
} else if str, ok := i.(string); ok {
this := &MediaTypeProperty{
alias: alias,
unknown: []byte(str),
}
return this, nil
} else {
return nil, fmt.Errorf("could not deserialize %q property", "mediaType")
}
this := &MediaTypeProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
@ -179,7 +176,7 @@ func (this MediaTypeProperty) Serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// Set sets the value of this property. Calling IsRfc2045 afterwards will return

View file

@ -17,7 +17,7 @@ type NamePropertyIterator struct {
stringMember string
hasStringMember bool
langStringMember map[string]string
unknown []byte
unknown interface{}
iri *url.URL
alias string
langMap map[string]string
@ -62,13 +62,12 @@ func deserializeNamePropertyIterator(i interface{}, aliasMap map[string]string)
langStringMember: v,
}
return this, nil
} else if str, ok := i.(string); ok {
this := &NamePropertyIterator{
alias: alias,
unknown: []byte(str),
}
return this, nil
}
this := &NamePropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "name")
}
@ -291,7 +290,7 @@ func (this NamePropertyIterator) serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// NameProperty is the non-functional property "name". It is permitted to have one

View file

@ -16,7 +16,7 @@ type NextProperty struct {
LinkMember vocab.LinkInterface
MentionMember vocab.MentionInterface
OrderedCollectionPageMember vocab.OrderedCollectionPageInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
}
@ -72,15 +72,12 @@ func DeserializeNextProperty(m map[string]interface{}, aliasMap map[string]strin
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &NextProperty{
alias: alias,
unknown: []byte(str),
}
return this, nil
} else {
return nil, fmt.Errorf("could not deserialize %q property", "next")
}
this := &NextProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
@ -267,7 +264,7 @@ func (this NextProperty) Serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// SetCollectionPage sets the value of this property. Calling IsCollectionPage

View file

@ -66,7 +66,7 @@ type ObjectPropertyIterator struct {
UpdateMember vocab.UpdateInterface
VideoMember vocab.VideoInterface
ViewMember vocab.ViewInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
myIdx int
@ -423,13 +423,12 @@ func deserializeObjectPropertyIterator(i interface{}, aliasMap map[string]string
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &ObjectPropertyIterator{
alias: alias,
unknown: []byte(str),
}
return this, nil
}
this := &ObjectPropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "object")
}
@ -2162,7 +2161,7 @@ func (this ObjectPropertyIterator) serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// ObjectProperty is the non-functional property "object". It is permitted to have

View file

@ -66,7 +66,7 @@ type OneOfPropertyIterator struct {
UpdateMember vocab.UpdateInterface
VideoMember vocab.VideoInterface
ViewMember vocab.ViewInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
myIdx int
@ -423,13 +423,12 @@ func deserializeOneOfPropertyIterator(i interface{}, aliasMap map[string]string)
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &OneOfPropertyIterator{
alias: alias,
unknown: []byte(str),
}
return this, nil
}
this := &OneOfPropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "oneOf")
}
@ -2162,7 +2161,7 @@ func (this OneOfPropertyIterator) serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// OneOfProperty is the non-functional property "oneOf". It is permitted to have

View file

@ -66,7 +66,7 @@ type OriginPropertyIterator struct {
UpdateMember vocab.UpdateInterface
VideoMember vocab.VideoInterface
ViewMember vocab.ViewInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
myIdx int
@ -423,13 +423,12 @@ func deserializeOriginPropertyIterator(i interface{}, aliasMap map[string]string
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &OriginPropertyIterator{
alias: alias,
unknown: []byte(str),
}
return this, nil
}
this := &OriginPropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "origin")
}
@ -2162,7 +2161,7 @@ func (this OriginPropertyIterator) serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// OriginProperty is the non-functional property "origin". It is permitted to have

View file

@ -0,0 +1,15 @@
// Package propertyoutbox contains the implementation for the outbox 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 propertyoutbox

View file

@ -0,0 +1,20 @@
package propertyoutbox
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 {
// DeserializeOrderedCollectionActivityStreams returns the deserialization
// method for the "OrderedCollectionInterface" non-functional property
// in the vocabulary "ActivityStreams"
DeserializeOrderedCollectionActivityStreams() func(map[string]interface{}, map[string]string) (vocab.OrderedCollectionInterface, 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
}

View file

@ -0,0 +1,195 @@
package propertyoutbox
import (
"fmt"
vocab "github.com/go-fed/activity/streams/vocab"
"net/url"
)
// OutboxProperty is the functional property "outbox". It is permitted to be a
// single nilable value type.
type OutboxProperty struct {
OrderedCollectionMember vocab.OrderedCollectionInterface
unknown interface{}
iri *url.URL
alias string
}
// DeserializeOutboxProperty creates a "outbox" property from an interface
// representation that has been unmarshalled from a text or binary format.
func DeserializeOutboxProperty(m map[string]interface{}, aliasMap map[string]string) (*OutboxProperty, error) {
alias := ""
if a, ok := aliasMap["https://www.w3.org/TR/activitystreams-vocabulary"]; ok {
alias = a
}
propName := "outbox"
if len(alias) > 0 {
// Use alias both to find the property, and set within the property.
propName = fmt.Sprintf("%s:%s", alias, "outbox")
}
if i, ok := m[propName]; 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 := &OutboxProperty{
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 := &OutboxProperty{
OrderedCollectionMember: v,
alias: alias,
}
return this, nil
}
}
this := &OutboxProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
// NewOutboxProperty creates a new outbox property.
func NewOutboxProperty() *OutboxProperty {
return &OutboxProperty{alias: ""}
}
// Clear ensures no value of this property is set. Calling IsOrderedCollection
// afterwards will return false.
func (this *OutboxProperty) Clear() {
this.unknown = nil
this.iri = nil
this.OrderedCollectionMember = nil
}
// Get returns the value of this property. When IsOrderedCollection returns false,
// Get will return any arbitrary value.
func (this OutboxProperty) Get() vocab.OrderedCollectionInterface {
return this.OrderedCollectionMember
}
// GetIRI returns the IRI of this property. When IsIRI returns false, GetIRI will
// return any arbitrary value.
func (this OutboxProperty) GetIRI() *url.URL {
return this.iri
}
// HasAny returns true if the value or IRI is set.
func (this OutboxProperty) HasAny() bool {
return this.IsOrderedCollection() || this.iri != nil
}
// IsIRI returns true if this property is an IRI.
func (this OutboxProperty) IsIRI() bool {
return this.iri != nil
}
// IsOrderedCollection returns true if this property is set and not an IRI.
func (this OutboxProperty) IsOrderedCollection() bool {
return this.OrderedCollectionMember != 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 OutboxProperty) JSONLDContext() map[string]string {
m := map[string]string{"https://www.w3.org/TR/activitystreams-vocabulary": this.alias}
var child map[string]string
if this.IsOrderedCollection() {
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 OutboxProperty) KindIndex() int {
if this.IsOrderedCollection() {
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 OutboxProperty) LessThan(o vocab.OutboxPropertyInterface) 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.IsOrderedCollection() && !o.IsOrderedCollection() {
// Both are unknowns.
return false
} else if this.IsOrderedCollection() && !o.IsOrderedCollection() {
// Values are always greater than unknown values.
return false
} else if !this.IsOrderedCollection() && o.IsOrderedCollection() {
// 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: "outbox".
func (this OutboxProperty) Name() string {
return "outbox"
}
// 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 OutboxProperty) Serialize() (interface{}, error) {
if this.IsOrderedCollection() {
return this.Get().Serialize()
} else if this.IsIRI() {
return this.iri.String(), nil
}
return this.unknown, nil
}
// Set sets the value of this property. Calling IsOrderedCollection afterwards
// will return true.
func (this *OutboxProperty) Set(v vocab.OrderedCollectionInterface) {
this.Clear()
this.OrderedCollectionMember = v
}
// SetIRI sets the value of this property. Calling IsIRI afterwards will return
// true.
func (this *OutboxProperty) SetIRI(v *url.URL) {
this.Clear()
this.iri = v
}

View file

@ -18,7 +18,7 @@ type PartOfProperty struct {
MentionMember vocab.MentionInterface
OrderedCollectionMember vocab.OrderedCollectionInterface
OrderedCollectionPageMember vocab.OrderedCollectionPageInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
}
@ -86,15 +86,12 @@ func DeserializePartOfProperty(m map[string]interface{}, aliasMap map[string]str
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &PartOfProperty{
alias: alias,
unknown: []byte(str),
}
return this, nil
} else {
return nil, fmt.Errorf("could not deserialize %q property", "partOf")
}
this := &PartOfProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
@ -330,7 +327,7 @@ func (this PartOfProperty) Serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// SetCollection sets the value of this property. Calling IsCollection afterwards

View file

@ -0,0 +1,15 @@
// Package propertypreferredusername contains the implementation for the
// preferredUsername 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 propertypreferredusername

View file

@ -0,0 +1,13 @@
package propertypreferredusername
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
}

View file

@ -0,0 +1,282 @@
package propertypreferredusername
import (
"fmt"
langstring "github.com/go-fed/activity/streams/values/langString"
string1 "github.com/go-fed/activity/streams/values/string"
vocab "github.com/go-fed/activity/streams/vocab"
"net/url"
)
// PreferredUsernameProperty is the functional property "preferredUsername". 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 PreferredUsernameProperty struct {
stringMember string
hasStringMember bool
langStringMember map[string]string
unknown interface{}
iri *url.URL
alias string
langMap map[string]string
}
// DeserializePreferredUsernameProperty creates a "preferredUsername" property
// from an interface representation that has been unmarshalled from a text or
// binary format.
func DeserializePreferredUsernameProperty(m map[string]interface{}, aliasMap map[string]string) (*PreferredUsernameProperty, error) {
alias := ""
if a, ok := aliasMap["https://www.w3.org/TR/activitystreams-vocabulary"]; ok {
alias = a
}
propName := "preferredUsername"
if len(alias) > 0 {
// Use alias both to find the property, and set within the property.
propName = fmt.Sprintf("%s:%s", alias, "preferredUsername")
}
if i, ok := m[propName]; 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 := &PreferredUsernameProperty{
alias: alias,
iri: u,
}
return this, nil
}
}
if v, err := string1.DeserializeString(i); err == nil {
this := &PreferredUsernameProperty{
alias: alias,
hasStringMember: true,
stringMember: v,
}
return this, nil
} else if v, err := langstring.DeserializeLangString(i); err == nil {
this := &PreferredUsernameProperty{
alias: alias,
langStringMember: v,
}
return this, nil
}
this := &PreferredUsernameProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
// NewPreferredUsernameProperty creates a new preferredUsername property.
func NewPreferredUsernameProperty() *PreferredUsernameProperty {
return &PreferredUsernameProperty{alias: ""}
}
// Clear ensures no value and no language map for this property is set. Calling
// HasAny or any of the 'Is' methods afterwards will return false.
func (this *PreferredUsernameProperty) Clear() {
this.hasStringMember = false
this.langStringMember = nil
this.unknown = nil
this.iri = nil
this.langMap = nil
}
// GetIRI returns the IRI of this property. When IsIRI returns false, GetIRI will
// return an arbitrary value.
func (this PreferredUsernameProperty) GetIRI() *url.URL {
return this.iri
}
// GetLangString returns the value of this property. When IsLangString returns
// false, GetLangString will return an arbitrary value.
func (this PreferredUsernameProperty) GetLangString() map[string]string {
return this.langStringMember
}
// GetLanguage returns the value for the specified BCP47 language code, or an
// empty string if it is either not a language map or no value is present.
func (this PreferredUsernameProperty) GetLanguage(bcp47 string) string {
if this.langMap == nil {
return ""
} else if v, ok := this.langMap[bcp47]; ok {
return v
} else {
return ""
}
}
// GetString returns the value of this property. When IsString returns false,
// GetString will return an arbitrary value.
func (this PreferredUsernameProperty) GetString() string {
return this.stringMember
}
// HasAny returns true if any of the values are set, except for the natural
// language map. When true, the specific has, getter, and setter methods may
// be used to determine what kind of value there is to access and set this
// property. To determine if the property was set as a natural language map,
// use the IsLanguageMap method instead.
func (this PreferredUsernameProperty) HasAny() bool {
return this.IsString() ||
this.IsLangString() ||
this.iri != nil
}
// HasLanguage returns true if the natural language map has an entry for the
// specified BCP47 language code.
func (this PreferredUsernameProperty) HasLanguage(bcp47 string) bool {
if this.langMap == nil {
return false
} else {
_, ok := this.langMap[bcp47]
return ok
}
}
// IsIRI returns true if this property is an IRI. When true, use GetIRI and SetIRI
// to access and set this property
func (this PreferredUsernameProperty) IsIRI() bool {
return this.iri != nil
}
// IsLangString returns true if this property has a type of "langString". When
// true, use the GetLangString and SetLangString methods to access and set
// this property.. To determine if the property was set as a natural language
// map, use the IsLanguageMap method instead.
func (this PreferredUsernameProperty) IsLangString() bool {
return this.langStringMember != nil
}
// IsLanguageMap determines if this property is represented by a natural language
// map. When true, use HasLanguage, GetLanguage, and SetLanguage methods to
// access and mutate the natural language map. The Clear method can be used to
// clear the natural language map. Note that this method is only used for
// natural language representations, and does not determine the presence nor
// absence of other values for this property.
func (this PreferredUsernameProperty) IsLanguageMap() bool {
return this.langMap != nil
}
// IsString returns true if this property has a type of "string". When true, use
// the GetString and SetString methods to access and set this property.. To
// determine if the property was set as a natural language map, use the
// IsLanguageMap method instead.
func (this PreferredUsernameProperty) IsString() 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 PreferredUsernameProperty) JSONLDContext() map[string]string {
m := map[string]string{"https://www.w3.org/TR/activitystreams-vocabulary": 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 PreferredUsernameProperty) KindIndex() int {
if this.IsString() {
return 0
}
if this.IsLangString() {
return 1
}
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 PreferredUsernameProperty) LessThan(o vocab.PreferredUsernamePropertyInterface) bool {
idx1 := this.KindIndex()
idx2 := o.KindIndex()
if idx1 < idx2 {
return true
} else if idx1 > idx2 {
return false
} else if this.IsString() {
return string1.LessString(this.GetString(), o.GetString())
} else if this.IsLangString() {
return langstring.LessLangString(this.GetLangString(), o.GetLangString())
} else if this.IsIRI() {
return this.iri.String() < o.GetIRI().String()
}
return false
}
// Name returns the name of this property: "preferredUsername".
func (this PreferredUsernameProperty) Name() string {
return "preferredUsername"
}
// 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 PreferredUsernameProperty) Serialize() (interface{}, error) {
if this.IsString() {
return string1.SerializeString(this.GetString())
} else if this.IsLangString() {
return langstring.SerializeLangString(this.GetLangString())
} else if this.IsIRI() {
return this.iri.String(), nil
}
return this.unknown, nil
}
// SetIRI sets the value of this property. Calling IsIRI afterwards returns true.
func (this *PreferredUsernameProperty) SetIRI(v *url.URL) {
this.Clear()
this.iri = v
}
// SetLangString sets the value of this property and clears the natural language
// map. Calling IsLangString afterwards will return true. Calling
// IsLanguageMap afterwards returns false.
func (this *PreferredUsernameProperty) SetLangString(v map[string]string) {
this.Clear()
this.langStringMember = v
}
// SetLanguage sets the value for the specified BCP47 language code.
func (this *PreferredUsernameProperty) SetLanguage(bcp47, value string) {
this.hasStringMember = false
this.langStringMember = nil
this.unknown = nil
this.iri = nil
if this.langMap == nil {
this.langMap = make(map[string]string)
}
this.langMap[bcp47] = value
}
// SetString sets the value of this property and clears the natural language map.
// Calling IsString afterwards will return true. Calling IsLanguageMap
// afterwards returns false.
func (this *PreferredUsernameProperty) SetString(v string) {
this.Clear()
this.stringMember = v
this.hasStringMember = true
}

View file

@ -16,7 +16,7 @@ type PrevProperty struct {
LinkMember vocab.LinkInterface
MentionMember vocab.MentionInterface
OrderedCollectionPageMember vocab.OrderedCollectionPageInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
}
@ -72,15 +72,12 @@ func DeserializePrevProperty(m map[string]interface{}, aliasMap map[string]strin
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &PrevProperty{
alias: alias,
unknown: []byte(str),
}
return this, nil
} else {
return nil, fmt.Errorf("could not deserialize %q property", "prev")
}
this := &PrevProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
@ -267,7 +264,7 @@ func (this PrevProperty) Serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// SetCollectionPage sets the value of this property. Calling IsCollectionPage

View file

@ -66,7 +66,7 @@ type PreviewPropertyIterator struct {
UpdateMember vocab.UpdateInterface
VideoMember vocab.VideoInterface
ViewMember vocab.ViewInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
myIdx int
@ -423,13 +423,12 @@ func deserializePreviewPropertyIterator(i interface{}, aliasMap map[string]strin
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &PreviewPropertyIterator{
alias: alias,
unknown: []byte(str),
}
return this, nil
}
this := &PreviewPropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "preview")
}
@ -2162,7 +2161,7 @@ func (this PreviewPropertyIterator) serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// PreviewProperty is the non-functional property "preview". It is permitted to

View file

@ -13,7 +13,7 @@ import (
type PublishedProperty struct {
dateTimeMember time.Time
hasDateTimeMember bool
unknown []byte
unknown interface{}
iri *url.URL
alias string
}
@ -50,15 +50,12 @@ func DeserializePublishedProperty(m map[string]interface{}, aliasMap map[string]
hasDateTimeMember: true,
}
return this, nil
} else if str, ok := i.(string); ok {
this := &PublishedProperty{
alias: alias,
unknown: []byte(str),
}
return this, nil
} else {
return nil, fmt.Errorf("could not deserialize %q property", "published")
}
this := &PublishedProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
@ -180,7 +177,7 @@ func (this PublishedProperty) Serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// Set sets the value of this property. Calling IsDateTime afterwards will return

View file

@ -12,7 +12,7 @@ import (
type RadiusProperty struct {
floatMember float64
hasFloatMember bool
unknown []byte
unknown interface{}
iri *url.URL
alias string
}
@ -49,15 +49,12 @@ func DeserializeRadiusProperty(m map[string]interface{}, aliasMap map[string]str
hasFloatMember: true,
}
return this, nil
} else if str, ok := i.(string); ok {
this := &RadiusProperty{
alias: alias,
unknown: []byte(str),
}
return this, nil
} else {
return nil, fmt.Errorf("could not deserialize %q property", "radius")
}
this := &RadiusProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
@ -179,7 +176,7 @@ func (this RadiusProperty) Serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// Set sets the value of this property. Calling IsFloat afterwards will return

View file

@ -12,7 +12,7 @@ import (
type RelPropertyIterator struct {
rfc5988Member string
hasRfc5988Member bool
unknown []byte
unknown interface{}
iri *url.URL
alias string
myIdx int
@ -50,13 +50,12 @@ func deserializeRelPropertyIterator(i interface{}, aliasMap map[string]string) (
rfc5988Member: v,
}
return this, nil
} else if str, ok := i.(string); ok {
this := &RelPropertyIterator{
alias: alias,
unknown: []byte(str),
}
return this, nil
}
this := &RelPropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "rel")
}
@ -205,7 +204,7 @@ func (this RelPropertyIterator) serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// RelProperty is the non-functional property "rel". It is permitted to have one

View file

@ -64,7 +64,7 @@ type RelationshipPropertyIterator struct {
UpdateMember vocab.UpdateInterface
VideoMember vocab.VideoInterface
ViewMember vocab.ViewInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
myIdx int
@ -409,13 +409,12 @@ func deserializeRelationshipPropertyIterator(i interface{}, aliasMap map[string]
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &RelationshipPropertyIterator{
alias: alias,
unknown: []byte(str),
}
return this, nil
}
this := &RelationshipPropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "relationship")
}
@ -2089,7 +2088,7 @@ func (this RelationshipPropertyIterator) serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// RelationshipProperty is the non-functional property "relationship". It is

View file

@ -16,7 +16,7 @@ type RepliesProperty struct {
CollectionPageMember vocab.CollectionPageInterface
OrderedCollectionMember vocab.OrderedCollectionInterface
OrderedCollectionPageMember vocab.OrderedCollectionPageInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
}
@ -72,15 +72,12 @@ func DeserializeRepliesProperty(m map[string]interface{}, aliasMap map[string]st
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &RepliesProperty{
alias: alias,
unknown: []byte(str),
}
return this, nil
} else {
return nil, fmt.Errorf("could not deserialize %q property", "replies")
}
this := &RepliesProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
@ -270,7 +267,7 @@ func (this RepliesProperty) Serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// SetCollection sets the value of this property. Calling IsCollection afterwards

View file

@ -66,7 +66,7 @@ type ResultPropertyIterator struct {
UpdateMember vocab.UpdateInterface
VideoMember vocab.VideoInterface
ViewMember vocab.ViewInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
myIdx int
@ -423,13 +423,12 @@ func deserializeResultPropertyIterator(i interface{}, aliasMap map[string]string
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &ResultPropertyIterator{
alias: alias,
unknown: []byte(str),
}
return this, nil
}
this := &ResultPropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "result")
}
@ -2162,7 +2161,7 @@ func (this ResultPropertyIterator) serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// ResultProperty is the non-functional property "result". It is permitted to have

View file

@ -0,0 +1,15 @@
// Package propertyshares contains the implementation for the shares 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 propertyshares

View file

@ -0,0 +1,32 @@
package propertyshares
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 {
// DeserializeCollectionActivityStreams returns the deserialization method
// for the "CollectionInterface" non-functional property in the
// vocabulary "ActivityStreams"
DeserializeCollectionActivityStreams() func(map[string]interface{}, map[string]string) (vocab.CollectionInterface, error)
// DeserializeCollectionPageActivityStreams returns the deserialization
// method for the "CollectionPageInterface" non-functional property in
// the vocabulary "ActivityStreams"
DeserializeCollectionPageActivityStreams() func(map[string]interface{}, map[string]string) (vocab.CollectionPageInterface, error)
// DeserializeOrderedCollectionActivityStreams returns the deserialization
// method for the "OrderedCollectionInterface" non-functional property
// in the vocabulary "ActivityStreams"
DeserializeOrderedCollectionActivityStreams() func(map[string]interface{}, map[string]string) (vocab.OrderedCollectionInterface, error)
// DeserializeOrderedCollectionPageActivityStreams returns the
// deserialization method for the "OrderedCollectionPageInterface"
// non-functional property in the vocabulary "ActivityStreams"
DeserializeOrderedCollectionPageActivityStreams() func(map[string]interface{}, map[string]string) (vocab.OrderedCollectionPageInterface, 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
}

View file

@ -0,0 +1,305 @@
package propertyshares
import (
"fmt"
vocab "github.com/go-fed/activity/streams/vocab"
"net/url"
)
// SharesProperty is the functional property "shares". 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 SharesProperty struct {
OrderedCollectionMember vocab.OrderedCollectionInterface
CollectionMember vocab.CollectionInterface
CollectionPageMember vocab.CollectionPageInterface
OrderedCollectionPageMember vocab.OrderedCollectionPageInterface
unknown interface{}
iri *url.URL
alias string
}
// DeserializeSharesProperty creates a "shares" property from an interface
// representation that has been unmarshalled from a text or binary format.
func DeserializeSharesProperty(m map[string]interface{}, aliasMap map[string]string) (*SharesProperty, error) {
alias := ""
if a, ok := aliasMap["https://www.w3.org/TR/activitystreams-vocabulary"]; ok {
alias = a
}
propName := "shares"
if len(alias) > 0 {
// Use alias both to find the property, and set within the property.
propName = fmt.Sprintf("%s:%s", alias, "shares")
}
if i, ok := m[propName]; 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 := &SharesProperty{
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 := &SharesProperty{
OrderedCollectionMember: v,
alias: alias,
}
return this, nil
} else if v, err := mgr.DeserializeCollectionActivityStreams()(m, aliasMap); err == nil {
this := &SharesProperty{
CollectionMember: v,
alias: alias,
}
return this, nil
} else if v, err := mgr.DeserializeCollectionPageActivityStreams()(m, aliasMap); err == nil {
this := &SharesProperty{
CollectionPageMember: v,
alias: alias,
}
return this, nil
} else if v, err := mgr.DeserializeOrderedCollectionPageActivityStreams()(m, aliasMap); err == nil {
this := &SharesProperty{
OrderedCollectionPageMember: v,
alias: alias,
}
return this, nil
}
}
this := &SharesProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
// NewSharesProperty creates a new shares property.
func NewSharesProperty() *SharesProperty {
return &SharesProperty{alias: ""}
}
// Clear ensures no value of this property is set. Calling HasAny or any of the
// 'Is' methods afterwards will return false.
func (this *SharesProperty) Clear() {
this.OrderedCollectionMember = nil
this.CollectionMember = nil
this.CollectionPageMember = nil
this.OrderedCollectionPageMember = nil
this.unknown = nil
this.iri = nil
}
// GetCollection returns the value of this property. When IsCollection returns
// false, GetCollection will return an arbitrary value.
func (this SharesProperty) GetCollection() vocab.CollectionInterface {
return this.CollectionMember
}
// GetCollectionPage returns the value of this property. When IsCollectionPage
// returns false, GetCollectionPage will return an arbitrary value.
func (this SharesProperty) GetCollectionPage() vocab.CollectionPageInterface {
return this.CollectionPageMember
}
// GetIRI returns the IRI of this property. When IsIRI returns false, GetIRI will
// return an arbitrary value.
func (this SharesProperty) GetIRI() *url.URL {
return this.iri
}
// GetOrderedCollection returns the value of this property. When
// IsOrderedCollection returns false, GetOrderedCollection will return an
// arbitrary value.
func (this SharesProperty) GetOrderedCollection() vocab.OrderedCollectionInterface {
return this.OrderedCollectionMember
}
// GetOrderedCollectionPage returns the value of this property. When
// IsOrderedCollectionPage returns false, GetOrderedCollectionPage will return
// an arbitrary value.
func (this SharesProperty) GetOrderedCollectionPage() vocab.OrderedCollectionPageInterface {
return this.OrderedCollectionPageMember
}
// HasAny returns true if any of the different values is set.
func (this SharesProperty) HasAny() bool {
return this.IsOrderedCollection() ||
this.IsCollection() ||
this.IsCollectionPage() ||
this.IsOrderedCollectionPage() ||
this.iri != nil
}
// IsCollection returns true if this property has a type of "Collection". When
// true, use the GetCollection and SetCollection methods to access and set
// this property.
func (this SharesProperty) IsCollection() bool {
return this.CollectionMember != nil
}
// IsCollectionPage returns true if this property has a type of "CollectionPage".
// When true, use the GetCollectionPage and SetCollectionPage methods to
// access and set this property.
func (this SharesProperty) IsCollectionPage() bool {
return this.CollectionPageMember != nil
}
// IsIRI returns true if this property is an IRI. When true, use GetIRI and SetIRI
// to access and set this property
func (this SharesProperty) IsIRI() bool {
return this.iri != nil
}
// IsOrderedCollection returns true if this property has a type of
// "OrderedCollection". When true, use the GetOrderedCollection and
// SetOrderedCollection methods to access and set this property.
func (this SharesProperty) IsOrderedCollection() bool {
return this.OrderedCollectionMember != nil
}
// IsOrderedCollectionPage returns true if this property has a type of
// "OrderedCollectionPage". When true, use the GetOrderedCollectionPage and
// SetOrderedCollectionPage methods to access and set this property.
func (this SharesProperty) IsOrderedCollectionPage() bool {
return this.OrderedCollectionPageMember != 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 SharesProperty) JSONLDContext() map[string]string {
m := map[string]string{"https://www.w3.org/TR/activitystreams-vocabulary": this.alias}
var child map[string]string
if this.IsOrderedCollection() {
child = this.GetOrderedCollection().JSONLDContext()
} else if this.IsCollection() {
child = this.GetCollection().JSONLDContext()
} else if this.IsCollectionPage() {
child = this.GetCollectionPage().JSONLDContext()
} else if this.IsOrderedCollectionPage() {
child = this.GetOrderedCollectionPage().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 SharesProperty) KindIndex() int {
if this.IsOrderedCollection() {
return 0
}
if this.IsCollection() {
return 1
}
if this.IsCollectionPage() {
return 2
}
if this.IsOrderedCollectionPage() {
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 SharesProperty) LessThan(o vocab.SharesPropertyInterface) bool {
idx1 := this.KindIndex()
idx2 := o.KindIndex()
if idx1 < idx2 {
return true
} else if idx1 > idx2 {
return false
} else if this.IsOrderedCollection() {
return this.GetOrderedCollection().LessThan(o.GetOrderedCollection())
} else if this.IsCollection() {
return this.GetCollection().LessThan(o.GetCollection())
} else if this.IsCollectionPage() {
return this.GetCollectionPage().LessThan(o.GetCollectionPage())
} else if this.IsOrderedCollectionPage() {
return this.GetOrderedCollectionPage().LessThan(o.GetOrderedCollectionPage())
} else if this.IsIRI() {
return this.iri.String() < o.GetIRI().String()
}
return false
}
// Name returns the name of this property: "shares".
func (this SharesProperty) Name() string {
return "shares"
}
// 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 SharesProperty) Serialize() (interface{}, error) {
if this.IsOrderedCollection() {
return this.GetOrderedCollection().Serialize()
} else if this.IsCollection() {
return this.GetCollection().Serialize()
} else if this.IsCollectionPage() {
return this.GetCollectionPage().Serialize()
} else if this.IsOrderedCollectionPage() {
return this.GetOrderedCollectionPage().Serialize()
} else if this.IsIRI() {
return this.iri.String(), nil
}
return this.unknown, nil
}
// SetCollection sets the value of this property. Calling IsCollection afterwards
// returns true.
func (this *SharesProperty) SetCollection(v vocab.CollectionInterface) {
this.Clear()
this.CollectionMember = v
}
// SetCollectionPage sets the value of this property. Calling IsCollectionPage
// afterwards returns true.
func (this *SharesProperty) SetCollectionPage(v vocab.CollectionPageInterface) {
this.Clear()
this.CollectionPageMember = v
}
// SetIRI sets the value of this property. Calling IsIRI afterwards returns true.
func (this *SharesProperty) SetIRI(v *url.URL) {
this.Clear()
this.iri = v
}
// SetOrderedCollection sets the value of this property. Calling
// IsOrderedCollection afterwards returns true.
func (this *SharesProperty) SetOrderedCollection(v vocab.OrderedCollectionInterface) {
this.Clear()
this.OrderedCollectionMember = v
}
// SetOrderedCollectionPage sets the value of this property. Calling
// IsOrderedCollectionPage afterwards returns true.
func (this *SharesProperty) SetOrderedCollectionPage(v vocab.OrderedCollectionPageInterface) {
this.Clear()
this.OrderedCollectionPageMember = v
}

View file

@ -12,7 +12,7 @@ import (
type StartIndexProperty struct {
nonNegativeIntegerMember int
hasNonNegativeIntegerMember bool
unknown []byte
unknown interface{}
iri *url.URL
alias string
}
@ -49,15 +49,12 @@ func DeserializeStartIndexProperty(m map[string]interface{}, aliasMap map[string
nonNegativeIntegerMember: v,
}
return this, nil
} else if str, ok := i.(string); ok {
this := &StartIndexProperty{
alias: alias,
unknown: []byte(str),
}
return this, nil
} else {
return nil, fmt.Errorf("could not deserialize %q property", "startIndex")
}
this := &StartIndexProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
@ -179,7 +176,7 @@ func (this StartIndexProperty) Serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// Set sets the value of this property. Calling IsNonNegativeInteger afterwards

View file

@ -13,7 +13,7 @@ import (
type StartTimeProperty struct {
dateTimeMember time.Time
hasDateTimeMember bool
unknown []byte
unknown interface{}
iri *url.URL
alias string
}
@ -50,15 +50,12 @@ func DeserializeStartTimeProperty(m map[string]interface{}, aliasMap map[string]
hasDateTimeMember: true,
}
return this, nil
} else if str, ok := i.(string); ok {
this := &StartTimeProperty{
alias: alias,
unknown: []byte(str),
}
return this, nil
} else {
return nil, fmt.Errorf("could not deserialize %q property", "startTime")
}
this := &StartTimeProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
@ -180,7 +177,7 @@ func (this StartTimeProperty) Serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// Set sets the value of this property. Calling IsDateTime afterwards will return

View file

@ -0,0 +1,15 @@
// Package propertystreams contains the implementation for the streams 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 propertystreams

View file

@ -0,0 +1,32 @@
package propertystreams
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 {
// DeserializeCollectionActivityStreams returns the deserialization method
// for the "CollectionInterface" non-functional property in the
// vocabulary "ActivityStreams"
DeserializeCollectionActivityStreams() func(map[string]interface{}, map[string]string) (vocab.CollectionInterface, error)
// DeserializeCollectionPageActivityStreams returns the deserialization
// method for the "CollectionPageInterface" non-functional property in
// the vocabulary "ActivityStreams"
DeserializeCollectionPageActivityStreams() func(map[string]interface{}, map[string]string) (vocab.CollectionPageInterface, error)
// DeserializeOrderedCollectionActivityStreams returns the deserialization
// method for the "OrderedCollectionInterface" non-functional property
// in the vocabulary "ActivityStreams"
DeserializeOrderedCollectionActivityStreams() func(map[string]interface{}, map[string]string) (vocab.OrderedCollectionInterface, error)
// DeserializeOrderedCollectionPageActivityStreams returns the
// deserialization method for the "OrderedCollectionPageInterface"
// non-functional property in the vocabulary "ActivityStreams"
DeserializeOrderedCollectionPageActivityStreams() func(map[string]interface{}, map[string]string) (vocab.OrderedCollectionPageInterface, 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
}

View file

@ -0,0 +1,720 @@
package propertystreams
import (
"fmt"
vocab "github.com/go-fed/activity/streams/vocab"
"net/url"
)
// StreamsPropertyIterator 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 StreamsPropertyIterator struct {
OrderedCollectionMember vocab.OrderedCollectionInterface
CollectionMember vocab.CollectionInterface
CollectionPageMember vocab.CollectionPageInterface
OrderedCollectionPageMember vocab.OrderedCollectionPageInterface
unknown interface{}
iri *url.URL
alias string
myIdx int
parent vocab.StreamsPropertyInterface
}
// NewStreamsPropertyIterator creates a new streams property.
func NewStreamsPropertyIterator() *StreamsPropertyIterator {
return &StreamsPropertyIterator{alias: ""}
}
// deserializeStreamsPropertyIterator creates an iterator from an element that has
// been unmarshalled from a text or binary format.
func deserializeStreamsPropertyIterator(i interface{}, aliasMap map[string]string) (*StreamsPropertyIterator, error) {
alias := ""
if a, ok := aliasMap["https://www.w3.org/TR/activitystreams-vocabulary"]; 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 := &StreamsPropertyIterator{
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 := &StreamsPropertyIterator{
OrderedCollectionMember: v,
alias: alias,
}
return this, nil
} else if v, err := mgr.DeserializeCollectionActivityStreams()(m, aliasMap); err == nil {
this := &StreamsPropertyIterator{
CollectionMember: v,
alias: alias,
}
return this, nil
} else if v, err := mgr.DeserializeCollectionPageActivityStreams()(m, aliasMap); err == nil {
this := &StreamsPropertyIterator{
CollectionPageMember: v,
alias: alias,
}
return this, nil
} else if v, err := mgr.DeserializeOrderedCollectionPageActivityStreams()(m, aliasMap); err == nil {
this := &StreamsPropertyIterator{
OrderedCollectionPageMember: v,
alias: alias,
}
return this, nil
}
}
this := &StreamsPropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "streams")
}
// GetCollection returns the value of this property. When IsCollection returns
// false, GetCollection will return an arbitrary value.
func (this StreamsPropertyIterator) GetCollection() vocab.CollectionInterface {
return this.CollectionMember
}
// GetCollectionPage returns the value of this property. When IsCollectionPage
// returns false, GetCollectionPage will return an arbitrary value.
func (this StreamsPropertyIterator) GetCollectionPage() vocab.CollectionPageInterface {
return this.CollectionPageMember
}
// GetIRI returns the IRI of this property. When IsIRI returns false, GetIRI will
// return an arbitrary value.
func (this StreamsPropertyIterator) GetIRI() *url.URL {
return this.iri
}
// GetOrderedCollection returns the value of this property. When
// IsOrderedCollection returns false, GetOrderedCollection will return an
// arbitrary value.
func (this StreamsPropertyIterator) GetOrderedCollection() vocab.OrderedCollectionInterface {
return this.OrderedCollectionMember
}
// GetOrderedCollectionPage returns the value of this property. When
// IsOrderedCollectionPage returns false, GetOrderedCollectionPage will return
// an arbitrary value.
func (this StreamsPropertyIterator) GetOrderedCollectionPage() vocab.OrderedCollectionPageInterface {
return this.OrderedCollectionPageMember
}
// HasAny returns true if any of the different values is set.
func (this StreamsPropertyIterator) HasAny() bool {
return this.IsOrderedCollection() ||
this.IsCollection() ||
this.IsCollectionPage() ||
this.IsOrderedCollectionPage() ||
this.iri != nil
}
// IsCollection returns true if this property has a type of "Collection". When
// true, use the GetCollection and SetCollection methods to access and set
// this property.
func (this StreamsPropertyIterator) IsCollection() bool {
return this.CollectionMember != nil
}
// IsCollectionPage returns true if this property has a type of "CollectionPage".
// When true, use the GetCollectionPage and SetCollectionPage methods to
// access and set this property.
func (this StreamsPropertyIterator) IsCollectionPage() bool {
return this.CollectionPageMember != nil
}
// IsIRI returns true if this property is an IRI. When true, use GetIRI and SetIRI
// to access and set this property
func (this StreamsPropertyIterator) IsIRI() bool {
return this.iri != nil
}
// IsOrderedCollection returns true if this property has a type of
// "OrderedCollection". When true, use the GetOrderedCollection and
// SetOrderedCollection methods to access and set this property.
func (this StreamsPropertyIterator) IsOrderedCollection() bool {
return this.OrderedCollectionMember != nil
}
// IsOrderedCollectionPage returns true if this property has a type of
// "OrderedCollectionPage". When true, use the GetOrderedCollectionPage and
// SetOrderedCollectionPage methods to access and set this property.
func (this StreamsPropertyIterator) IsOrderedCollectionPage() bool {
return this.OrderedCollectionPageMember != 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 StreamsPropertyIterator) JSONLDContext() map[string]string {
m := map[string]string{"https://www.w3.org/TR/activitystreams-vocabulary": this.alias}
var child map[string]string
if this.IsOrderedCollection() {
child = this.GetOrderedCollection().JSONLDContext()
} else if this.IsCollection() {
child = this.GetCollection().JSONLDContext()
} else if this.IsCollectionPage() {
child = this.GetCollectionPage().JSONLDContext()
} else if this.IsOrderedCollectionPage() {
child = this.GetOrderedCollectionPage().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 StreamsPropertyIterator) KindIndex() int {
if this.IsOrderedCollection() {
return 0
}
if this.IsCollection() {
return 1
}
if this.IsCollectionPage() {
return 2
}
if this.IsOrderedCollectionPage() {
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 StreamsPropertyIterator) LessThan(o vocab.StreamsPropertyIteratorInterface) bool {
idx1 := this.KindIndex()
idx2 := o.KindIndex()
if idx1 < idx2 {
return true
} else if idx1 > idx2 {
return false
} else if this.IsOrderedCollection() {
return this.GetOrderedCollection().LessThan(o.GetOrderedCollection())
} else if this.IsCollection() {
return this.GetCollection().LessThan(o.GetCollection())
} else if this.IsCollectionPage() {
return this.GetCollectionPage().LessThan(o.GetCollectionPage())
} else if this.IsOrderedCollectionPage() {
return this.GetOrderedCollectionPage().LessThan(o.GetOrderedCollectionPage())
} else if this.IsIRI() {
return this.iri.String() < o.GetIRI().String()
}
return false
}
// Name returns the name of this property: "streams".
func (this StreamsPropertyIterator) Name() string {
return "streams"
}
// Next returns the next iterator, or nil if there is no next iterator.
func (this StreamsPropertyIterator) Next() vocab.StreamsPropertyIteratorInterface {
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 StreamsPropertyIterator) Prev() vocab.StreamsPropertyIteratorInterface {
if this.myIdx-1 < 0 {
return nil
} else {
return this.parent.At(this.myIdx - 1)
}
}
// SetCollection sets the value of this property. Calling IsCollection afterwards
// returns true.
func (this *StreamsPropertyIterator) SetCollection(v vocab.CollectionInterface) {
this.clear()
this.CollectionMember = v
}
// SetCollectionPage sets the value of this property. Calling IsCollectionPage
// afterwards returns true.
func (this *StreamsPropertyIterator) SetCollectionPage(v vocab.CollectionPageInterface) {
this.clear()
this.CollectionPageMember = v
}
// SetIRI sets the value of this property. Calling IsIRI afterwards returns true.
func (this *StreamsPropertyIterator) SetIRI(v *url.URL) {
this.clear()
this.iri = v
}
// SetOrderedCollection sets the value of this property. Calling
// IsOrderedCollection afterwards returns true.
func (this *StreamsPropertyIterator) SetOrderedCollection(v vocab.OrderedCollectionInterface) {
this.clear()
this.OrderedCollectionMember = v
}
// SetOrderedCollectionPage sets the value of this property. Calling
// IsOrderedCollectionPage afterwards returns true.
func (this *StreamsPropertyIterator) SetOrderedCollectionPage(v vocab.OrderedCollectionPageInterface) {
this.clear()
this.OrderedCollectionPageMember = v
}
// clear ensures no value of this property is set. Calling HasAny or any of the
// 'Is' methods afterwards will return false.
func (this *StreamsPropertyIterator) clear() {
this.OrderedCollectionMember = nil
this.CollectionMember = nil
this.CollectionPageMember = nil
this.OrderedCollectionPageMember = 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 StreamsPropertyIterator) serialize() (interface{}, error) {
if this.IsOrderedCollection() {
return this.GetOrderedCollection().Serialize()
} else if this.IsCollection() {
return this.GetCollection().Serialize()
} else if this.IsCollectionPage() {
return this.GetCollectionPage().Serialize()
} else if this.IsOrderedCollectionPage() {
return this.GetOrderedCollectionPage().Serialize()
} else if this.IsIRI() {
return this.iri.String(), nil
}
return this.unknown, nil
}
// StreamsProperty is the non-functional property "streams". It is permitted to
// have one or more values, and of different value types.
type StreamsProperty struct {
properties []*StreamsPropertyIterator
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.StreamsPropertyInterface, error) {
alias := ""
if a, ok := aliasMap["https://www.w3.org/TR/activitystreams-vocabulary"]; ok {
alias = a
}
propName := "streams"
if len(alias) > 0 {
propName = fmt.Sprintf("%s:%s", alias, "streams")
}
if i, ok := m[propName]; ok {
this := &StreamsProperty{
alias: alias,
properties: []*StreamsPropertyIterator{},
}
if list, ok := i.([]interface{}); ok {
for _, iterator := range list {
if p, err := deserializeStreamsPropertyIterator(iterator, aliasMap); err != nil {
return this, err
} else if p != nil {
this.properties = append(this.properties, p)
}
}
} else {
if p, err := deserializeStreamsPropertyIterator(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
}
// NewStreamsProperty creates a new streams property.
func NewStreamsProperty() *StreamsProperty {
return &StreamsProperty{alias: ""}
}
// AppendCollection appends a Collection value to the back of a list of the
// property "streams". Invalidates iterators that are traversing using Prev.
func (this *StreamsProperty) AppendCollection(v vocab.CollectionInterface) {
this.properties = append(this.properties, &StreamsPropertyIterator{
CollectionMember: v,
alias: this.alias,
myIdx: this.Len(),
parent: this,
})
}
// AppendCollectionPage appends a CollectionPage value to the back of a list of
// the property "streams". Invalidates iterators that are traversing using
// Prev.
func (this *StreamsProperty) AppendCollectionPage(v vocab.CollectionPageInterface) {
this.properties = append(this.properties, &StreamsPropertyIterator{
CollectionPageMember: 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 *StreamsProperty) AppendIRI(v *url.URL) {
this.properties = append(this.properties, &StreamsPropertyIterator{
alias: this.alias,
iri: v,
myIdx: this.Len(),
parent: this,
})
}
// AppendOrderedCollection appends a OrderedCollection value to the back of a list
// of the property "streams". Invalidates iterators that are traversing using
// Prev.
func (this *StreamsProperty) AppendOrderedCollection(v vocab.OrderedCollectionInterface) {
this.properties = append(this.properties, &StreamsPropertyIterator{
OrderedCollectionMember: v,
alias: this.alias,
myIdx: this.Len(),
parent: this,
})
}
// AppendOrderedCollectionPage appends a OrderedCollectionPage value to the back
// of a list of the property "streams". Invalidates iterators that are
// traversing using Prev.
func (this *StreamsProperty) AppendOrderedCollectionPage(v vocab.OrderedCollectionPageInterface) {
this.properties = append(this.properties, &StreamsPropertyIterator{
OrderedCollectionPageMember: v,
alias: this.alias,
myIdx: this.Len(),
parent: this,
})
}
// At returns the property value for the specified index. Panics if the index is
// out of bounds.
func (this StreamsProperty) At(index int) vocab.StreamsPropertyIteratorInterface {
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 StreamsProperty) Begin() vocab.StreamsPropertyIteratorInterface {
if this.Empty() {
return nil
} else {
return this.properties[0]
}
}
// Empty returns returns true if there are no elements.
func (this StreamsProperty) 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 StreamsProperty) End() vocab.StreamsPropertyIteratorInterface {
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 StreamsProperty) JSONLDContext() map[string]string {
m := map[string]string{"https://www.w3.org/TR/activitystreams-vocabulary": 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 StreamsProperty) KindIndex(idx int) int {
return this.properties[idx].KindIndex()
}
// Len returns the number of values that exist for the "streams" property.
func (this StreamsProperty) 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 StreamsProperty) 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].GetOrderedCollection()
rhs := this.properties[j].GetOrderedCollection()
return lhs.LessThan(rhs)
} else if idx1 == 1 {
lhs := this.properties[i].GetCollection()
rhs := this.properties[j].GetCollection()
return lhs.LessThan(rhs)
} else if idx1 == 2 {
lhs := this.properties[i].GetCollectionPage()
rhs := this.properties[j].GetCollectionPage()
return lhs.LessThan(rhs)
} else if idx1 == 3 {
lhs := this.properties[i].GetOrderedCollectionPage()
rhs := this.properties[j].GetOrderedCollectionPage()
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 StreamsProperty) LessThan(o vocab.StreamsPropertyInterface) 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".
func (this StreamsProperty) Name() string {
return "streams"
}
// PrependCollection prepends a Collection value to the front of a list of the
// property "streams". Invalidates all iterators.
func (this *StreamsProperty) PrependCollection(v vocab.CollectionInterface) {
this.properties = append([]*StreamsPropertyIterator{{
CollectionMember: v,
alias: this.alias,
myIdx: 0,
parent: this,
}}, this.properties...)
for i := 1; i < this.Len(); i++ {
(this.properties)[i].myIdx = i
}
}
// PrependCollectionPage prepends a CollectionPage value to the front of a list of
// the property "streams". Invalidates all iterators.
func (this *StreamsProperty) PrependCollectionPage(v vocab.CollectionPageInterface) {
this.properties = append([]*StreamsPropertyIterator{{
CollectionPageMember: 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 *StreamsProperty) PrependIRI(v *url.URL) {
this.properties = append([]*StreamsPropertyIterator{{
alias: this.alias,
iri: v,
myIdx: 0,
parent: this,
}}, this.properties...)
for i := 1; i < this.Len(); i++ {
(this.properties)[i].myIdx = i
}
}
// PrependOrderedCollection prepends a OrderedCollection value to the front of a
// list of the property "streams". Invalidates all iterators.
func (this *StreamsProperty) PrependOrderedCollection(v vocab.OrderedCollectionInterface) {
this.properties = append([]*StreamsPropertyIterator{{
OrderedCollectionMember: v,
alias: this.alias,
myIdx: 0,
parent: this,
}}, this.properties...)
for i := 1; i < this.Len(); i++ {
(this.properties)[i].myIdx = i
}
}
// PrependOrderedCollectionPage prepends a OrderedCollectionPage value to the
// front of a list of the property "streams". Invalidates all iterators.
func (this *StreamsProperty) PrependOrderedCollectionPage(v vocab.OrderedCollectionPageInterface) {
this.properties = append([]*StreamsPropertyIterator{{
OrderedCollectionPageMember: v,
alias: this.alias,
myIdx: 0,
parent: this,
}}, 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
// "streams", regardless of its type. Panics if the index is out of bounds.
// Invalidates all iterators.
func (this *StreamsProperty) Remove(idx int) {
(this.properties)[idx].parent = nil
copy((this.properties)[idx:], (this.properties)[idx+1:])
(this.properties)[len(this.properties)-1] = &StreamsPropertyIterator{}
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 StreamsProperty) 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
}
// SetCollection 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 *StreamsProperty) SetCollection(idx int, v vocab.CollectionInterface) {
(this.properties)[idx].parent = nil
(this.properties)[idx] = &StreamsPropertyIterator{
CollectionMember: v,
alias: this.alias,
myIdx: idx,
parent: this,
}
}
// SetCollectionPage 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 *StreamsProperty) SetCollectionPage(idx int, v vocab.CollectionPageInterface) {
(this.properties)[idx].parent = nil
(this.properties)[idx] = &StreamsPropertyIterator{
CollectionPageMember: 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 *StreamsProperty) SetIRI(idx int, v *url.URL) {
(this.properties)[idx].parent = nil
(this.properties)[idx] = &StreamsPropertyIterator{
alias: this.alias,
iri: v,
myIdx: idx,
parent: this,
}
}
// SetOrderedCollection 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 *StreamsProperty) SetOrderedCollection(idx int, v vocab.OrderedCollectionInterface) {
(this.properties)[idx].parent = nil
(this.properties)[idx] = &StreamsPropertyIterator{
OrderedCollectionMember: v,
alias: this.alias,
myIdx: idx,
parent: this,
}
}
// SetOrderedCollectionPage 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 *StreamsProperty) SetOrderedCollectionPage(idx int, v vocab.OrderedCollectionPageInterface) {
(this.properties)[idx].parent = nil
(this.properties)[idx] = &StreamsPropertyIterator{
OrderedCollectionPageMember: v,
alias: this.alias,
myIdx: idx,
parent: this,
}
}
// Swap swaps the location of values at two indices for the "streams" property.
func (this StreamsProperty) Swap(i, j int) {
this.properties[i], this.properties[j] = this.properties[j], this.properties[i]
}

View file

@ -66,7 +66,7 @@ type SubjectProperty struct {
UpdateMember vocab.UpdateInterface
VideoMember vocab.VideoInterface
ViewMember vocab.ViewInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
}
@ -422,15 +422,12 @@ func DeserializeSubjectProperty(m map[string]interface{}, aliasMap map[string]st
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &SubjectProperty{
alias: alias,
unknown: []byte(str),
}
return this, nil
} else {
return nil, fmt.Errorf("could not deserialize %q property", "subject")
}
this := &SubjectProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
@ -1778,7 +1775,7 @@ func (this SubjectProperty) Serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// SetAccept sets the value of this property. Calling IsAccept afterwards returns

View file

@ -17,7 +17,7 @@ type SummaryPropertyIterator struct {
stringMember string
hasStringMember bool
langStringMember map[string]string
unknown []byte
unknown interface{}
iri *url.URL
alias string
langMap map[string]string
@ -62,13 +62,12 @@ func deserializeSummaryPropertyIterator(i interface{}, aliasMap map[string]strin
langStringMember: v,
}
return this, nil
} else if str, ok := i.(string); ok {
this := &SummaryPropertyIterator{
alias: alias,
unknown: []byte(str),
}
return this, nil
}
this := &SummaryPropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "summary")
}
@ -291,7 +290,7 @@ func (this SummaryPropertyIterator) serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// SummaryProperty is the non-functional property "summary". It is permitted to

View file

@ -66,7 +66,7 @@ type TagPropertyIterator struct {
UpdateMember vocab.UpdateInterface
VideoMember vocab.VideoInterface
ViewMember vocab.ViewInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
myIdx int
@ -423,13 +423,12 @@ func deserializeTagPropertyIterator(i interface{}, aliasMap map[string]string) (
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &TagPropertyIterator{
alias: alias,
unknown: []byte(str),
}
return this, nil
}
this := &TagPropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "tag")
}
@ -2162,7 +2161,7 @@ func (this TagPropertyIterator) serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// TagProperty is the non-functional property "tag". It is permitted to have one

View file

@ -66,7 +66,7 @@ type TargetPropertyIterator struct {
UpdateMember vocab.UpdateInterface
VideoMember vocab.VideoInterface
ViewMember vocab.ViewInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
myIdx int
@ -423,13 +423,12 @@ func deserializeTargetPropertyIterator(i interface{}, aliasMap map[string]string
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &TargetPropertyIterator{
alias: alias,
unknown: []byte(str),
}
return this, nil
}
this := &TargetPropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "target")
}
@ -2162,7 +2161,7 @@ func (this TargetPropertyIterator) serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// TargetProperty is the non-functional property "target". It is permitted to have

View file

@ -66,7 +66,7 @@ type ToPropertyIterator struct {
UpdateMember vocab.UpdateInterface
VideoMember vocab.VideoInterface
ViewMember vocab.ViewInterface
unknown []byte
unknown interface{}
iri *url.URL
alias string
myIdx int
@ -423,13 +423,12 @@ func deserializeToPropertyIterator(i interface{}, aliasMap map[string]string) (*
}
return this, nil
}
} else if str, ok := i.(string); ok {
this := &ToPropertyIterator{
alias: alias,
unknown: []byte(str),
}
return this, nil
}
this := &ToPropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "to")
}
@ -2162,7 +2161,7 @@ func (this ToPropertyIterator) serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// ToProperty is the non-functional property "to". It is permitted to have one or

View file

@ -12,7 +12,7 @@ import (
type TotalItemsProperty struct {
nonNegativeIntegerMember int
hasNonNegativeIntegerMember bool
unknown []byte
unknown interface{}
iri *url.URL
alias string
}
@ -49,15 +49,12 @@ func DeserializeTotalItemsProperty(m map[string]interface{}, aliasMap map[string
nonNegativeIntegerMember: v,
}
return this, nil
} else if str, ok := i.(string); ok {
this := &TotalItemsProperty{
alias: alias,
unknown: []byte(str),
}
return this, nil
} else {
return nil, fmt.Errorf("could not deserialize %q property", "totalItems")
}
this := &TotalItemsProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
@ -179,7 +176,7 @@ func (this TotalItemsProperty) Serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// Set sets the value of this property. Calling IsNonNegativeInteger afterwards

View file

@ -11,7 +11,7 @@ import (
// single nilable value type.
type TypePropertyIterator struct {
anyURIMember *url.URL
unknown []byte
unknown interface{}
alias string
myIdx int
parent vocab.TypePropertyInterface
@ -35,13 +35,12 @@ func deserializeTypePropertyIterator(i interface{}, aliasMap map[string]string)
anyURIMember: v,
}
return this, nil
} else if str, ok := i.(string); ok {
this := &TypePropertyIterator{
alias: alias,
unknown: []byte(str),
}
return this, nil
}
this := &TypePropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "type")
}
@ -183,7 +182,7 @@ func (this TypePropertyIterator) serialize() (interface{}, error) {
if this.IsAnyURI() {
return anyuri.SerializeAnyURI(this.Get())
}
return string(this.unknown), nil
return this.unknown, nil
}
// TypeProperty is the non-functional property "type". It is permitted to have one

View file

@ -17,7 +17,7 @@ type UnitsProperty struct {
stringMember string
hasStringMember bool
anyURIMember *url.URL
unknown []byte
unknown interface{}
alias string
}
@ -47,15 +47,12 @@ func DeserializeUnitsProperty(m map[string]interface{}, aliasMap map[string]stri
anyURIMember: v,
}
return this, nil
} else if str, ok := i.(string); ok {
this := &UnitsProperty{
alias: alias,
unknown: []byte(str),
}
return this, nil
} else {
return nil, fmt.Errorf("could not deserialize %q property", "units")
}
this := &UnitsProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
@ -183,7 +180,7 @@ func (this UnitsProperty) Serialize() (interface{}, error) {
} else if this.IsAnyURI() {
return anyuri.SerializeAnyURI(this.GetAnyURI())
}
return string(this.unknown), nil
return this.unknown, nil
}
// SetAnyURI sets the value of this property. Calling IsAnyURI afterwards returns

View file

@ -13,7 +13,7 @@ import (
type UpdatedProperty struct {
dateTimeMember time.Time
hasDateTimeMember bool
unknown []byte
unknown interface{}
iri *url.URL
alias string
}
@ -50,15 +50,12 @@ func DeserializeUpdatedProperty(m map[string]interface{}, aliasMap map[string]st
hasDateTimeMember: true,
}
return this, nil
} else if str, ok := i.(string); ok {
this := &UpdatedProperty{
alias: alias,
unknown: []byte(str),
}
return this, nil
} else {
return nil, fmt.Errorf("could not deserialize %q property", "updated")
}
this := &UpdatedProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
@ -180,7 +177,7 @@ func (this UpdatedProperty) Serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// Set sets the value of this property. Calling IsDateTime afterwards will return

View file

@ -16,7 +16,7 @@ type UrlPropertyIterator struct {
anyURIMember *url.URL
LinkMember vocab.LinkInterface
MentionMember vocab.MentionInterface
unknown []byte
unknown interface{}
alias string
myIdx int
parent vocab.UrlPropertyInterface
@ -48,19 +48,19 @@ func deserializeUrlPropertyIterator(i interface{}, aliasMap map[string]string) (
}
return this, nil
}
} else if v, err := anyuri.DeserializeAnyURI(i); err == nil {
}
if v, err := anyuri.DeserializeAnyURI(i); err == nil {
this := &UrlPropertyIterator{
alias: alias,
anyURIMember: v,
}
return this, nil
} else if str, ok := i.(string); ok {
this := &UrlPropertyIterator{
alias: alias,
unknown: []byte(str),
}
return this, nil
}
this := &UrlPropertyIterator{
alias: alias,
unknown: i,
}
return this, nil
return nil, fmt.Errorf("could not deserialize %q property", "url")
}
@ -251,7 +251,7 @@ func (this UrlPropertyIterator) serialize() (interface{}, error) {
} else if this.IsMention() {
return this.GetMention().Serialize()
}
return string(this.unknown), nil
return this.unknown, nil
}
// UrlProperty is the non-functional property "url". It is permitted to have one

View file

@ -12,7 +12,7 @@ import (
type WidthProperty struct {
nonNegativeIntegerMember int
hasNonNegativeIntegerMember bool
unknown []byte
unknown interface{}
iri *url.URL
alias string
}
@ -49,15 +49,12 @@ func DeserializeWidthProperty(m map[string]interface{}, aliasMap map[string]stri
nonNegativeIntegerMember: v,
}
return this, nil
} else if str, ok := i.(string); ok {
this := &WidthProperty{
alias: alias,
unknown: []byte(str),
}
return this, nil
} else {
return nil, fmt.Errorf("could not deserialize %q property", "width")
}
this := &WidthProperty{
alias: alias,
unknown: i,
}
return this, nil
}
return nil, nil
}
@ -179,7 +176,7 @@ func (this WidthProperty) Serialize() (interface{}, error) {
} else if this.IsIRI() {
return this.iri.String(), nil
}
return string(this.unknown), nil
return this.unknown, nil
}
// Set sets the value of this property. Calling IsNonNegativeInteger afterwards

View file

@ -79,6 +79,10 @@ type privateManager interface {
// deserialization method for the "InstrumentPropertyInterface"
// non-functional property in the vocabulary "ActivityStreams"
DeserializeInstrumentPropertyActivityStreams() func(map[string]interface{}, map[string]string) (vocab.InstrumentPropertyInterface, error)
// DeserializeLikesPropertyActivityStreams returns the deserialization
// method for the "LikesPropertyInterface" non-functional property in
// the vocabulary "ActivityStreams"
DeserializeLikesPropertyActivityStreams() func(map[string]interface{}, map[string]string) (vocab.LikesPropertyInterface, error)
// DeserializeLocationPropertyActivityStreams returns the deserialization
// method for the "LocationPropertyInterface" non-functional property
// in the vocabulary "ActivityStreams"
@ -115,6 +119,10 @@ type privateManager interface {
// method for the "ResultPropertyInterface" non-functional property in
// the vocabulary "ActivityStreams"
DeserializeResultPropertyActivityStreams() func(map[string]interface{}, map[string]string) (vocab.ResultPropertyInterface, error)
// DeserializeSharesPropertyActivityStreams returns the deserialization
// method for the "SharesPropertyInterface" non-functional property in
// the vocabulary "ActivityStreams"
DeserializeSharesPropertyActivityStreams() func(map[string]interface{}, map[string]string) (vocab.SharesPropertyInterface, error)
// DeserializeStartTimePropertyActivityStreams returns the deserialization
// method for the "StartTimePropertyInterface" non-functional property
// in the vocabulary "ActivityStreams"

View file

@ -1,6 +1,10 @@
package typeaccept
import vocab "github.com/go-fed/activity/streams/vocab"
import (
"fmt"
vocab "github.com/go-fed/activity/streams/vocab"
"strings"
)
// Indicates that the actor accepts the object. The target property can be used in
// certain circumstances to indicate the context into which the object has
@ -60,6 +64,7 @@ type Accept struct {
Image vocab.ImagePropertyInterface
InReplyTo vocab.InReplyToPropertyInterface
Instrument vocab.InstrumentPropertyInterface
Likes vocab.LikesPropertyInterface
Location vocab.LocationPropertyInterface
MediaType vocab.MediaTypePropertyInterface
Name vocab.NamePropertyInterface
@ -69,6 +74,7 @@ type Accept struct {
Published vocab.PublishedPropertyInterface
Replies vocab.RepliesPropertyInterface
Result vocab.ResultPropertyInterface
Shares vocab.SharesPropertyInterface
StartTime vocab.StartTimePropertyInterface
Summary vocab.SummaryPropertyInterface
Tag vocab.TagPropertyInterface
@ -120,13 +126,38 @@ func AcceptIsExtendedBy(other vocab.Type) bool {
// unmarshalled from a text or binary format.
func DeserializeAccept(m map[string]interface{}, aliasMap map[string]string) (*Accept, error) {
alias := ""
aliasPrefix := ""
if a, ok := aliasMap["https://www.w3.org/TR/activitystreams-vocabulary"]; ok {
alias = a
aliasPrefix = a + ":"
}
this := &Accept{
alias: alias,
unknown: make(map[string]interface{}),
}
if typeValue, ok := m["type"]; !ok {
return nil, fmt.Errorf("no \"type\" property in map")
} else if typeString, ok := typeValue.(string); ok {
typeName := strings.TrimPrefix(typeString, aliasPrefix)
if typeName != "Accept" {
return nil, fmt.Errorf("\"type\" property is not of %q type: %s", "Accept", typeName)
}
// Fall through, success in finding a proper Type
} else if arrType, ok := typeValue.([]interface{}); ok {
found := false
for _, elemVal := range arrType {
if typeString, ok := elemVal.(string); ok && strings.TrimPrefix(typeString, aliasPrefix) == "Accept" {
found = true
break
}
}
if !found {
return nil, fmt.Errorf("could not find a \"type\" property of value %q", "Accept")
}
// Fall through, success in finding a proper Type
} else {
return nil, fmt.Errorf("\"type\" property is unrecognized type: %T", typeValue)
}
// Begin: Known property deserialization
if p, err := mgr.DeserializeActorPropertyActivityStreams()(m, aliasMap); err != nil {
return nil, err
@ -218,6 +249,11 @@ func DeserializeAccept(m map[string]interface{}, aliasMap map[string]string) (*A
} else if p != nil {
this.Instrument = p
}
if p, err := mgr.DeserializeLikesPropertyActivityStreams()(m, aliasMap); err != nil {
return nil, err
} else if p != nil {
this.Likes = p
}
if p, err := mgr.DeserializeLocationPropertyActivityStreams()(m, aliasMap); err != nil {
return nil, err
} else if p != nil {
@ -263,6 +299,11 @@ func DeserializeAccept(m map[string]interface{}, aliasMap map[string]string) (*A
} else if p != nil {
this.Result = p
}
if p, err := mgr.DeserializeSharesPropertyActivityStreams()(m, aliasMap); err != nil {
return nil, err
} else if p != nil {
this.Shares = p
}
if p, err := mgr.DeserializeStartTimePropertyActivityStreams()(m, aliasMap); err != nil {
return nil, err
} else if p != nil {
@ -344,6 +385,8 @@ func DeserializeAccept(m map[string]interface{}, aliasMap map[string]string) (*A
continue
} else if k == "instrument" {
continue
} else if k == "likes" {
continue
} else if k == "location" {
continue
} else if k == "mediaType" {
@ -362,6 +405,8 @@ func DeserializeAccept(m map[string]interface{}, aliasMap map[string]string) (*A
continue
} else if k == "result" {
continue
} else if k == "shares" {
continue
} else if k == "startTime" {
continue
} else if k == "summary" {
@ -486,6 +531,11 @@ func (this Accept) GetInstrument() vocab.InstrumentPropertyInterface {
return this.Instrument
}
// GetLikes returns the "likes" property if it exists, and nil otherwise.
func (this Accept) GetLikes() vocab.LikesPropertyInterface {
return this.Likes
}
// GetLocation returns the "location" property if it exists, and nil otherwise.
func (this Accept) GetLocation() vocab.LocationPropertyInterface {
return this.Location
@ -531,6 +581,11 @@ func (this Accept) GetResult() vocab.ResultPropertyInterface {
return this.Result
}
// GetShares returns the "shares" property if it exists, and nil otherwise.
func (this Accept) GetShares() vocab.SharesPropertyInterface {
return this.Shares
}
// GetStartTime returns the "startTime" property if it exists, and nil otherwise.
func (this Accept) GetStartTime() vocab.StartTimePropertyInterface {
return this.StartTime
@ -609,6 +664,7 @@ func (this Accept) JSONLDContext() map[string]string {
m = this.helperJSONLDContext(this.Image, m)
m = this.helperJSONLDContext(this.InReplyTo, m)
m = this.helperJSONLDContext(this.Instrument, m)
m = this.helperJSONLDContext(this.Likes, m)
m = this.helperJSONLDContext(this.Location, m)
m = this.helperJSONLDContext(this.MediaType, m)
m = this.helperJSONLDContext(this.Name, m)
@ -618,6 +674,7 @@ func (this Accept) JSONLDContext() map[string]string {
m = this.helperJSONLDContext(this.Published, m)
m = this.helperJSONLDContext(this.Replies, m)
m = this.helperJSONLDContext(this.Result, m)
m = this.helperJSONLDContext(this.Shares, m)
m = this.helperJSONLDContext(this.StartTime, m)
m = this.helperJSONLDContext(this.Summary, m)
m = this.helperJSONLDContext(this.Tag, m)
@ -886,6 +943,20 @@ func (this Accept) LessThan(o vocab.AcceptInterface) bool {
// Anything else is greater than nil
return false
} // Else: Both are nil
// Compare property "likes"
if lhs, rhs := this.Likes, o.GetLikes(); 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 "location"
if lhs, rhs := this.Location, o.GetLocation(); lhs != nil && rhs != nil {
if lhs.LessThan(rhs) {
@ -1012,6 +1083,20 @@ func (this Accept) LessThan(o vocab.AcceptInterface) bool {
// Anything else is greater than nil
return false
} // Else: Both are nil
// Compare property "shares"
if lhs, rhs := this.Shares, o.GetShares(); 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 "startTime"
if lhs, rhs := this.StartTime, o.GetStartTime(); lhs != nil && rhs != nil {
if lhs.LessThan(rhs) {
@ -1141,6 +1226,11 @@ func (this Accept) LessThan(o vocab.AcceptInterface) bool {
// marshalling into a text or binary format.
func (this Accept) Serialize() (map[string]interface{}, error) {
m := make(map[string]interface{})
typeName := "Accept"
if len(this.alias) > 0 {
typeName = this.alias + ":" + "Accept"
}
m["type"] = typeName
// Begin: Serialize known properties
// Maybe serialize property "actor"
if this.Actor != nil {
@ -1286,6 +1376,14 @@ func (this Accept) Serialize() (map[string]interface{}, error) {
m[this.Instrument.Name()] = i
}
}
// Maybe serialize property "likes"
if this.Likes != nil {
if i, err := this.Likes.Serialize(); err != nil {
return nil, err
} else if i != nil {
m[this.Likes.Name()] = i
}
}
// Maybe serialize property "location"
if this.Location != nil {
if i, err := this.Location.Serialize(); err != nil {
@ -1358,6 +1456,14 @@ func (this Accept) Serialize() (map[string]interface{}, error) {
m[this.Result.Name()] = i
}
}
// Maybe serialize property "shares"
if this.Shares != nil {
if i, err := this.Shares.Serialize(); err != nil {
return nil, err
} else if i != nil {
m[this.Shares.Name()] = i
}
}
// Maybe serialize property "startTime"
if this.StartTime != nil {
if i, err := this.StartTime.Serialize(); err != nil {
@ -1437,178 +1543,188 @@ func (this Accept) Serialize() (map[string]interface{}, error) {
}
// SetActor returns the "actor" property if it exists, and nil otherwise.
func (this Accept) SetActor(i vocab.ActorPropertyInterface) {
func (this *Accept) SetActor(i vocab.ActorPropertyInterface) {
this.Actor = i
}
// SetAltitude returns the "altitude" property if it exists, and nil otherwise.
func (this Accept) SetAltitude(i vocab.AltitudePropertyInterface) {
func (this *Accept) SetAltitude(i vocab.AltitudePropertyInterface) {
this.Altitude = i
}
// SetAttachment returns the "attachment" property if it exists, and nil otherwise.
func (this Accept) SetAttachment(i vocab.AttachmentPropertyInterface) {
func (this *Accept) SetAttachment(i vocab.AttachmentPropertyInterface) {
this.Attachment = i
}
// SetAttributedTo returns the "attributedTo" property if it exists, and nil
// otherwise.
func (this Accept) SetAttributedTo(i vocab.AttributedToPropertyInterface) {
func (this *Accept) SetAttributedTo(i vocab.AttributedToPropertyInterface) {
this.AttributedTo = i
}
// SetAudience returns the "audience" property if it exists, and nil otherwise.
func (this Accept) SetAudience(i vocab.AudiencePropertyInterface) {
func (this *Accept) SetAudience(i vocab.AudiencePropertyInterface) {
this.Audience = i
}
// SetBcc returns the "bcc" property if it exists, and nil otherwise.
func (this Accept) SetBcc(i vocab.BccPropertyInterface) {
func (this *Accept) SetBcc(i vocab.BccPropertyInterface) {
this.Bcc = i
}
// SetBto returns the "bto" property if it exists, and nil otherwise.
func (this Accept) SetBto(i vocab.BtoPropertyInterface) {
func (this *Accept) SetBto(i vocab.BtoPropertyInterface) {
this.Bto = i
}
// SetCc returns the "cc" property if it exists, and nil otherwise.
func (this Accept) SetCc(i vocab.CcPropertyInterface) {
func (this *Accept) SetCc(i vocab.CcPropertyInterface) {
this.Cc = i
}
// SetContent returns the "content" property if it exists, and nil otherwise.
func (this Accept) SetContent(i vocab.ContentPropertyInterface) {
func (this *Accept) SetContent(i vocab.ContentPropertyInterface) {
this.Content = i
}
// SetContext returns the "context" property if it exists, and nil otherwise.
func (this Accept) SetContext(i vocab.ContextPropertyInterface) {
func (this *Accept) SetContext(i vocab.ContextPropertyInterface) {
this.Context = i
}
// SetDuration returns the "duration" property if it exists, and nil otherwise.
func (this Accept) SetDuration(i vocab.DurationPropertyInterface) {
func (this *Accept) SetDuration(i vocab.DurationPropertyInterface) {
this.Duration = i
}
// SetEndTime returns the "endTime" property if it exists, and nil otherwise.
func (this Accept) SetEndTime(i vocab.EndTimePropertyInterface) {
func (this *Accept) SetEndTime(i vocab.EndTimePropertyInterface) {
this.EndTime = i
}
// SetGenerator returns the "generator" property if it exists, and nil otherwise.
func (this Accept) SetGenerator(i vocab.GeneratorPropertyInterface) {
func (this *Accept) SetGenerator(i vocab.GeneratorPropertyInterface) {
this.Generator = i
}
// SetIcon returns the "icon" property if it exists, and nil otherwise.
func (this Accept) SetIcon(i vocab.IconPropertyInterface) {
func (this *Accept) SetIcon(i vocab.IconPropertyInterface) {
this.Icon = i
}
// SetId returns the "id" property if it exists, and nil otherwise.
func (this Accept) SetId(i vocab.IdPropertyInterface) {
func (this *Accept) SetId(i vocab.IdPropertyInterface) {
this.Id = i
}
// SetImage returns the "image" property if it exists, and nil otherwise.
func (this Accept) SetImage(i vocab.ImagePropertyInterface) {
func (this *Accept) SetImage(i vocab.ImagePropertyInterface) {
this.Image = i
}
// SetInReplyTo returns the "inReplyTo" property if it exists, and nil otherwise.
func (this Accept) SetInReplyTo(i vocab.InReplyToPropertyInterface) {
func (this *Accept) SetInReplyTo(i vocab.InReplyToPropertyInterface) {
this.InReplyTo = i
}
// SetInstrument returns the "instrument" property if it exists, and nil otherwise.
func (this Accept) SetInstrument(i vocab.InstrumentPropertyInterface) {
func (this *Accept) SetInstrument(i vocab.InstrumentPropertyInterface) {
this.Instrument = i
}
// SetLikes returns the "likes" property if it exists, and nil otherwise.
func (this *Accept) SetLikes(i vocab.LikesPropertyInterface) {
this.Likes = i
}
// SetLocation returns the "location" property if it exists, and nil otherwise.
func (this Accept) SetLocation(i vocab.LocationPropertyInterface) {
func (this *Accept) SetLocation(i vocab.LocationPropertyInterface) {
this.Location = i
}
// SetMediaType returns the "mediaType" property if it exists, and nil otherwise.
func (this Accept) SetMediaType(i vocab.MediaTypePropertyInterface) {
func (this *Accept) SetMediaType(i vocab.MediaTypePropertyInterface) {
this.MediaType = i
}
// SetName returns the "name" property if it exists, and nil otherwise.
func (this Accept) SetName(i vocab.NamePropertyInterface) {
func (this *Accept) SetName(i vocab.NamePropertyInterface) {
this.Name = i
}
// SetObject returns the "object" property if it exists, and nil otherwise.
func (this Accept) SetObject(i vocab.ObjectPropertyInterface) {
func (this *Accept) SetObject(i vocab.ObjectPropertyInterface) {
this.Object = i
}
// SetOrigin returns the "origin" property if it exists, and nil otherwise.
func (this Accept) SetOrigin(i vocab.OriginPropertyInterface) {
func (this *Accept) SetOrigin(i vocab.OriginPropertyInterface) {
this.Origin = i
}
// SetPreview returns the "preview" property if it exists, and nil otherwise.
func (this Accept) SetPreview(i vocab.PreviewPropertyInterface) {
func (this *Accept) SetPreview(i vocab.PreviewPropertyInterface) {
this.Preview = i
}
// SetPublished returns the "published" property if it exists, and nil otherwise.
func (this Accept) SetPublished(i vocab.PublishedPropertyInterface) {
func (this *Accept) SetPublished(i vocab.PublishedPropertyInterface) {
this.Published = i
}
// SetReplies returns the "replies" property if it exists, and nil otherwise.
func (this Accept) SetReplies(i vocab.RepliesPropertyInterface) {
func (this *Accept) SetReplies(i vocab.RepliesPropertyInterface) {
this.Replies = i
}
// SetResult returns the "result" property if it exists, and nil otherwise.
func (this Accept) SetResult(i vocab.ResultPropertyInterface) {
func (this *Accept) SetResult(i vocab.ResultPropertyInterface) {
this.Result = i
}
// SetShares returns the "shares" property if it exists, and nil otherwise.
func (this *Accept) SetShares(i vocab.SharesPropertyInterface) {
this.Shares = i
}
// SetStartTime returns the "startTime" property if it exists, and nil otherwise.
func (this Accept) SetStartTime(i vocab.StartTimePropertyInterface) {
func (this *Accept) SetStartTime(i vocab.StartTimePropertyInterface) {
this.StartTime = i
}
// SetSummary returns the "summary" property if it exists, and nil otherwise.
func (this Accept) SetSummary(i vocab.SummaryPropertyInterface) {
func (this *Accept) SetSummary(i vocab.SummaryPropertyInterface) {
this.Summary = i
}
// SetTag returns the "tag" property if it exists, and nil otherwise.
func (this Accept) SetTag(i vocab.TagPropertyInterface) {
func (this *Accept) SetTag(i vocab.TagPropertyInterface) {
this.Tag = i
}
// SetTarget returns the "target" property if it exists, and nil otherwise.
func (this Accept) SetTarget(i vocab.TargetPropertyInterface) {
func (this *Accept) SetTarget(i vocab.TargetPropertyInterface) {
this.Target = i
}
// SetTo returns the "to" property if it exists, and nil otherwise.
func (this Accept) SetTo(i vocab.ToPropertyInterface) {
func (this *Accept) SetTo(i vocab.ToPropertyInterface) {
this.To = i
}
// SetType returns the "type" property if it exists, and nil otherwise.
func (this Accept) SetType(i vocab.TypePropertyInterface) {
func (this *Accept) SetType(i vocab.TypePropertyInterface) {
this.Type = i
}
// SetUpdated returns the "updated" property if it exists, and nil otherwise.
func (this Accept) SetUpdated(i vocab.UpdatedPropertyInterface) {
func (this *Accept) SetUpdated(i vocab.UpdatedPropertyInterface) {
this.Updated = i
}
// SetUrl returns the "url" property if it exists, and nil otherwise.
func (this Accept) SetUrl(i vocab.UrlPropertyInterface) {
func (this *Accept) SetUrl(i vocab.UrlPropertyInterface) {
this.Url = i
}

View file

@ -79,6 +79,10 @@ type privateManager interface {
// deserialization method for the "InstrumentPropertyInterface"
// non-functional property in the vocabulary "ActivityStreams"
DeserializeInstrumentPropertyActivityStreams() func(map[string]interface{}, map[string]string) (vocab.InstrumentPropertyInterface, error)
// DeserializeLikesPropertyActivityStreams returns the deserialization
// method for the "LikesPropertyInterface" non-functional property in
// the vocabulary "ActivityStreams"
DeserializeLikesPropertyActivityStreams() func(map[string]interface{}, map[string]string) (vocab.LikesPropertyInterface, error)
// DeserializeLocationPropertyActivityStreams returns the deserialization
// method for the "LocationPropertyInterface" non-functional property
// in the vocabulary "ActivityStreams"
@ -115,6 +119,10 @@ type privateManager interface {
// method for the "ResultPropertyInterface" non-functional property in
// the vocabulary "ActivityStreams"
DeserializeResultPropertyActivityStreams() func(map[string]interface{}, map[string]string) (vocab.ResultPropertyInterface, error)
// DeserializeSharesPropertyActivityStreams returns the deserialization
// method for the "SharesPropertyInterface" non-functional property in
// the vocabulary "ActivityStreams"
DeserializeSharesPropertyActivityStreams() func(map[string]interface{}, map[string]string) (vocab.SharesPropertyInterface, error)
// DeserializeStartTimePropertyActivityStreams returns the deserialization
// method for the "StartTimePropertyInterface" non-functional property
// in the vocabulary "ActivityStreams"

View file

@ -1,6 +1,10 @@
package typeactivity
import vocab "github.com/go-fed/activity/streams/vocab"
import (
"fmt"
vocab "github.com/go-fed/activity/streams/vocab"
"strings"
)
// An Activity is a subtype of Object that describes some form of action that may
// happen, is currently happening, or has already happened. The Activity type
@ -40,6 +44,7 @@ type Activity struct {
Image vocab.ImagePropertyInterface
InReplyTo vocab.InReplyToPropertyInterface
Instrument vocab.InstrumentPropertyInterface
Likes vocab.LikesPropertyInterface
Location vocab.LocationPropertyInterface
MediaType vocab.MediaTypePropertyInterface
Name vocab.NamePropertyInterface
@ -49,6 +54,7 @@ type Activity struct {
Published vocab.PublishedPropertyInterface
Replies vocab.RepliesPropertyInterface
Result vocab.ResultPropertyInterface
Shares vocab.SharesPropertyInterface
StartTime vocab.StartTimePropertyInterface
Summary vocab.SummaryPropertyInterface
Tag vocab.TagPropertyInterface
@ -100,13 +106,38 @@ func ActivityIsExtendedBy(other vocab.Type) bool {
// unmarshalled from a text or binary format.
func DeserializeActivity(m map[string]interface{}, aliasMap map[string]string) (*Activity, error) {
alias := ""
aliasPrefix := ""
if a, ok := aliasMap["https://www.w3.org/TR/activitystreams-vocabulary"]; ok {
alias = a
aliasPrefix = a + ":"
}
this := &Activity{
alias: alias,
unknown: make(map[string]interface{}),
}
if typeValue, ok := m["type"]; !ok {
return nil, fmt.Errorf("no \"type\" property in map")
} else if typeString, ok := typeValue.(string); ok {
typeName := strings.TrimPrefix(typeString, aliasPrefix)
if typeName != "Activity" {
return nil, fmt.Errorf("\"type\" property is not of %q type: %s", "Activity", typeName)
}
// Fall through, success in finding a proper Type
} else if arrType, ok := typeValue.([]interface{}); ok {
found := false
for _, elemVal := range arrType {
if typeString, ok := elemVal.(string); ok && strings.TrimPrefix(typeString, aliasPrefix) == "Activity" {
found = true
break
}
}
if !found {
return nil, fmt.Errorf("could not find a \"type\" property of value %q", "Activity")
}
// Fall through, success in finding a proper Type
} else {
return nil, fmt.Errorf("\"type\" property is unrecognized type: %T", typeValue)
}
// Begin: Known property deserialization
if p, err := mgr.DeserializeActorPropertyActivityStreams()(m, aliasMap); err != nil {
return nil, err
@ -198,6 +229,11 @@ func DeserializeActivity(m map[string]interface{}, aliasMap map[string]string) (
} else if p != nil {
this.Instrument = p
}
if p, err := mgr.DeserializeLikesPropertyActivityStreams()(m, aliasMap); err != nil {
return nil, err
} else if p != nil {
this.Likes = p
}
if p, err := mgr.DeserializeLocationPropertyActivityStreams()(m, aliasMap); err != nil {
return nil, err
} else if p != nil {
@ -243,6 +279,11 @@ func DeserializeActivity(m map[string]interface{}, aliasMap map[string]string) (
} else if p != nil {
this.Result = p
}
if p, err := mgr.DeserializeSharesPropertyActivityStreams()(m, aliasMap); err != nil {
return nil, err
} else if p != nil {
this.Shares = p
}
if p, err := mgr.DeserializeStartTimePropertyActivityStreams()(m, aliasMap); err != nil {
return nil, err
} else if p != nil {
@ -324,6 +365,8 @@ func DeserializeActivity(m map[string]interface{}, aliasMap map[string]string) (
continue
} else if k == "instrument" {
continue
} else if k == "likes" {
continue
} else if k == "location" {
continue
} else if k == "mediaType" {
@ -342,6 +385,8 @@ func DeserializeActivity(m map[string]interface{}, aliasMap map[string]string) (
continue
} else if k == "result" {
continue
} else if k == "shares" {
continue
} else if k == "startTime" {
continue
} else if k == "summary" {
@ -466,6 +511,11 @@ func (this Activity) GetInstrument() vocab.InstrumentPropertyInterface {
return this.Instrument
}
// GetLikes returns the "likes" property if it exists, and nil otherwise.
func (this Activity) GetLikes() vocab.LikesPropertyInterface {
return this.Likes
}
// GetLocation returns the "location" property if it exists, and nil otherwise.
func (this Activity) GetLocation() vocab.LocationPropertyInterface {
return this.Location
@ -511,6 +561,11 @@ func (this Activity) GetResult() vocab.ResultPropertyInterface {
return this.Result
}
// GetShares returns the "shares" property if it exists, and nil otherwise.
func (this Activity) GetShares() vocab.SharesPropertyInterface {
return this.Shares
}
// GetStartTime returns the "startTime" property if it exists, and nil otherwise.
func (this Activity) GetStartTime() vocab.StartTimePropertyInterface {
return this.StartTime
@ -589,6 +644,7 @@ func (this Activity) JSONLDContext() map[string]string {
m = this.helperJSONLDContext(this.Image, m)
m = this.helperJSONLDContext(this.InReplyTo, m)
m = this.helperJSONLDContext(this.Instrument, m)
m = this.helperJSONLDContext(this.Likes, m)
m = this.helperJSONLDContext(this.Location, m)
m = this.helperJSONLDContext(this.MediaType, m)
m = this.helperJSONLDContext(this.Name, m)
@ -598,6 +654,7 @@ func (this Activity) JSONLDContext() map[string]string {
m = this.helperJSONLDContext(this.Published, m)
m = this.helperJSONLDContext(this.Replies, m)
m = this.helperJSONLDContext(this.Result, m)
m = this.helperJSONLDContext(this.Shares, m)
m = this.helperJSONLDContext(this.StartTime, m)
m = this.helperJSONLDContext(this.Summary, m)
m = this.helperJSONLDContext(this.Tag, m)
@ -866,6 +923,20 @@ func (this Activity) LessThan(o vocab.ActivityInterface) bool {
// Anything else is greater than nil
return false
} // Else: Both are nil
// Compare property "likes"
if lhs, rhs := this.Likes, o.GetLikes(); 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 "location"
if lhs, rhs := this.Location, o.GetLocation(); lhs != nil && rhs != nil {
if lhs.LessThan(rhs) {
@ -992,6 +1063,20 @@ func (this Activity) LessThan(o vocab.ActivityInterface) bool {
// Anything else is greater than nil
return false
} // Else: Both are nil
// Compare property "shares"
if lhs, rhs := this.Shares, o.GetShares(); 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 "startTime"
if lhs, rhs := this.StartTime, o.GetStartTime(); lhs != nil && rhs != nil {
if lhs.LessThan(rhs) {
@ -1121,6 +1206,11 @@ func (this Activity) LessThan(o vocab.ActivityInterface) bool {
// marshalling into a text or binary format.
func (this Activity) Serialize() (map[string]interface{}, error) {
m := make(map[string]interface{})
typeName := "Activity"
if len(this.alias) > 0 {
typeName = this.alias + ":" + "Activity"
}
m["type"] = typeName
// Begin: Serialize known properties
// Maybe serialize property "actor"
if this.Actor != nil {
@ -1266,6 +1356,14 @@ func (this Activity) Serialize() (map[string]interface{}, error) {
m[this.Instrument.Name()] = i
}
}
// Maybe serialize property "likes"
if this.Likes != nil {
if i, err := this.Likes.Serialize(); err != nil {
return nil, err
} else if i != nil {
m[this.Likes.Name()] = i
}
}
// Maybe serialize property "location"
if this.Location != nil {
if i, err := this.Location.Serialize(); err != nil {
@ -1338,6 +1436,14 @@ func (this Activity) Serialize() (map[string]interface{}, error) {
m[this.Result.Name()] = i
}
}
// Maybe serialize property "shares"
if this.Shares != nil {
if i, err := this.Shares.Serialize(); err != nil {
return nil, err
} else if i != nil {
m[this.Shares.Name()] = i
}
}
// Maybe serialize property "startTime"
if this.StartTime != nil {
if i, err := this.StartTime.Serialize(); err != nil {
@ -1417,178 +1523,188 @@ func (this Activity) Serialize() (map[string]interface{}, error) {
}
// SetActor returns the "actor" property if it exists, and nil otherwise.
func (this Activity) SetActor(i vocab.ActorPropertyInterface) {
func (this *Activity) SetActor(i vocab.ActorPropertyInterface) {
this.Actor = i
}
// SetAltitude returns the "altitude" property if it exists, and nil otherwise.
func (this Activity) SetAltitude(i vocab.AltitudePropertyInterface) {
func (this *Activity) SetAltitude(i vocab.AltitudePropertyInterface) {
this.Altitude = i
}
// SetAttachment returns the "attachment" property if it exists, and nil otherwise.
func (this Activity) SetAttachment(i vocab.AttachmentPropertyInterface) {
func (this *Activity) SetAttachment(i vocab.AttachmentPropertyInterface) {
this.Attachment = i
}
// SetAttributedTo returns the "attributedTo" property if it exists, and nil
// otherwise.
func (this Activity) SetAttributedTo(i vocab.AttributedToPropertyInterface) {
func (this *Activity) SetAttributedTo(i vocab.AttributedToPropertyInterface) {
this.AttributedTo = i
}
// SetAudience returns the "audience" property if it exists, and nil otherwise.
func (this Activity) SetAudience(i vocab.AudiencePropertyInterface) {
func (this *Activity) SetAudience(i vocab.AudiencePropertyInterface) {
this.Audience = i
}
// SetBcc returns the "bcc" property if it exists, and nil otherwise.
func (this Activity) SetBcc(i vocab.BccPropertyInterface) {
func (this *Activity) SetBcc(i vocab.BccPropertyInterface) {
this.Bcc = i
}
// SetBto returns the "bto" property if it exists, and nil otherwise.
func (this Activity) SetBto(i vocab.BtoPropertyInterface) {
func (this *Activity) SetBto(i vocab.BtoPropertyInterface) {
this.Bto = i
}
// SetCc returns the "cc" property if it exists, and nil otherwise.
func (this Activity) SetCc(i vocab.CcPropertyInterface) {
func (this *Activity) SetCc(i vocab.CcPropertyInterface) {
this.Cc = i
}
// SetContent returns the "content" property if it exists, and nil otherwise.
func (this Activity) SetContent(i vocab.ContentPropertyInterface) {
func (this *Activity) SetContent(i vocab.ContentPropertyInterface) {
this.Content = i
}
// SetContext returns the "context" property if it exists, and nil otherwise.
func (this Activity) SetContext(i vocab.ContextPropertyInterface) {
func (this *Activity) SetContext(i vocab.ContextPropertyInterface) {
this.Context = i
}
// SetDuration returns the "duration" property if it exists, and nil otherwise.
func (this Activity) SetDuration(i vocab.DurationPropertyInterface) {
func (this *Activity) SetDuration(i vocab.DurationPropertyInterface) {
this.Duration = i
}
// SetEndTime returns the "endTime" property if it exists, and nil otherwise.
func (this Activity) SetEndTime(i vocab.EndTimePropertyInterface) {
func (this *Activity) SetEndTime(i vocab.EndTimePropertyInterface) {
this.EndTime = i
}
// SetGenerator returns the "generator" property if it exists, and nil otherwise.
func (this Activity) SetGenerator(i vocab.GeneratorPropertyInterface) {
func (this *Activity) SetGenerator(i vocab.GeneratorPropertyInterface) {
this.Generator = i
}
// SetIcon returns the "icon" property if it exists, and nil otherwise.
func (this Activity) SetIcon(i vocab.IconPropertyInterface) {
func (this *Activity) SetIcon(i vocab.IconPropertyInterface) {
this.Icon = i
}
// SetId returns the "id" property if it exists, and nil otherwise.
func (this Activity) SetId(i vocab.IdPropertyInterface) {
func (this *Activity) SetId(i vocab.IdPropertyInterface) {
this.Id = i
}
// SetImage returns the "image" property if it exists, and nil otherwise.
func (this Activity) SetImage(i vocab.ImagePropertyInterface) {
func (this *Activity) SetImage(i vocab.ImagePropertyInterface) {
this.Image = i
}
// SetInReplyTo returns the "inReplyTo" property if it exists, and nil otherwise.
func (this Activity) SetInReplyTo(i vocab.InReplyToPropertyInterface) {
func (this *Activity) SetInReplyTo(i vocab.InReplyToPropertyInterface) {
this.InReplyTo = i
}
// SetInstrument returns the "instrument" property if it exists, and nil otherwise.
func (this Activity) SetInstrument(i vocab.InstrumentPropertyInterface) {
func (this *Activity) SetInstrument(i vocab.InstrumentPropertyInterface) {
this.Instrument = i
}
// SetLikes returns the "likes" property if it exists, and nil otherwise.
func (this *Activity) SetLikes(i vocab.LikesPropertyInterface) {
this.Likes = i
}
// SetLocation returns the "location" property if it exists, and nil otherwise.
func (this Activity) SetLocation(i vocab.LocationPropertyInterface) {
func (this *Activity) SetLocation(i vocab.LocationPropertyInterface) {
this.Location = i
}
// SetMediaType returns the "mediaType" property if it exists, and nil otherwise.
func (this Activity) SetMediaType(i vocab.MediaTypePropertyInterface) {
func (this *Activity) SetMediaType(i vocab.MediaTypePropertyInterface) {
this.MediaType = i
}
// SetName returns the "name" property if it exists, and nil otherwise.
func (this Activity) SetName(i vocab.NamePropertyInterface) {
func (this *Activity) SetName(i vocab.NamePropertyInterface) {
this.Name = i
}
// SetObject returns the "object" property if it exists, and nil otherwise.
func (this Activity) SetObject(i vocab.ObjectPropertyInterface) {
func (this *Activity) SetObject(i vocab.ObjectPropertyInterface) {
this.Object = i
}
// SetOrigin returns the "origin" property if it exists, and nil otherwise.
func (this Activity) SetOrigin(i vocab.OriginPropertyInterface) {
func (this *Activity) SetOrigin(i vocab.OriginPropertyInterface) {
this.Origin = i
}
// SetPreview returns the "preview" property if it exists, and nil otherwise.
func (this Activity) SetPreview(i vocab.PreviewPropertyInterface) {
func (this *Activity) SetPreview(i vocab.PreviewPropertyInterface) {
this.Preview = i
}
// SetPublished returns the "published" property if it exists, and nil otherwise.
func (this Activity) SetPublished(i vocab.PublishedPropertyInterface) {
func (this *Activity) SetPublished(i vocab.PublishedPropertyInterface) {
this.Published = i
}
// SetReplies returns the "replies" property if it exists, and nil otherwise.
func (this Activity) SetReplies(i vocab.RepliesPropertyInterface) {
func (this *Activity) SetReplies(i vocab.RepliesPropertyInterface) {
this.Replies = i
}
// SetResult returns the "result" property if it exists, and nil otherwise.
func (this Activity) SetResult(i vocab.ResultPropertyInterface) {
func (this *Activity) SetResult(i vocab.ResultPropertyInterface) {
this.Result = i
}
// SetShares returns the "shares" property if it exists, and nil otherwise.
func (this *Activity) SetShares(i vocab.SharesPropertyInterface) {
this.Shares = i
}
// SetStartTime returns the "startTime" property if it exists, and nil otherwise.
func (this Activity) SetStartTime(i vocab.StartTimePropertyInterface) {
func (this *Activity) SetStartTime(i vocab.StartTimePropertyInterface) {
this.StartTime = i
}
// SetSummary returns the "summary" property if it exists, and nil otherwise.
func (this Activity) SetSummary(i vocab.SummaryPropertyInterface) {
func (this *Activity) SetSummary(i vocab.SummaryPropertyInterface) {
this.Summary = i
}
// SetTag returns the "tag" property if it exists, and nil otherwise.
func (this Activity) SetTag(i vocab.TagPropertyInterface) {
func (this *Activity) SetTag(i vocab.TagPropertyInterface) {
this.Tag = i
}
// SetTarget returns the "target" property if it exists, and nil otherwise.
func (this Activity) SetTarget(i vocab.TargetPropertyInterface) {
func (this *Activity) SetTarget(i vocab.TargetPropertyInterface) {
this.Target = i
}
// SetTo returns the "to" property if it exists, and nil otherwise.
func (this Activity) SetTo(i vocab.ToPropertyInterface) {
func (this *Activity) SetTo(i vocab.ToPropertyInterface) {
this.To = i
}
// SetType returns the "type" property if it exists, and nil otherwise.
func (this Activity) SetType(i vocab.TypePropertyInterface) {
func (this *Activity) SetType(i vocab.TypePropertyInterface) {
this.Type = i
}
// SetUpdated returns the "updated" property if it exists, and nil otherwise.
func (this Activity) SetUpdated(i vocab.UpdatedPropertyInterface) {
func (this *Activity) SetUpdated(i vocab.UpdatedPropertyInterface) {
this.Updated = i
}
// SetUrl returns the "url" property if it exists, and nil otherwise.
func (this Activity) SetUrl(i vocab.UrlPropertyInterface) {
func (this *Activity) SetUrl(i vocab.UrlPropertyInterface) {
this.Url = i
}

View file

@ -79,6 +79,10 @@ type privateManager interface {
// deserialization method for the "InstrumentPropertyInterface"
// non-functional property in the vocabulary "ActivityStreams"
DeserializeInstrumentPropertyActivityStreams() func(map[string]interface{}, map[string]string) (vocab.InstrumentPropertyInterface, error)
// DeserializeLikesPropertyActivityStreams returns the deserialization
// method for the "LikesPropertyInterface" non-functional property in
// the vocabulary "ActivityStreams"
DeserializeLikesPropertyActivityStreams() func(map[string]interface{}, map[string]string) (vocab.LikesPropertyInterface, error)
// DeserializeLocationPropertyActivityStreams returns the deserialization
// method for the "LocationPropertyInterface" non-functional property
// in the vocabulary "ActivityStreams"
@ -115,6 +119,10 @@ type privateManager interface {
// method for the "ResultPropertyInterface" non-functional property in
// the vocabulary "ActivityStreams"
DeserializeResultPropertyActivityStreams() func(map[string]interface{}, map[string]string) (vocab.ResultPropertyInterface, error)
// DeserializeSharesPropertyActivityStreams returns the deserialization
// method for the "SharesPropertyInterface" non-functional property in
// the vocabulary "ActivityStreams"
DeserializeSharesPropertyActivityStreams() func(map[string]interface{}, map[string]string) (vocab.SharesPropertyInterface, error)
// DeserializeStartTimePropertyActivityStreams returns the deserialization
// method for the "StartTimePropertyInterface" non-functional property
// in the vocabulary "ActivityStreams"

Some files were not shown because too many files have changed in this diff Show more