github.com/weaviate/weaviate@v1.24.6/entities/models/c11y_nearest_neighbors.go (about)

     1  //                           _       _
     2  // __      _____  __ ___   ___  __ _| |_ ___
     3  // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
     4  //  \ V  V /  __/ (_| |\ V /| | (_| | ||  __/
     5  //   \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
     6  //
     7  //  Copyright © 2016 - 2024 Weaviate B.V. All rights reserved.
     8  //
     9  //  CONTACT: hello@weaviate.io
    10  //
    11  
    12  // Code generated by go-swagger; DO NOT EDIT.
    13  
    14  package models
    15  
    16  // This file was generated by the swagger tool.
    17  // Editing this file might prove futile when you re-run the swagger generate command
    18  
    19  import (
    20  	"context"
    21  	"strconv"
    22  
    23  	"github.com/go-openapi/errors"
    24  	"github.com/go-openapi/strfmt"
    25  	"github.com/go-openapi/swag"
    26  )
    27  
    28  // C11yNearestNeighbors C11y function to show the nearest neighbors to a word.
    29  //
    30  // swagger:model C11yNearestNeighbors
    31  type C11yNearestNeighbors []*C11yNearestNeighborsItems0
    32  
    33  // Validate validates this c11y nearest neighbors
    34  func (m C11yNearestNeighbors) Validate(formats strfmt.Registry) error {
    35  	var res []error
    36  
    37  	for i := 0; i < len(m); i++ {
    38  		if swag.IsZero(m[i]) { // not required
    39  			continue
    40  		}
    41  
    42  		if m[i] != nil {
    43  			if err := m[i].Validate(formats); err != nil {
    44  				if ve, ok := err.(*errors.Validation); ok {
    45  					return ve.ValidateName(strconv.Itoa(i))
    46  				} else if ce, ok := err.(*errors.CompositeError); ok {
    47  					return ce.ValidateName(strconv.Itoa(i))
    48  				}
    49  				return err
    50  			}
    51  		}
    52  
    53  	}
    54  
    55  	if len(res) > 0 {
    56  		return errors.CompositeValidationError(res...)
    57  	}
    58  	return nil
    59  }
    60  
    61  // ContextValidate validate this c11y nearest neighbors based on the context it is used
    62  func (m C11yNearestNeighbors) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    63  	var res []error
    64  
    65  	for i := 0; i < len(m); i++ {
    66  
    67  		if m[i] != nil {
    68  			if err := m[i].ContextValidate(ctx, formats); err != nil {
    69  				if ve, ok := err.(*errors.Validation); ok {
    70  					return ve.ValidateName(strconv.Itoa(i))
    71  				} else if ce, ok := err.(*errors.CompositeError); ok {
    72  					return ce.ValidateName(strconv.Itoa(i))
    73  				}
    74  				return err
    75  			}
    76  		}
    77  
    78  	}
    79  
    80  	if len(res) > 0 {
    81  		return errors.CompositeValidationError(res...)
    82  	}
    83  	return nil
    84  }
    85  
    86  // C11yNearestNeighborsItems0 c11y nearest neighbors items0
    87  //
    88  // swagger:model C11yNearestNeighborsItems0
    89  type C11yNearestNeighborsItems0 struct {
    90  
    91  	// distance
    92  	Distance float32 `json:"distance,omitempty"`
    93  
    94  	// word
    95  	Word string `json:"word,omitempty"`
    96  }
    97  
    98  // Validate validates this c11y nearest neighbors items0
    99  func (m *C11yNearestNeighborsItems0) Validate(formats strfmt.Registry) error {
   100  	return nil
   101  }
   102  
   103  // ContextValidate validates this c11y nearest neighbors items0 based on context it is used
   104  func (m *C11yNearestNeighborsItems0) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   105  	return nil
   106  }
   107  
   108  // MarshalBinary interface implementation
   109  func (m *C11yNearestNeighborsItems0) MarshalBinary() ([]byte, error) {
   110  	if m == nil {
   111  		return nil, nil
   112  	}
   113  	return swag.WriteJSON(m)
   114  }
   115  
   116  // UnmarshalBinary interface implementation
   117  func (m *C11yNearestNeighborsItems0) UnmarshalBinary(b []byte) error {
   118  	var res C11yNearestNeighborsItems0
   119  	if err := swag.ReadJSON(b, &res); err != nil {
   120  		return err
   121  	}
   122  	*m = res
   123  	return nil
   124  }