Skip to content

Commit

Permalink
Add SetType nonfunctional property method
Browse files Browse the repository at this point in the history
  • Loading branch information
cjslep committed Mar 24, 2019
1 parent 1ea8e2c commit b5eecc6
Show file tree
Hide file tree
Showing 61 changed files with 551 additions and 0 deletions.
35 changes: 35 additions & 0 deletions astool/gen/nonfuncprop.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,41 @@ func (p *NonFunctionalPropertyGenerator) funcs() []*codegen.Method {
},
fmt.Sprintf("%s 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.", contextMethod)))
if p.hasTypeKind() {
// SetType Method
methods = append(methods,
codegen.NewCommentedPointerMethod(
p.GetPrivatePackage().Path(),
fmt.Sprintf("%s%s", setMethod, typeInterfaceName),
p.StructName(),
// Requires the property and type public path to be the same.
[]jen.Code{
jen.Id("idx").Int(),
jen.Id("t").Qual(p.GetPublicPackage().Path(), typeInterfaceName),
},
[]jen.Code{jen.Error()},
[]jen.Code{
jen.Id("n").Op(":=").Op("&").Id(
p.iteratorTypeName().CamelName,
).Values(
jen.Dict{
jen.Id(myIndexMemberName): jen.Id("idx"),
},
),
jen.If(
jen.Err().Op(":=").Id("n").Dot(
fmt.Sprintf("Set%s", typeInterfaceName),
).Call(
jen.Id("t"),
),
jen.Err().Op("!=").Nil(),
).Block(
jen.Return(jen.Err()),
),
jen.Parens(jen.Id(codegen.This()).Dot(propertiesName)).Index(jen.Id("idx")).Op("=").Id("n"),
jen.Return(jen.Nil()),

},
fmt.Sprintf("%s%s sets an arbitrary type value to the specified index of the property %q. Invalidates all iterators. Returns an error if the type is not a valid one to set for this property. Panics if the index is out of bounds.", setMethod, typeInterfaceName, p.PropertyName())))
// PrependType Method
methods = append(methods,
codegen.NewCommentedPointerMethod(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5201,6 +5201,18 @@ func (this *ActivityStreamsActorProperty) SetIRI(idx int, v *url.URL) {
}
}

// SetType sets an arbitrary type value to the specified index of the property
// "actor". Invalidates all iterators. Returns an error if the type is not a
// valid one to set for this property. Panics if the index is out of bounds.
func (this *ActivityStreamsActorProperty) SetType(idx int, t vocab.Type) error {
n := &ActivityStreamsActorPropertyIterator{myIdx: idx}
if err := n.SetType(t); err != nil {
return err
}
(this.properties)[idx] = n
return nil
}

// Swap swaps the location of values at two indices for the "actor" property.
func (this ActivityStreamsActorProperty) Swap(i, j int) {
this.properties[i], this.properties[j] = this.properties[j], this.properties[i]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5201,6 +5201,18 @@ func (this *ActivityStreamsAnyOfProperty) SetIRI(idx int, v *url.URL) {
}
}

// SetType sets an arbitrary type value to the specified index of the property
// "anyOf". Invalidates all iterators. Returns an error if the type is not a
// valid one to set for this property. Panics if the index is out of bounds.
func (this *ActivityStreamsAnyOfProperty) SetType(idx int, t vocab.Type) error {
n := &ActivityStreamsAnyOfPropertyIterator{myIdx: idx}
if err := n.SetType(t); err != nil {
return err
}
(this.properties)[idx] = n
return nil
}

// Swap swaps the location of values at two indices for the "anyOf" property.
func (this ActivityStreamsAnyOfProperty) Swap(i, j int) {
this.properties[i], this.properties[j] = this.properties[j], this.properties[i]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5213,6 +5213,19 @@ func (this *ActivityStreamsAttachmentProperty) SetIRI(idx int, v *url.URL) {
}
}

// SetType sets an arbitrary type value to the specified index of the property
// "attachment". Invalidates all iterators. Returns an error if the type is
// not a valid one to set for this property. Panics if the index is out of
// bounds.
func (this *ActivityStreamsAttachmentProperty) SetType(idx int, t vocab.Type) error {
n := &ActivityStreamsAttachmentPropertyIterator{myIdx: idx}
if err := n.SetType(t); err != nil {
return err
}
(this.properties)[idx] = n
return nil
}

// Swap swaps the location of values at two indices for the "attachment" property.
func (this ActivityStreamsAttachmentProperty) Swap(i, j int) {
this.properties[i], this.properties[j] = this.properties[j], this.properties[i]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5250,6 +5250,19 @@ func (this *ActivityStreamsAttributedToProperty) SetIRI(idx int, v *url.URL) {
}
}

// SetType sets an arbitrary type value to the specified index of the property
// "attributedTo". Invalidates all iterators. Returns an error if the type is
// not a valid one to set for this property. Panics if the index is out of
// bounds.
func (this *ActivityStreamsAttributedToProperty) SetType(idx int, t vocab.Type) error {
n := &ActivityStreamsAttributedToPropertyIterator{myIdx: idx}
if err := n.SetType(t); err != nil {
return err
}
(this.properties)[idx] = n
return nil
}

// Swap swaps the location of values at two indices for the "attributedTo"
// property.
func (this ActivityStreamsAttributedToProperty) Swap(i, j int) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5211,6 +5211,18 @@ func (this *ActivityStreamsAudienceProperty) SetIRI(idx int, v *url.URL) {
}
}

// SetType sets an arbitrary type value to the specified index of the property
// "audience". Invalidates all iterators. Returns an error if the type is not
// a valid one to set for this property. Panics if the index is out of bounds.
func (this *ActivityStreamsAudienceProperty) SetType(idx int, t vocab.Type) error {
n := &ActivityStreamsAudiencePropertyIterator{myIdx: idx}
if err := n.SetType(t); err != nil {
return err
}
(this.properties)[idx] = n
return nil
}

// Swap swaps the location of values at two indices for the "audience" property.
func (this ActivityStreamsAudienceProperty) Swap(i, j int) {
this.properties[i], this.properties[j] = this.properties[j], this.properties[i]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5199,6 +5199,18 @@ func (this *ActivityStreamsBccProperty) SetIRI(idx int, v *url.URL) {
}
}

// SetType sets an arbitrary type value to the specified index of the property
// "bcc". Invalidates all iterators. Returns an error if the type is not a
// valid one to set for this property. Panics if the index is out of bounds.
func (this *ActivityStreamsBccProperty) SetType(idx int, t vocab.Type) error {
n := &ActivityStreamsBccPropertyIterator{myIdx: idx}
if err := n.SetType(t); err != nil {
return err
}
(this.properties)[idx] = n
return nil
}

// Swap swaps the location of values at two indices for the "bcc" property.
func (this ActivityStreamsBccProperty) Swap(i, j int) {
this.properties[i], this.properties[j] = this.properties[j], this.properties[i]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5199,6 +5199,18 @@ func (this *ActivityStreamsBtoProperty) SetIRI(idx int, v *url.URL) {
}
}

// SetType sets an arbitrary type value to the specified index of the property
// "bto". Invalidates all iterators. Returns an error if the type is not a
// valid one to set for this property. Panics if the index is out of bounds.
func (this *ActivityStreamsBtoProperty) SetType(idx int, t vocab.Type) error {
n := &ActivityStreamsBtoPropertyIterator{myIdx: idx}
if err := n.SetType(t); err != nil {
return err
}
(this.properties)[idx] = n
return nil
}

// Swap swaps the location of values at two indices for the "bto" property.
func (this ActivityStreamsBtoProperty) Swap(i, j int) {
this.properties[i], this.properties[j] = this.properties[j], this.properties[i]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5199,6 +5199,18 @@ func (this *ActivityStreamsCcProperty) SetIRI(idx int, v *url.URL) {
}
}

// SetType sets an arbitrary type value to the specified index of the property
// "cc". Invalidates all iterators. Returns an error if the type is not a
// valid one to set for this property. Panics if the index is out of bounds.
func (this *ActivityStreamsCcProperty) SetType(idx int, t vocab.Type) error {
n := &ActivityStreamsCcPropertyIterator{myIdx: idx}
if err := n.SetType(t); err != nil {
return err
}
(this.properties)[idx] = n
return nil
}

// Swap swaps the location of values at two indices for the "cc" property.
func (this ActivityStreamsCcProperty) Swap(i, j int) {
this.properties[i], this.properties[j] = this.properties[j], this.properties[i]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5347,6 +5347,18 @@ func (this *ActivityStreamsClosedProperty) SetIRI(idx int, v *url.URL) {
}
}

// SetType sets an arbitrary type value to the specified index of the property
// "closed". Invalidates all iterators. Returns an error if the type is not a
// valid one to set for this property. Panics if the index is out of bounds.
func (this *ActivityStreamsClosedProperty) SetType(idx int, t vocab.Type) error {
n := &ActivityStreamsClosedPropertyIterator{myIdx: idx}
if err := n.SetType(t); err != nil {
return err
}
(this.properties)[idx] = n
return nil
}

// SetXMLSchemaBoolean sets a boolean value to be at the specified index for the
// property "closed". Panics if the index is out of bounds. Invalidates all
// iterators.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5211,6 +5211,18 @@ func (this *ActivityStreamsContextProperty) SetIRI(idx int, v *url.URL) {
}
}

