github.com/sap/cf-mta-plugin@v2.6.3+incompatible/clients/models/message.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package models
     4  
     5  // This file was generated by the swagger tool.
     6  // Editing this file might prove futile when you re-run the swagger generate command
     7  
     8  import (
     9  	strfmt "github.com/go-openapi/strfmt"
    10  
    11  	"github.com/go-openapi/errors"
    12  	"github.com/go-openapi/swag"
    13  )
    14  
    15  // Message message
    16  // swagger:model Message
    17  
    18  type Message struct {
    19  
    20  	// id
    21  	ID int64 `json:"id,omitempty"`
    22  
    23  	// text
    24  	Text string `json:"text,omitempty"`
    25  
    26  	// type
    27  	Type MessageType `json:"type,omitempty"`
    28  }
    29  
    30  /* polymorph Message id false */
    31  
    32  /* polymorph Message text false */
    33  
    34  /* polymorph Message type false */
    35  
    36  // Validate validates this message
    37  func (m *Message) Validate(formats strfmt.Registry) error {
    38  	var res []error
    39  
    40  	if err := m.validateType(formats); err != nil {
    41  		// prop
    42  		res = append(res, err)
    43  	}
    44  
    45  	if len(res) > 0 {
    46  		return errors.CompositeValidationError(res...)
    47  	}
    48  	return nil
    49  }
    50  
    51  func (m *Message) validateType(formats strfmt.Registry) error {
    52  
    53  	if swag.IsZero(m.Type) { // not required
    54  		return nil
    55  	}
    56  
    57  	if err := m.Type.Validate(formats); err != nil {
    58  		if ve, ok := err.(*errors.Validation); ok {
    59  			return ve.ValidateName("type")
    60  		}
    61  		return err
    62  	}
    63  
    64  	return nil
    65  }
    66  
    67  // MarshalBinary interface implementation
    68  func (m *Message) MarshalBinary() ([]byte, error) {
    69  	if m == nil {
    70  		return nil, nil
    71  	}
    72  	return swag.WriteJSON(m)
    73  }
    74  
    75  // UnmarshalBinary interface implementation
    76  func (m *Message) UnmarshalBinary(b []byte) error {
    77  	var res Message
    78  	if err := swag.ReadJSON(b, &res); err != nil {
    79  		return err
    80  	}
    81  	*m = res
    82  	return nil
    83  }