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

// BigNumberItem big number item
//
// swagger:model BigNumberItem
type BigNumberItem struct {

	// bottom label
	BottomLabel string `json:"bottomLabel,omitempty"`

	// color thresholds
	ColorThresholds []*ColorThreshold `json:"colorThresholds,omitempty"`

	// data point name
	// Required: true
	DataPointName *string `json:"dataPointName"`

	// position
	Position int32 `json:"position,omitempty"`

	// right label
	RightLabel string `json:"rightLabel,omitempty"`

	// rounding
	Rounding int32 `json:"rounding,omitempty"`

	// use comma separators
	// Required: true
	UseCommaSeparators *bool `json:"useCommaSeparators"`
}

// Validate validates this big number item
func (m *BigNumberItem) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

func (m *BigNumberItem) validateColorThresholds(formats strfmt.Registry) error {
	if swag.IsZero(m.ColorThresholds) { // not required
		return nil
	}

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

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

	}

	return nil
}

func (m *BigNumberItem) validateDataPointName(formats strfmt.Registry) error {

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

	return nil
}

func (m *BigNumberItem) validateUseCommaSeparators(formats strfmt.Registry) error {

	if err := validate.Required("useCommaSeparators", "body", m.UseCommaSeparators); err != nil {
		return err
	}

	return nil
}

// ContextValidate validate this big number item based on the context it is used
func (m *BigNumberItem) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

func (m *BigNumberItem) contextValidateColorThresholds(ctx context.Context, formats strfmt.Registry) error {

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

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

	}

	return nil
}

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

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