Making Collection,OrderedCollectin and Item array implement the ItemMatcher interface
This commit is contained in:
parent
611ae1db29
commit
4d5fd9ff2d
7 changed files with 26 additions and 5 deletions
|
@ -290,3 +290,8 @@ func FollowingNew() *Following {
|
|||
|
||||
return &i
|
||||
}
|
||||
|
||||
// ItemMatches
|
||||
func (c Collection) ItemMatches(it Item) bool {
|
||||
return c.Items.Contains(it.GetLink())
|
||||
}
|
||||
|
|
|
@ -284,3 +284,8 @@ func ToCollectionPage(it Item) (*CollectionPage, error) {
|
|||
}
|
||||
return nil, errors.New("unable to convert to collection page")
|
||||
}
|
||||
|
||||
// ItemMatches
|
||||
func (c CollectionPage) ItemMatches(it Item) bool {
|
||||
return c.Items.Contains(it.GetLink())
|
||||
}
|
||||
|
|
|
@ -92,11 +92,7 @@ func OnCollectionIntf(it Item, fn withCollectionInterfaceFn) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
c := Collection{
|
||||
TotalItems: uint(len(*col)),
|
||||
Items: *col,
|
||||
}
|
||||
return fn(&c)
|
||||
return fn(col)
|
||||
case CollectionType:
|
||||
col, err := ToCollection(it)
|
||||
if err != nil {
|
||||
|
|
1
item.go
1
item.go
|
@ -18,3 +18,4 @@ func Flatten(it Item) Item {
|
|||
}
|
||||
return it
|
||||
}
|
||||
|
||||
|
|
|
@ -151,3 +151,7 @@ func ToItemCollection(it Item) (*ItemCollection, error) {
|
|||
}
|
||||
return nil, errors.New("unable to convert to item collection")
|
||||
}
|
||||
|
||||
func (i ItemCollection) ItemMatches(it Item) bool {
|
||||
return i.Contains(it.GetLink())
|
||||
}
|
||||
|
|
|
@ -385,3 +385,8 @@ func SharesNew() *Shares {
|
|||
|
||||
return &i
|
||||
}
|
||||
|
||||
// ItemMatches
|
||||
func (o OrderedCollection) ItemMatches(it Item) bool {
|
||||
return o.OrderedItems.Contains(it.GetLink())
|
||||
}
|
||||
|
|
|
@ -239,3 +239,8 @@ func ToOrderedCollectionPage(it Item) (*OrderedCollectionPage, error) {
|
|||
}
|
||||
return nil, errors.New("unable to convert to ordered collection page")
|
||||
}
|
||||
|
||||
// ItemMatches
|
||||
func (o OrderedCollectionPage) ItemMatches(it Item) bool {
|
||||
return o.OrderedItems.Contains(it.GetLink())
|
||||
}
|
||||
|
|
Reference in a new issue