// SetType sets an arbitrary type value to the specified index of the property
// "context". Invalidates all iterators. Returns an error if the type is not a
// valid one to set for this property. Panics if the index is out of bounds.
func (this *ActivityStreamsContextProperty) SetType(idx int, t vocab.Type) error {
n := &ActivityStreamsContextPropertyIterator{myIdx: idx}
if err := n.SetType(t); err != nil {
return err
}
(this.properties)[idx] = n
return nil
}

// Swap swaps the location of values at two indices for the "context" property.
func (this ActivityStreamsContextProperty) Swap(i, j int) {
this.properties[i], this.properties[j] = this.properties[j], this.properties[i]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5108,6 +5108,19 @@ func (this *ActivityStreamsFormerTypeProperty) SetIRI(idx int, v *url.URL) {
}
}

// SetType sets an arbitrary type value to the specified index of the property
// "formerType". Invalidates all iterators. Returns an error if the type is
// not a valid one to set for this property. Panics if the index is out of
// bounds.
func (this *ActivityStreamsFormerTypeProperty) SetType(idx int, t vocab.Type) error {
n := &ActivityStreamsFormerTypePropertyIterator{myIdx: idx}
if err := n.SetType(t); err != nil {
return err
}
(this.properties)[idx] = n
return nil
}

