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

// HostTypeHardwareRequirements host type hardware requirements
//
// swagger:model host-type-hardware-requirements
type HostTypeHardwareRequirements struct {

	// Host requirements that cannot be quantified at the time of calculation. Descriptions or formulas of requiements
	Qualitative []string `json:"qualitative"`

	// Host requirements that can be quantified
	Quantitative *ClusterHostRequirementsDetails `json:"quantitative,omitempty"`
}

// Validate validates this host type hardware requirements
func (m *HostTypeHardwareRequirements) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *HostTypeHardwareRequirements) validateQuantitative(formats strfmt.Registry) error {
	if swag.IsZero(m.Quantitative) { // not required
		return nil
	}

	if m.Quantitative != nil {
		if err := m.Quantitative.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("quantitative")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("quantitative")
			}
			return err
		}
	}

	return nil
}

// ContextValidate validate this host type hardware requirements based on the context it is used
func (m *HostTypeHardwareRequirements) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

func (m *HostTypeHardwareRequirements) contextValidateQuantitative(ctx context.Context, formats strfmt.Registry) error {

	if m.Quantitative != nil {
		if err := m.Quantitative.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("quantitative")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("quantitative")
			}
			return err
		}
	}

	return nil
}

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

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