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

// CustomVirtualDataPoint custom virtual data point
//
// swagger:model CustomVirtualDataPoint
type CustomVirtualDataPoint struct {

	// custom graph Id
	CustomGraphID int32 `json:"customGraphId,omitempty"`

	// display
	Display *GraphDisplay `json:"display,omitempty"`

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

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

	// rpn
	Rpn string `json:"rpn,omitempty"`
}

// Validate validates this custom virtual data point
func (m *CustomVirtualDataPoint) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *CustomVirtualDataPoint) validateDisplay(formats strfmt.Registry) error {
	if swag.IsZero(m.Display) { // not required
		return nil
	}

	if m.Display != nil {
		if err := m.Display.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("display")
			}
			return err
		}
	}

	return nil
}

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

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

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

func (m *CustomVirtualDataPoint) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error {

	if m.Display != nil {
		if err := m.Display.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("display")
			}
			return err
		}
	}

	return nil
}

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

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