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

// DataSourceOverviewGraph data source overview graph
//
// swagger:model DataSourceOverviewGraph
type DataSourceOverviewGraph struct {

	// aggregated
	Aggregated bool `json:"aggregated,omitempty"`

	// base1024
	Base1024 bool `json:"base1024,omitempty"`

	// data points
	DataPoints []*OverviewGraphDataPoint `json:"dataPoints,omitempty"`

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

	// height
	Height int32 `json:"height,omitempty"`

	// id
	ID int32 `json:"id,omitempty"`

	// lines
	Lines []*GraphLine `json:"lines,omitempty"`

	// max value
	MaxValue interface{} `json:"maxValue,omitempty"`

	// min value
	MinValue interface{} `json:"minValue,omitempty"`

	// name
	Name string `json:"name,omitempty"`

	// rigid
	Rigid bool `json:"rigid,omitempty"`

	// time scale
	TimeScale string `json:"timeScale,omitempty"`

	// title
	Title string `json:"title,omitempty"`

	// vertical label
	VerticalLabel string `json:"verticalLabel,omitempty"`

	// virtual data points
	VirtualDataPoints []*GraphVirtualDataPoint `json:"virtualDataPoints,omitempty"`

	// width
	Width int32 `json:"width,omitempty"`
}

// Validate validates this data source overview graph
func (m *DataSourceOverviewGraph) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

func (m *DataSourceOverviewGraph) validateDataPoints(formats strfmt.Registry) error {
	if swag.IsZero(m.DataPoints) { // not required
		return nil
	}

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

		if m.DataPoints[i] != nil {
			if err := m.DataPoints[i].Validate(formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("dataPoints" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

func (m *DataSourceOverviewGraph) validateLines(formats strfmt.Registry) error {
	if swag.IsZero(m.Lines) { // not required
		return nil
	}

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

		if m.Lines[i] != nil {
			if err := m.Lines[i].Validate(formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("lines" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

func (m *DataSourceOverviewGraph) validateVirtualDataPoints(formats strfmt.Registry) error {
	if swag.IsZero(m.VirtualDataPoints) { // not required
		return nil
	}

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

		if m.VirtualDataPoints[i] != nil {
			if err := m.VirtualDataPoints[i].Validate(formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("virtualDataPoints" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

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

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

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

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

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

func (m *DataSourceOverviewGraph) contextValidateDataPoints(ctx context.Context, formats strfmt.Registry) error {

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

		if m.DataPoints[i] != nil {
			if err := m.DataPoints[i].ContextValidate(ctx, formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("dataPoints" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

func (m *DataSourceOverviewGraph) contextValidateLines(ctx context.Context, formats strfmt.Registry) error {

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

		if m.Lines[i] != nil {
			if err := m.Lines[i].ContextValidate(ctx, formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("lines" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

func (m *DataSourceOverviewGraph) contextValidateVirtualDataPoints(ctx context.Context, formats strfmt.Registry) error {

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

		if m.VirtualDataPoints[i] != nil {
			if err := m.VirtualDataPoints[i].ContextValidate(ctx, formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("virtualDataPoints" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

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

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