// 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 (
	"github.com/go-openapi/errors"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag"
)

// Dog dog
//
// swagger:model Dog
type Dog struct {
	Pet

	Identifiable

	// breed
	Breed string `json:"breed,omitempty"`
}

// UnmarshalJSON unmarshals this object from a JSON structure
func (m *Dog) UnmarshalJSON(raw []byte) error {
	// AO0
	var aO0 Pet
	if err := swag.ReadJSON(raw, &aO0); err != nil {
		return err
	}
	m.Pet = aO0

	// AO1
	var aO1 Identifiable
	if err := swag.ReadJSON(raw, &aO1); err != nil {
		return err
	}
	m.Identifiable = aO1

	// AO2
	var dataAO2 struct {
		Breed string `json:"breed,omitempty"`
	}
	if err := swag.ReadJSON(raw, &dataAO2); err != nil {
		return err
	}

	m.Breed = dataAO2.Breed

	return nil
}

// MarshalJSON marshals this object to a JSON structure
func (m Dog) MarshalJSON() ([]byte, error) {
	_parts := make([][]byte, 0, 3)

	aO0, err := swag.WriteJSON(m.Pet)
	if err != nil {
		return nil, err
	}
	_parts = append(_parts, aO0)

	aO1, err := swag.WriteJSON(m.Identifiable)
	if err != nil {
		return nil, err
	}
	_parts = append(_parts, aO1)
	var dataAO2 struct {
		Breed string `json:"breed,omitempty"`
	}

	dataAO2.Breed = m.Breed

	jsonDataAO2, errAO2 := swag.WriteJSON(dataAO2)
	if errAO2 != nil {
		return nil, errAO2
	}
	_parts = append(_parts, jsonDataAO2)
	return swag.ConcatJSON(_parts...), nil
}

// Validate validates this dog
func (m *Dog) Validate(formats strfmt.Registry) error {
	var res []error

	// validation for a type composition with Pet
	if err := m.Pet.Validate(formats); err != nil {
		res = append(res, err)
	}
	// validation for a type composition with Identifiable
	if err := m.Identifiable.Validate(formats); err != nil {
		res = append(res, err)
	}

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

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

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