mirror of
https://github.com/IBM/fp-go.git
synced 2025-11-23 22:14:53 +02:00
250 lines
8.3 KiB
Go
250 lines
8.3 KiB
Go
package lens
|
|
|
|
// Code generated by go generate; DO NOT EDIT.
|
|
// This file was generated by robots at
|
|
// 2025-11-07 16:13:10.2317216 +0100 CET m=+0.005378701
|
|
|
|
import (
|
|
F "github.com/IBM/fp-go/v2/function"
|
|
L "github.com/IBM/fp-go/v2/optics/lens"
|
|
LO "github.com/IBM/fp-go/v2/optics/lens/option"
|
|
O "github.com/IBM/fp-go/v2/option"
|
|
option "github.com/IBM/fp-go/v2/optics/lens/option"
|
|
)
|
|
|
|
// PersonLenses provides lenses for accessing fields of Person
|
|
type PersonLenses struct {
|
|
Name L.Lens[Person, string]
|
|
Age L.Lens[Person, int]
|
|
Email L.Lens[Person, string]
|
|
Phone LO.LensO[Person, *string]
|
|
}
|
|
|
|
// PersonRefLenses provides lenses for accessing fields of Person via a reference to Person
|
|
type PersonRefLenses struct {
|
|
Name L.Lens[*Person, string]
|
|
Age L.Lens[*Person, int]
|
|
Email L.Lens[*Person, string]
|
|
Phone LO.LensO[*Person, *string]
|
|
}
|
|
|
|
// MakePersonLenses creates a new PersonLenses with lenses for all fields
|
|
func MakePersonLenses() PersonLenses {
|
|
getOrElsePhone := O.GetOrElse(F.ConstNil[string])
|
|
return PersonLenses{
|
|
Name: L.MakeLens(
|
|
func(s Person) string { return s.Name },
|
|
func(s Person, v string) Person { s.Name = v; return s },
|
|
),
|
|
Age: L.MakeLens(
|
|
func(s Person) int { return s.Age },
|
|
func(s Person, v int) Person { s.Age = v; return s },
|
|
),
|
|
Email: L.MakeLens(
|
|
func(s Person) string { return s.Email },
|
|
func(s Person, v string) Person { s.Email = v; return s },
|
|
),
|
|
Phone: L.MakeLens(
|
|
func(s Person) O.Option[*string] { return O.FromNillable(s.Phone) },
|
|
func(s Person, v O.Option[*string]) Person { s.Phone = getOrElsePhone(v); return s },
|
|
),
|
|
}
|
|
}
|
|
|
|
// MakePersonRefLenses creates a new PersonRefLenses with lenses for all fields
|
|
func MakePersonRefLenses() PersonRefLenses {
|
|
getOrElsePhone := O.GetOrElse(F.ConstNil[string])
|
|
return PersonRefLenses{
|
|
Name: L.MakeLensRef(
|
|
func(s *Person) string { return s.Name },
|
|
func(s *Person, v string) *Person { s.Name = v; return s },
|
|
),
|
|
Age: L.MakeLensRef(
|
|
func(s *Person) int { return s.Age },
|
|
func(s *Person, v int) *Person { s.Age = v; return s },
|
|
),
|
|
Email: L.MakeLensRef(
|
|
func(s *Person) string { return s.Email },
|
|
func(s *Person, v string) *Person { s.Email = v; return s },
|
|
),
|
|
Phone: L.MakeLensRef(
|
|
func(s *Person) O.Option[*string] { return O.FromNillable(s.Phone) },
|
|
func(s *Person, v O.Option[*string]) *Person { s.Phone = getOrElsePhone(v); return s },
|
|
),
|
|
}
|
|
}
|
|
|
|
// AddressLenses provides lenses for accessing fields of Address
|
|
type AddressLenses struct {
|
|
Street L.Lens[Address, string]
|
|
City L.Lens[Address, string]
|
|
ZipCode L.Lens[Address, string]
|
|
Country L.Lens[Address, string]
|
|
State LO.LensO[Address, *string]
|
|
}
|
|
|
|
// AddressRefLenses provides lenses for accessing fields of Address via a reference to Address
|
|
type AddressRefLenses struct {
|
|
Street L.Lens[*Address, string]
|
|
City L.Lens[*Address, string]
|
|
ZipCode L.Lens[*Address, string]
|
|
Country L.Lens[*Address, string]
|
|
State LO.LensO[*Address, *string]
|
|
}
|
|
|
|
// MakeAddressLenses creates a new AddressLenses with lenses for all fields
|
|
func MakeAddressLenses() AddressLenses {
|
|
getOrElseState := O.GetOrElse(F.ConstNil[string])
|
|
return AddressLenses{
|
|
Street: L.MakeLens(
|
|
func(s Address) string { return s.Street },
|
|
func(s Address, v string) Address { s.Street = v; return s },
|
|
),
|
|
City: L.MakeLens(
|
|
func(s Address) string { return s.City },
|
|
func(s Address, v string) Address { s.City = v; return s },
|
|
),
|
|
ZipCode: L.MakeLens(
|
|
func(s Address) string { return s.ZipCode },
|
|
func(s Address, v string) Address { s.ZipCode = v; return s },
|
|
),
|
|
Country: L.MakeLens(
|
|
func(s Address) string { return s.Country },
|
|
func(s Address, v string) Address { s.Country = v; return s },
|
|
),
|
|
State: L.MakeLens(
|
|
func(s Address) O.Option[*string] { return O.FromNillable(s.State) },
|
|
func(s Address, v O.Option[*string]) Address { s.State = getOrElseState(v); return s },
|
|
),
|
|
}
|
|
}
|
|
|
|
// MakeAddressRefLenses creates a new AddressRefLenses with lenses for all fields
|
|
func MakeAddressRefLenses() AddressRefLenses {
|
|
getOrElseState := O.GetOrElse(F.ConstNil[string])
|
|
return AddressRefLenses{
|
|
Street: L.MakeLensRef(
|
|
func(s *Address) string { return s.Street },
|
|
func(s *Address, v string) *Address { s.Street = v; return s },
|
|
),
|
|
City: L.MakeLensRef(
|
|
func(s *Address) string { return s.City },
|
|
func(s *Address, v string) *Address { s.City = v; return s },
|
|
),
|
|
ZipCode: L.MakeLensRef(
|
|
func(s *Address) string { return s.ZipCode },
|
|
func(s *Address, v string) *Address { s.ZipCode = v; return s },
|
|
),
|
|
Country: L.MakeLensRef(
|
|
func(s *Address) string { return s.Country },
|
|
func(s *Address, v string) *Address { s.Country = v; return s },
|
|
),
|
|
State: L.MakeLensRef(
|
|
func(s *Address) O.Option[*string] { return O.FromNillable(s.State) },
|
|
func(s *Address, v O.Option[*string]) *Address { s.State = getOrElseState(v); return s },
|
|
),
|
|
}
|
|
}
|
|
|
|
// CompanyLenses provides lenses for accessing fields of Company
|
|
type CompanyLenses struct {
|
|
Name L.Lens[Company, string]
|
|
Address L.Lens[Company, Address]
|
|
CEO L.Lens[Company, Person]
|
|
Website LO.LensO[Company, *string]
|
|
}
|
|
|
|
// CompanyRefLenses provides lenses for accessing fields of Company via a reference to Company
|
|
type CompanyRefLenses struct {
|
|
Name L.Lens[*Company, string]
|
|
Address L.Lens[*Company, Address]
|
|
CEO L.Lens[*Company, Person]
|
|
Website LO.LensO[*Company, *string]
|
|
}
|
|
|
|
// MakeCompanyLenses creates a new CompanyLenses with lenses for all fields
|
|
func MakeCompanyLenses() CompanyLenses {
|
|
getOrElseWebsite := O.GetOrElse(F.ConstNil[string])
|
|
return CompanyLenses{
|
|
Name: L.MakeLens(
|
|
func(s Company) string { return s.Name },
|
|
func(s Company, v string) Company { s.Name = v; return s },
|
|
),
|
|
Address: L.MakeLens(
|
|
func(s Company) Address { return s.Address },
|
|
func(s Company, v Address) Company { s.Address = v; return s },
|
|
),
|
|
CEO: L.MakeLens(
|
|
func(s Company) Person { return s.CEO },
|
|
func(s Company, v Person) Company { s.CEO = v; return s },
|
|
),
|
|
Website: L.MakeLens(
|
|
func(s Company) O.Option[*string] { return O.FromNillable(s.Website) },
|
|
func(s Company, v O.Option[*string]) Company { s.Website = getOrElseWebsite(v); return s },
|
|
),
|
|
}
|
|
}
|
|
|
|
// MakeCompanyRefLenses creates a new CompanyRefLenses with lenses for all fields
|
|
func MakeCompanyRefLenses() CompanyRefLenses {
|
|
getOrElseWebsite := O.GetOrElse(F.ConstNil[string])
|
|
return CompanyRefLenses{
|
|
Name: L.MakeLensRef(
|
|
func(s *Company) string { return s.Name },
|
|
func(s *Company, v string) *Company { s.Name = v; return s },
|
|
),
|
|
Address: L.MakeLensRef(
|
|
func(s *Company) Address { return s.Address },
|
|
func(s *Company, v Address) *Company { s.Address = v; return s },
|
|
),
|
|
CEO: L.MakeLensRef(
|
|
func(s *Company) Person { return s.CEO },
|
|
func(s *Company, v Person) *Company { s.CEO = v; return s },
|
|
),
|
|
Website: L.MakeLensRef(
|
|
func(s *Company) O.Option[*string] { return O.FromNillable(s.Website) },
|
|
func(s *Company, v O.Option[*string]) *Company { s.Website = getOrElseWebsite(v); return s },
|
|
),
|
|
}
|
|
}
|
|
|
|
// CheckOptionLenses provides lenses for accessing fields of CheckOption
|
|
type CheckOptionLenses struct {
|
|
Name L.Lens[CheckOption, option.Option[string]]
|
|
Value L.Lens[CheckOption, string]
|
|
}
|
|
|
|
// CheckOptionRefLenses provides lenses for accessing fields of CheckOption via a reference to CheckOption
|
|
type CheckOptionRefLenses struct {
|
|
Name L.Lens[*CheckOption, option.Option[string]]
|
|
Value L.Lens[*CheckOption, string]
|
|
}
|
|
|
|
// MakeCheckOptionLenses creates a new CheckOptionLenses with lenses for all fields
|
|
func MakeCheckOptionLenses() CheckOptionLenses {
|
|
return CheckOptionLenses{
|
|
Name: L.MakeLens(
|
|
func(s CheckOption) option.Option[string] { return s.Name },
|
|
func(s CheckOption, v option.Option[string]) CheckOption { s.Name = v; return s },
|
|
),
|
|
Value: L.MakeLens(
|
|
func(s CheckOption) string { return s.Value },
|
|
func(s CheckOption, v string) CheckOption { s.Value = v; return s },
|
|
),
|
|
}
|
|
}
|
|
|
|
// MakeCheckOptionRefLenses creates a new CheckOptionRefLenses with lenses for all fields
|
|
func MakeCheckOptionRefLenses() CheckOptionRefLenses {
|
|
return CheckOptionRefLenses{
|
|
Name: L.MakeLensRef(
|
|
func(s *CheckOption) option.Option[string] { return s.Name },
|
|
func(s *CheckOption, v option.Option[string]) *CheckOption { s.Name = v; return s },
|
|
),
|
|
Value: L.MakeLensRef(
|
|
func(s *CheckOption) string { return s.Value },
|
|
func(s *CheckOption, v string) *CheckOption { s.Value = v; return s },
|
|
),
|
|
}
|
|
}
|