// 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"
	"github.com/go-openapi/validate"
)

// DeviceDatasourceGraph device datasource graph
//
// swagger:model DeviceDatasourceGraph
type DeviceDatasourceGraph struct {

	// display prio
	// Read Only: true
	DisplayPrio int32 `json:"displayPrio,omitempty"`

	// id
	// Read Only: true
	ID int32 `json:"id,omitempty"`

	// name
	// Read Only: true
	Name string `json:"name,omitempty"`

	// title
	// Read Only: true
	Title string `json:"title,omitempty"`
}

// Validate validates this device datasource graph
func (m *DeviceDatasourceGraph) Validate(formats strfmt.Registry) error {
	return nil
}

// ContextValidate validate this device datasource graph based on the context it is used
func (m *DeviceDatasourceGraph) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

func (m *DeviceDatasourceGraph) contextValidateDisplayPrio(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "displayPrio", "body", int32(m.DisplayPrio)); err != nil {
		return err
	}

	return nil
}

func (m *DeviceDatasourceGraph) contextValidateID(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "id", "body", int32(m.ID)); err != nil {
		return err
	}

	return nil
}

func (m *DeviceDatasourceGraph) contextValidateName(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "name", "body", string(m.Name)); err != nil {
		return err
	}

	return nil
}

func (m *DeviceDatasourceGraph) contextValidateTitle(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "title", "body", string(m.Title)); err != nil {
		return err
	}

	return nil
}

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

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