// SetXMLSchemaString sets a string value to be at the specified index for the
// property "formerType". Panics if the index is out of bounds. Invalidates
// all iterators.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5211,6 +5211,18 @@ func (this *ActivityStreamsGeneratorProperty) SetIRI(idx int, v *url.URL) {
}
}

// SetType sets an arbitrary type value to the specified index of the property
// "generator". Invalidates all iterators. Returns an error if the type is not
// a valid one to set for this property. Panics if the index is out of bounds.
func (this *ActivityStreamsGeneratorProperty) SetType(idx int, t vocab.Type) error {
n := &ActivityStreamsGeneratorPropertyIterator{myIdx: idx}
if err := n.SetType(t); err != nil {
return err
}
(this.properties)[idx] = n
return nil
}

// Swap swaps the location of values at two indices for the "generator" property.
func (this ActivityStreamsGeneratorProperty) Swap(i, j int) {
this.properties[i], this.properties[j] = this.properties[j], this.properties[i]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,18 @@ func (this *ActivityStreamsIconProperty) SetIRI(idx int, v *url.URL) {
}
}

// SetType sets an arbitrary type value to the specified index of the property
// "icon". Invalidates all iterators. Returns an error if the type is not a
// valid one to set for this property. Panics if the index is out of bounds.
func (this *ActivityStreamsIconProperty) SetType(idx int, t vocab.Type) error {
n := &ActivityStreamsIconPropertyIterator{myIdx: idx}
if err := n.SetType(t); err != nil {
return err
}
(this.properties)[idx] = n
return nil
}

// Swap swaps the location of values at two indices for the "icon" property.
func (this ActivityStreamsIconProperty) Swap(i, j int) {
this.properties[i], this.properties[j] = this.properties[j], this.properties[i]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,18 @@ func (this *ActivityStreamsImageProperty) SetIRI(idx int, v *url.URL) {
}
}

