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

package restmodels

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

import (
	strfmt "github.com/go-openapi/strfmt"

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

// BasicNewModel basic new model
// swagger:model BasicNewModel

type BasicNewModel struct {
	BasicModel

	// Location of the model to retrieve it.
	Location string `json:"location,omitempty"`
}

// UnmarshalJSON unmarshals this object from a JSON structure
func (m *BasicNewModel) UnmarshalJSON(raw []byte) error {

	var aO0 BasicModel
	if err := swag.ReadJSON(raw, &aO0); err != nil {
		return err
	}
	m.BasicModel = aO0

	var data struct {
		Location string `json:"location,omitempty"`
	}
	if err := swag.ReadJSON(raw, &data); err != nil {
		return err
	}

	m.Location = data.Location

	return nil
}

// MarshalJSON marshals this object to a JSON structure
func (m BasicNewModel) MarshalJSON() ([]byte, error) {
	var _parts [][]byte

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

	var data struct {
		Location string `json:"location,omitempty"`
	}

	data.Location = m.Location

	jsonData, err := swag.WriteJSON(data)
	if err != nil {
		return nil, err
	}
	_parts = append(_parts, jsonData)

	return swag.ConcatJSON(_parts...), nil
}

// Validate validates this basic new model
func (m *BasicNewModel) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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