// Code generated by go-swagger; DO NOT EDIT.

package models

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

import (
	"context"

	"github.com/go-openapi/errors"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag"
)

// APIAppLayerParams api app layer params
//
// swagger:model apiAppLayerParams
type APIAppLayerParams struct {

	// TS003 fPort.
	Ts003FPort int64 `json:"ts003FPort,omitempty"`

	// TS003 version (Application Layer Clock Sync).
	Ts003Version *APITs003Version `json:"ts003Version,omitempty"`

	// TS004 fPort.
	Ts004FPort int64 `json:"ts004FPort,omitempty"`

	// TS004 version (Fragmented Data Block Transport).
	Ts004Version *APITs004Version `json:"ts004Version,omitempty"`

	// TS005 fPort.
	Ts005FPort int64 `json:"ts005FPort,omitempty"`

	// TS005 version (Remote Multicast Setup).
	Ts005Version *APITs005Version `json:"ts005Version,omitempty"`
}

// Validate validates this api app layer params
func (m *APIAppLayerParams) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateTs003Version(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateTs004Version(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateTs005Version(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (m *APIAppLayerParams) validateTs003Version(formats strfmt.Registry) error {
	if swag.IsZero(m.Ts003Version) { // not required
		return nil
	}

	if m.Ts003Version != nil {
		if err := m.Ts003Version.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("ts003Version")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("ts003Version")
			}
			return err
		}
	}

	return nil
}

func (m *APIAppLayerParams) validateTs004Version(formats strfmt.Registry) error {
	if swag.IsZero(m.Ts004Version) { // not required
		return nil
	}

	if m.Ts004Version != nil {
		if err := m.Ts004Version.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("ts004Version")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("ts004Version")
			}
			return err
		}
	}

	return nil
}

func (m *APIAppLayerParams) validateTs005Version(formats strfmt.Registry) error {
	if swag.IsZero(m.Ts005Version) { // not required
		return nil
	}

	if m.Ts005Version != nil {
		if err := m.Ts005Version.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("ts005Version")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("ts005Version")
			}
			return err
		}
	}

	return nil
}

// ContextValidate validate this api app layer params based on the context it is used
func (m *APIAppLayerParams) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

	if err := m.contextValidateTs003Version(ctx, formats); err != nil {
		res = append(res, err)
	}

	if err := m.contextValidateTs004Version(ctx, formats); err != nil {
		res = append(res, err)
	}

	if err := m.contextValidateTs005Version(ctx, formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (m *APIAppLayerParams) contextValidateTs003Version(ctx context.Context, formats strfmt.Registry) error {

	if m.Ts003Version != nil {

		if swag.IsZero(m.Ts003Version) { // not required
			return nil
		}

		if err := m.Ts003Version.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("ts003Version")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("ts003Version")
			}
			return err
		}
	}

	return nil
}

func (m *APIAppLayerParams) contextValidateTs004Version(ctx context.Context, formats strfmt.Registry) error {

	if m.Ts004Version != nil {

		if swag.IsZero(m.Ts004Version) { // not required
			return nil
		}

		if err := m.Ts004Version.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("ts004Version")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("ts004Version")
			}
			return err
		}
	}

	return nil
}

func (m *APIAppLayerParams) contextValidateTs005Version(ctx context.Context, formats strfmt.Registry) error {

	if m.Ts005Version != nil {

		if swag.IsZero(m.Ts005Version) { // not required
			return nil
		}

		if err := m.Ts005Version.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("ts005Version")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("ts005Version")
			}
			return err
		}
	}

	return nil
}

// MarshalBinary interface implementation
func (m *APIAppLayerParams) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}

// UnmarshalBinary interface implementation
func (m *APIAppLayerParams) UnmarshalBinary(b []byte) error {
	var res APIAppLayerParams
	if err := swag.ReadJSON(b, &res); err != nil {
		return err
	}
	*m = res
	return nil
}
