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

// LinkedWmiClass linked wmi class
//
// swagger:model LinkedWmiClass
type LinkedWmiClass struct {

	// i l p
	ILP []*ILP `json:"ILP,omitempty"`

	// anchor class w m i property
	// Required: true
	AnchorClassWMIProperty *string `json:"anchorClassWMIProperty"`

	// linked wmi class
	// Required: true
	LinkedWmiClass *string `json:"linkedWmiClass"`

	// match
	Match *PropertyMatchRule `json:"match,omitempty"`

	// my link w m i property
	MyLinkWMIProperty string `json:"myLinkWMIProperty,omitempty"`
}

// Validate validates this linked wmi class
func (m *LinkedWmiClass) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

func (m *LinkedWmiClass) validateILP(formats strfmt.Registry) error {
	if swag.IsZero(m.ILP) { // not required
		return nil
	}

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

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

	}

	return nil
}

func (m *LinkedWmiClass) validateAnchorClassWMIProperty(formats strfmt.Registry) error {

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

	return nil
}

func (m *LinkedWmiClass) validateLinkedWmiClass(formats strfmt.Registry) error {

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

	return nil
}

func (m *LinkedWmiClass) validateMatch(formats strfmt.Registry) error {
	if swag.IsZero(m.Match) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this linked wmi class based on the context it is used
func (m *LinkedWmiClass) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *LinkedWmiClass) contextValidateILP(ctx context.Context, formats strfmt.Registry) error {

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

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

	}

	return nil
}

func (m *LinkedWmiClass) contextValidateMatch(ctx context.Context, formats strfmt.Registry) error {

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

	return nil
}

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

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