Code refactoring for bpa operator
[icn.git] / cmd / bpa-operator / vendor / github.com / go-openapi / spec / xml_object.go
1 // Copyright 2015 go-swagger maintainers
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //    http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 package spec
16
17 // XMLObject a metadata object that allows for more fine-tuned XML model definitions.
18 //
19 // For more information: http://goo.gl/8us55a#xmlObject
20 type XMLObject struct {
21         Name      string `json:"name,omitempty"`
22         Namespace string `json:"namespace,omitempty"`
23         Prefix    string `json:"prefix,omitempty"`
24         Attribute bool   `json:"attribute,omitempty"`
25         Wrapped   bool   `json:"wrapped,omitempty"`
26 }
27
28 // WithName sets the xml name for the object
29 func (x *XMLObject) WithName(name string) *XMLObject {
30         x.Name = name
31         return x
32 }
33
34 // WithNamespace sets the xml namespace for the object
35 func (x *XMLObject) WithNamespace(namespace string) *XMLObject {
36         x.Namespace = namespace
37         return x
38 }
39
40 // WithPrefix sets the xml prefix for the object
41 func (x *XMLObject) WithPrefix(prefix string) *XMLObject {
42         x.Prefix = prefix
43         return x
44 }
45
46 // AsAttribute flags this object as xml attribute
47 func (x *XMLObject) AsAttribute() *XMLObject {
48         x.Attribute = true
49         return x
50 }
51
52 // AsElement flags this object as an xml node
53 func (x *XMLObject) AsElement() *XMLObject {
54         x.Attribute = false
55         return x
56 }
57
58 // AsWrapped flags this object as wrapped, this is mostly useful for array types
59 func (x *XMLObject) AsWrapped() *XMLObject {
60         x.Wrapped = true
61         return x
62 }
63
64 // AsUnwrapped flags this object as an xml node
65 func (x *XMLObject) AsUnwrapped() *XMLObject {
66         x.Wrapped = false
67         return x
68 }