openmeter / pkg /entitydiff /parent.go
Leon4gr45's picture
Upload folder using huggingface_hub (part 9)
fea99b3 verified
Raw
History Blame Contribute Delete
909 Bytes
package entitydiff
import "github.com/samber/lo"
type NestedEntity[T Entity, P Entity] struct {
Entity T
Parent P
}
func (w NestedEntity[T, P]) GetID() string {
return w.Entity.GetID()
}
func (w NestedEntity[T, P]) IsDeleted() bool {
return w.Entity.IsDeleted()
}
type EqualerNestedEntity[T EqualerEntity[T], P Entity] struct {
Entity T
Parent P
}
func (w EqualerNestedEntity[T, P]) GetID() string {
return w.Entity.GetID()
}
func (w EqualerNestedEntity[T, P]) IsDeleted() bool {
return w.Entity.IsDeleted()
}
func (w EqualerNestedEntity[T, P]) Equal(other EqualerNestedEntity[T, P]) bool {
return w.Entity.Equal(other.Entity)
}
func NewEqualersWithParent[T EqualerEntity[T], P Entity](entity []T, parent P) []EqualerNestedEntity[T, P] {
return lo.Map(entity, func(item T, _ int) EqualerNestedEntity[T, P] {
return EqualerNestedEntity[T, P]{
Entity: item,
Parent: parent,
}
})
}