// 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"
	"strconv"

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

// CommonDTCInformation common d t c information
//
// swagger:model common.DTCInformation
type CommonDTCInformation struct {

	// display trouble code
	DisplayTroubleCode string `json:"displayTroubleCode,omitempty"`

	// error text
	ErrorText *CommonDTCInformationErrorText `json:"errorText,omitempty"`

	// short name
	ShortName string `json:"shortName,omitempty"`

	// spl data groups
	SplDataGroups *CommonDTCInformationSplDataGroups `json:"splDataGroups,omitempty"`

	// trouble code
	TroubleCode int64 `json:"troubleCode,omitempty"`

	// trouble code hex
	TroubleCodeHex string `json:"troubleCodeHex,omitempty"`
}

// Validate validates this common d t c information
func (m *CommonDTCInformation) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *CommonDTCInformation) validateErrorText(formats strfmt.Registry) error {
	if swag.IsZero(m.ErrorText) { // not required
		return nil
	}

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

	return nil
}

func (m *CommonDTCInformation) validateSplDataGroups(formats strfmt.Registry) error {
	if swag.IsZero(m.SplDataGroups) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this common d t c information based on the context it is used
func (m *CommonDTCInformation) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *CommonDTCInformation) contextValidateErrorText(ctx context.Context, formats strfmt.Registry) error {

	if m.ErrorText != nil {

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

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

	return nil
}

func (m *CommonDTCInformation) contextValidateSplDataGroups(ctx context.Context, formats strfmt.Registry) error {

	if m.SplDataGroups != nil {

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

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

	return nil
}

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

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

// CommonDTCInformationErrorText common d t c information error text
//
// swagger:model CommonDTCInformationErrorText
type CommonDTCInformationErrorText struct {

	// text
	Text string `json:"text,omitempty"`

	// ti
	Ti string `json:"ti,omitempty"`
}

// Validate validates this common d t c information error text
func (m *CommonDTCInformationErrorText) Validate(formats strfmt.Registry) error {
	return nil
}

// ContextValidate validates this common d t c information error text based on context it is used
func (m *CommonDTCInformationErrorText) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

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

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

// CommonDTCInformationSplDataGroups common d t c information spl data groups
//
// swagger:model CommonDTCInformationSplDataGroups
type CommonDTCInformationSplDataGroups struct {

	// spl data group
	SplDataGroup *CommonDTCInformationSplDataGroupsSplDataGroup `json:"splDataGroup,omitempty"`
}

// Validate validates this common d t c information spl data groups
func (m *CommonDTCInformationSplDataGroups) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *CommonDTCInformationSplDataGroups) validateSplDataGroup(formats strfmt.Registry) error {
	if swag.IsZero(m.SplDataGroup) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this common d t c information spl data groups based on the context it is used
func (m *CommonDTCInformationSplDataGroups) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

func (m *CommonDTCInformationSplDataGroups) contextValidateSplDataGroup(ctx context.Context, formats strfmt.Registry) error {

	if m.SplDataGroup != nil {

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

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

	return nil
}

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

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

// CommonDTCInformationSplDataGroupsSplDataGroup common d t c information spl data groups spl data group
//
// swagger:model CommonDTCInformationSplDataGroupsSplDataGroup
type CommonDTCInformationSplDataGroupsSplDataGroup struct {

	// spl data
	SplData []*CommonDTCInformationSplDataGroupsSplDataGroupSplDataItems0 `json:"splData"`

	// spl data group caption
	SplDataGroupCaption interface{} `json:"splDataGroupCaption,omitempty"`
}

// Validate validates this common d t c information spl data groups spl data group
func (m *CommonDTCInformationSplDataGroupsSplDataGroup) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *CommonDTCInformationSplDataGroupsSplDataGroup) validateSplData(formats strfmt.Registry) error {
	if swag.IsZero(m.SplData) { // not required
		return nil
	}

	for i := 0; i < len(m.SplData); i++ {
		if swag.IsZero(m.SplData[i]) { // not required
			continue
		}

		if m.SplData[i] != nil {
			if err := m.SplData[i].Validate(formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("splDataGroups" + "." + "splDataGroup" + "." + "splData" + "." + strconv.Itoa(i))
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("splDataGroups" + "." + "splDataGroup" + "." + "splData" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

// ContextValidate validate this common d t c information spl data groups spl data group based on the context it is used
func (m *CommonDTCInformationSplDataGroupsSplDataGroup) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

func (m *CommonDTCInformationSplDataGroupsSplDataGroup) contextValidateSplData(ctx context.Context, formats strfmt.Registry) error {

	for i := 0; i < len(m.SplData); i++ {

		if m.SplData[i] != nil {

			if swag.IsZero(m.SplData[i]) { // not required
				return nil
			}

			if err := m.SplData[i].ContextValidate(ctx, formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("splDataGroups" + "." + "splDataGroup" + "." + "splData" + "." + strconv.Itoa(i))
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("splDataGroups" + "." + "splDataGroup" + "." + "splData" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

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

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

// CommonDTCInformationSplDataGroupsSplDataGroupSplDataItems0 common d t c information spl data groups spl data group spl data items0
//
// swagger:model CommonDTCInformationSplDataGroupsSplDataGroupSplDataItems0
type CommonDTCInformationSplDataGroupsSplDataGroupSplDataItems0 struct {

	// semantic information
	SemanticInformation string `json:"semanticInformation,omitempty"`

	// text
	Text string `json:"text,omitempty"`

	// ti
	Ti string `json:"ti,omitempty"`
}

// Validate validates this common d t c information spl data groups spl data group spl data items0
func (m *CommonDTCInformationSplDataGroupsSplDataGroupSplDataItems0) Validate(formats strfmt.Registry) error {
	return nil
}

// ContextValidate validates this common d t c information spl data groups spl data group spl data items0 based on context it is used
func (m *CommonDTCInformationSplDataGroupsSplDataGroupSplDataItems0) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

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

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