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

// PieChartData pie chart data
//
// swagger:model PieChartData
type PieChartData struct {

	// color name
	// Read Only: true
	ColorName string `json:"colorName,omitempty"`

	// data point name
	// Read Only: true
	DataPointName string `json:"dataPointName,omitempty"`

	// legend
	// Read Only: true
	Legend string `json:"legend,omitempty"`

	// value
	// Read Only: true
	Value float64 `json:"value,omitempty"`
}

// Validate validates this pie chart data
func (m *PieChartData) Validate(formats strfmt.Registry) error {
	return nil
}

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

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

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

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

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

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

func (m *PieChartData) contextValidateColorName(ctx context.Context, formats strfmt.Registry) error {

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

	return nil
}

func (m *PieChartData) contextValidateDataPointName(ctx context.Context, formats strfmt.Registry) error {

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

	return nil
}

func (m *PieChartData) contextValidateLegend(ctx context.Context, formats strfmt.Registry) error {

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

	return nil
}

func (m *PieChartData) contextValidateValue(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "value", "body", float64(m.Value)); err != nil {
		return err
	}

	return nil
}

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

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