// SetType sets an arbitrary type value to the specified index of the property
// "image". Invalidates all iterators. Returns an error if the type is not a
// valid one to set for this property. Panics if the index is out of bounds.
func (this *ActivityStreamsImageProperty) SetType(idx int, t vocab.Type) error {
n := &ActivityStreamsImagePropertyIterator{myIdx: idx}
if err := n.SetType(t); err != nil {
return err
}
(this.properties)[idx] = n
return nil
}

// Swap swaps the location of values at two indices for the "image" property.
func (this ActivityStreamsImageProperty) Swap(i, j int) {
this.properties[i], this.properties[j] = this.properties[j], this.properties[i]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5211,6 +5211,18 @@ func (this *ActivityStreamsInReplyToProperty) SetIRI(idx int, v *url.URL) {
}
}

// SetType sets an arbitrary type value to the specified index of the property
// "inReplyTo". Invalidates all iterators. Returns an error if the type is not
// a valid one to set for this property. Panics if the index is out of bounds.
func (this *ActivityStreamsInReplyToProperty) SetType(idx int, t vocab.Type) error {
n := &ActivityStreamsInReplyToPropertyIterator{myIdx: idx}
if err := n.SetType(t); err != nil {
return err
}
(this.properties)[idx] = n
return nil
}

// Swap swaps the location of values at two indices for the "inReplyTo" property.
func (this ActivityStreamsInReplyToProperty) Swap(i, j int) {
this.properties[i], this.properties[j] = this.properties[j], this.properties[i]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5213,6 +5213,19 @@ func (this *ActivityStreamsInstrumentProperty) SetIRI(idx int, v *url.URL) {
}
}

// SetType sets an arbitrary type value to the specified index of the property
// "instrument". Invalidates all iterators. Returns an error if the type is
// not a valid one to set for this property. Panics if the index is out of
// bounds.
func (this *ActivityStreamsInstrumentProperty) SetType(idx int, t vocab.Type) error {
n := &ActivityStreamsInstrumentPropertyIterator{myIdx: idx}
if err := n.SetType(t); err != nil {
return err
}
(this.properties)[idx] = n
return nil
}

// Swap swaps the location of values at two indices for the "instrument" property.
func (this ActivityStreamsInstrumentProperty) Swap(i, j int) {
this.properties[i], this.properties[j] = this.properties[j], this.properties[i]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5201,6 +5201,18 @@ func (this *ActivityStreamsItemsProperty) SetIRI(idx int, v *url.URL) {
}
}

// SetType sets an arbitrary type value to the specified index of the property
// "items". Invalidates all iterators. Returns an error if the type is not a
// valid one to set for this property. Panics if the index is out of bounds.
func (this *ActivityStreamsItemsProperty) SetType(idx int, t vocab.Type) error {
n := &ActivityStreamsItemsPropertyIterator{myIdx: idx}
if err := n.SetType(t); err != nil {
return err
}
(this.properties)[idx] = n
return nil
}

// Swap swaps the location of values at two indices for the "items" property.
func (this ActivityStreamsItemsProperty) Swap(i, j int) {
this.properties[i], this.properties[j] = this.properties[j], this.properties[i]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5211,6 +5211,18 @@ func (this *ActivityStreamsLocationProperty) SetIRI(idx int, v *url.URL) {
}
}

// SetType sets an arbitrary type value to the specified index of the property
// "location". Invalidates all iterators. Returns an error if the type is not
// a valid one to set for this property. Panics if the index is out of bounds.
func (this *ActivityStreamsLocationProperty) SetType(idx int, t vocab.Type) error {
n := &ActivityStreamsLocationPropertyIterator{myIdx: idx}
if err := n.SetType(t); err != nil {
return err
}
(this.properties)[idx] = n
return nil
}

// Swap swaps the location of values at two indices for the "location" property.
func (this ActivityStreamsLocationProperty) Swap(i, j int) {
this.properties[i], this.properties[j] = this.properties[j], this.properties[i]
Expand Down
Loading

0 comments on commit b5eecc6

Please sign in to comment.