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

// TableWidgetInstanceCell table widget instance cell
//
// swagger:model TableWidgetInstanceCell
type TableWidgetInstanceCell struct {

	// data point Id
	// Read Only: true
	DataPointID int32 `json:"dataPointId,omitempty"`

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

	// instance Id
	// Required: true
	InstanceID *int32 `json:"instanceId"`

	// instance name
	// Read Only: true
	InstanceName string `json:"instanceName,omitempty"`

	// validation status code
	// Read Only: true
	ValidationStatusCode int32 `json:"validationStatusCode,omitempty"`
}

// Validate validates this table widget instance cell
func (m *TableWidgetInstanceCell) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *TableWidgetInstanceCell) validateInstanceID(formats strfmt.Registry) error {

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

	return nil
}

// ContextValidate validate this table widget instance cell based on the context it is used
func (m *TableWidgetInstanceCell) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

func (m *TableWidgetInstanceCell) contextValidateDataPointID(ctx context.Context, formats strfmt.Registry) error {

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

	return nil
}

func (m *TableWidgetInstanceCell) 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 *TableWidgetInstanceCell) contextValidateInstanceName(ctx context.Context, formats strfmt.Registry) error {

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

	return nil
}

func (m *TableWidgetInstanceCell) contextValidateValidationStatusCode(ctx context.Context, formats strfmt.Registry) error {

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

	return nil
}

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

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