// Code generated by ObjectBox; DO NOT EDIT.
// Learn more about defining entities and generating this file - visit https://golang.objectbox.io/entity-annotations

package object

import (
	"errors"
	"github.com/google/flatbuffers/go"
	"github.com/objectbox/objectbox-go/objectbox"
	"github.com/objectbox/objectbox-go/objectbox/fbutils"
)

type typeful_EntityInfo struct {
	objectbox.Entity
	Uid uint64
}

var TypefulBinding = typeful_EntityInfo{
	Entity: objectbox.Entity{
		Id: 3,
	},
	Uid: 959367522974354090,
}

// Typeful_ contains type-based Property helpers to facilitate some common operations such as Queries.
var Typeful_ = struct {
	Id           *objectbox.PropertyUint64
	Int          *objectbox.PropertyInt
	Int8         *objectbox.PropertyInt8
	Int16        *objectbox.PropertyInt16
	Int32        *objectbox.PropertyInt32
	Int64        *objectbox.PropertyInt64
	Uint         *objectbox.PropertyUint
	Uint8        *objectbox.PropertyUint8
	Uint16       *objectbox.PropertyUint16
	Uint32       *objectbox.PropertyUint32
	Uint64       *objectbox.PropertyUint64
	Bool         *objectbox.PropertyBool
	String       *objectbox.PropertyString
	StringVector *objectbox.PropertyStringVector
	Byte         *objectbox.PropertyByte
	ByteVector   *objectbox.PropertyByteVector
	Rune         *objectbox.PropertyRune
	Float32      *objectbox.PropertyFloat32
	FloatVector  *objectbox.PropertyFloat32Vector
	Float64      *objectbox.PropertyFloat64
	Date         *objectbox.PropertyInt64
	Time         *objectbox.PropertyInt64
	Time2        *objectbox.PropertyInt64
	TimeNano     *objectbox.PropertyInt64
}{
	Id: &objectbox.PropertyUint64{
		BaseProperty: &objectbox.BaseProperty{
			Id:     1,
			Entity: &TypefulBinding.Entity,
		},
	},
	Int: &objectbox.PropertyInt{
		BaseProperty: &objectbox.BaseProperty{
			Id:     2,
			Entity: &TypefulBinding.Entity,
		},
	},
	Int8: &objectbox.PropertyInt8{
		BaseProperty: &objectbox.BaseProperty{
			Id:     3,
			Entity: &TypefulBinding.Entity,
		},
	},
	Int16: &objectbox.PropertyInt16{
		BaseProperty: &objectbox.BaseProperty{
			Id:     4,
			Entity: &TypefulBinding.Entity,
		},
	},
	Int32: &objectbox.PropertyInt32{
		BaseProperty: &objectbox.BaseProperty{
			Id:     5,
			Entity: &TypefulBinding.Entity,
		},
	},
	Int64: &objectbox.PropertyInt64{
		BaseProperty: &objectbox.BaseProperty{
			Id:     6,
			Entity: &TypefulBinding.Entity,
		},
	},
	Uint: &objectbox.PropertyUint{
		BaseProperty: &objectbox.BaseProperty{
			Id:     7,
			Entity: &TypefulBinding.Entity,
		},
	},
	Uint8: &objectbox.PropertyUint8{
		BaseProperty: &objectbox.BaseProperty{
			Id:     8,
			Entity: &TypefulBinding.Entity,
		},
	},
	Uint16: &objectbox.PropertyUint16{
		BaseProperty: &objectbox.BaseProperty{
			Id:     9,
			Entity: &TypefulBinding.Entity,
		},
	},
	Uint32: &objectbox.PropertyUint32{
		BaseProperty: &objectbox.BaseProperty{
			Id:     10,
			Entity: &TypefulBinding.Entity,
		},
	},
	Uint64: &objectbox.PropertyUint64{
		BaseProperty: &objectbox.BaseProperty{
			Id:     11,
			Entity: &TypefulBinding.Entity,
		},
	},
	Bool: &objectbox.PropertyBool{
		BaseProperty: &objectbox.BaseProperty{
			Id:     12,
			Entity: &TypefulBinding.Entity,
		},
	},
	String: &objectbox.PropertyString{
		BaseProperty: &objectbox.BaseProperty{
			Id:     13,
			Entity: &TypefulBinding.Entity,
		},
	},
	StringVector: &objectbox.PropertyStringVector{
		BaseProperty: &objectbox.BaseProperty{
			Id:     14,
			Entity: &TypefulBinding.Entity,
		},
	},
	Byte: &objectbox.PropertyByte{
		BaseProperty: &objectbox.BaseProperty{
			Id:     15,
			Entity: &TypefulBinding.Entity,
		},
	},
	ByteVector: &objectbox.PropertyByteVector{
		BaseProperty: &objectbox.BaseProperty{
			Id:     16,
			Entity: &TypefulBinding.Entity,
		},
	},
	Rune: &objectbox.PropertyRune{
		BaseProperty: &objectbox.BaseProperty{
			Id:     17,
			Entity: &TypefulBinding.Entity,
		},
	},
	Float32: &objectbox.PropertyFloat32{
		BaseProperty: &objectbox.BaseProperty{
			Id:     18,
			Entity: &TypefulBinding.Entity,
		},
	},
	FloatVector: &objectbox.PropertyFloat32Vector{
		BaseProperty: &objectbox.BaseProperty{
			Id:     19,
			Entity: &TypefulBinding.Entity,
		},
	},
	Float64: &objectbox.PropertyFloat64{
		BaseProperty: &objectbox.BaseProperty{
			Id:     20,
			Entity: &TypefulBinding.Entity,
		},
	},
	Date: &objectbox.PropertyInt64{
		BaseProperty: &objectbox.BaseProperty{
			Id:     21,
			Entity: &TypefulBinding.Entity,
		},
	},
	Time: &objectbox.PropertyInt64{
		BaseProperty: &objectbox.BaseProperty{
			Id:     22,
			Entity: &TypefulBinding.Entity,
		},
	},
	Time2: &objectbox.PropertyInt64{
		BaseProperty: &objectbox.BaseProperty{
			Id:     23,
			Entity: &TypefulBinding.Entity,
		},
	},
	TimeNano: &objectbox.PropertyInt64{
		BaseProperty: &objectbox.BaseProperty{
			Id:     24,
			Entity: &TypefulBinding.Entity,
		},
	},
}

// GeneratorVersion is called by ObjectBox to verify the compatibility of the generator used to generate this code
func (typeful_EntityInfo) GeneratorVersion() int {
	return 6
}

// AddToModel is called by ObjectBox during model build
func (typeful_EntityInfo) AddToModel(model *objectbox.Model) {
	model.Entity("Typeful", 3, 959367522974354090)
	model.Property("Id", 6, 1, 6745438398739480977)
	model.PropertyFlags(129)
	model.Property("Int", 6, 2, 2897681629866238117)
	model.Property("Int8", 2, 3, 3398579248012586914)
	model.Property("Int16", 3, 4, 5974317550424871033)
	model.Property("Int32", 5, 5, 3317123977833389635)
	model.Property("Int64", 6, 6, 5001958211167890979)
	model.Property("Uint", 6, 7, 167566062957544642)
	model.PropertyFlags(8192)
	model.Property("Uint8", 2, 8, 4778690082005258714)
	model.PropertyFlags(8192)
	model.Property("Uint16", 3, 9, 1059542851699319360)
	model.PropertyFlags(8192)
	model.Property("Uint32", 5, 10, 6972732843819909978)
	model.PropertyFlags(8192)
	model.Property("Uint64", 6, 11, 5558237345453186302)
	model.PropertyFlags(8192)
	model.Property("Bool", 1, 12, 7845762441295307478)
	model.Property("String", 9, 13, 771642788862502430)
	model.Property("StringVector", 30, 14, 8514850266767180993)
	model.Property("Byte", 2, 15, 8683452355129068124)
	model.PropertyFlags(8192)
	model.Property("ByteVector", 23, 16, 4345851588384648695)
	model.Property("Rune", 5, 17, 7699391924090763411)
	model.Property("Float32", 7, 18, 388440063886460141)
	model.Property("FloatVector", 28, 19, 7561811714888168464)
	model.Property("Float64", 8, 20, 3959279844101328186)
	model.Property("Date", 10, 21, 8902041070398994519)
	model.PropertyFlags(8)
	model.PropertyIndex(1, 303089054982227392)
	model.Property("Time", 10, 22, 7338728586234333996)
	model.PropertyFlags(8)
	model.PropertyIndex(2, 5392504858645185670)
	model.Property("Time2", 10, 23, 7847956203786849690)
	model.Property("TimeNano", 12, 24, 406703151708498928)
	model.PropertyFlags(8)
	model.PropertyIndex(3, 4756106358532488297)
	model.EntityLastPropertyId(24, 406703151708498928)
}

// GetId is called by ObjectBox during Put operations to check for existing ID on an object
func (typeful_EntityInfo) GetId(object interface{}) (uint64, error) {
	return object.(*Typeful).Id, nil
}

// SetId is called by ObjectBox during Put to update an ID on an object that has just been inserted
func (typeful_EntityInfo) SetId(object interface{}, id uint64) error {
	object.(*Typeful).Id = id
	return nil
}

// PutRelated is called by ObjectBox to put related entities before the object itself is flattened and put
func (typeful_EntityInfo) PutRelated(ob *objectbox.ObjectBox, object interface{}, id uint64) error {
	return nil
}

// Flatten is called by ObjectBox to transform an object to a FlatBuffer
func (typeful_EntityInfo) Flatten(object interface{}, fbb *flatbuffers.Builder, id uint64) error {
	obj := object.(*Typeful)
	var propTime int64
	{
		var err error
		propTime, err = objectbox.TimeInt64ConvertToDatabaseValue(obj.Time)
		if err != nil {
			return errors.New("converter objectbox.TimeInt64ConvertToDatabaseValue() failed on Typeful.Time: " + err.Error())
		}
	}

	var propTime2 int64
	{
		var err error
		propTime2, err = objectbox.TimeInt64ConvertToDatabaseValue(obj.Time2)
		if err != nil {
			return errors.New("converter objectbox.TimeInt64ConvertToDatabaseValue() failed on Typeful.Time2: " + err.Error())
		}
	}

	var propTimeNano int64
	{
		var err error
		propTimeNano, err = objectbox.NanoTimeInt64ConvertToDatabaseValue(obj.TimeNano)
		if err != nil {
			return errors.New("converter objectbox.NanoTimeInt64ConvertToDatabaseValue() failed on Typeful.TimeNano: " + err.Error())
		}
	}

	var offsetString = fbutils.CreateStringOffset(fbb, obj.String)
	var offsetStringVector = fbutils.CreateStringVectorOffset(fbb, obj.StringVector)
	var offsetByteVector = fbutils.CreateByteVectorOffset(fbb, obj.ByteVector)
	var offsetFloatVector = fbutils.CreateFloatVectorOffset(fbb, obj.FloatVector)

	// build the FlatBuffers object
	fbb.StartObject(24)
	fbutils.SetUint64Slot(fbb, 0, id)
	fbutils.SetInt64Slot(fbb, 1, int64(obj.Int))
	fbutils.SetInt8Slot(fbb, 2, obj.Int8)
	fbutils.SetInt16Slot(fbb, 3, obj.Int16)
	fbutils.SetInt32Slot(fbb, 4, obj.Int32)
	fbutils.SetInt64Slot(fbb, 5, obj.Int64)
	fbutils.SetUint64Slot(fbb, 6, uint64(obj.Uint))
	fbutils.SetUint8Slot(fbb, 7, obj.Uint8)
	fbutils.SetUint16Slot(fbb, 8, obj.Uint16)
	fbutils.SetUint32Slot(fbb, 9, obj.Uint32)
	fbutils.SetUint64Slot(fbb, 10, obj.Uint64)
	fbutils.SetBoolSlot(fbb, 11, obj.Bool)
	fbutils.SetUOffsetTSlot(fbb, 12, offsetString)
	fbutils.SetUOffsetTSlot(fbb, 13, offsetStringVector)
	fbutils.SetUint8Slot(fbb, 14, obj.Byte)
	fbutils.SetUOffsetTSlot(fbb, 15, offsetByteVector)
	fbutils.SetInt32Slot(fbb, 16, obj.Rune)
	fbutils.SetFloat32Slot(fbb, 17, obj.Float32)
	fbutils.SetUOffsetTSlot(fbb, 18, offsetFloatVector)
	fbutils.SetFloat64Slot(fbb, 19, obj.Float64)
	fbutils.SetInt64Slot(fbb, 20, obj.Date)
	fbutils.SetInt64Slot(fbb, 21, propTime)
	fbutils.SetInt64Slot(fbb, 22, propTime2)
	fbutils.SetInt64Slot(fbb, 23, propTimeNano)
	return nil
}

// Load is called by ObjectBox to load an object from a FlatBuffer
func (typeful_EntityInfo) Load(ob *objectbox.ObjectBox, bytes []byte) (interface{}, error) {
	if len(bytes) == 0 { // sanity check, should "never" happen
		return nil, errors.New("can't deserialize an object of type 'Typeful' - no data received")
	}

	var table = &flatbuffers.Table{
		Bytes: bytes,
		Pos:   flatbuffers.GetUOffsetT(bytes),
	}

	var propId = table.GetUint64Slot(4, 0)

	propTime, err := objectbox.TimeInt64ConvertToEntityProperty(fbutils.GetInt64Slot(table, 46))
	if err != nil {
		return nil, errors.New("converter objectbox.TimeInt64ConvertToEntityProperty() failed on Typeful.Time: " + err.Error())
	}

	propTime2, err := objectbox.TimeInt64ConvertToEntityProperty(fbutils.GetInt64Slot(table, 48))
	if err != nil {
		return nil, errors.New("converter objectbox.TimeInt64ConvertToEntityProperty() failed on Typeful.Time2: " + err.Error())
	}

	propTimeNano, err := objectbox.NanoTimeInt64ConvertToEntityProperty(fbutils.GetInt64Slot(table, 50))
	if err != nil {
		return nil, errors.New("converter objectbox.NanoTimeInt64ConvertToEntityProperty() failed on Typeful.TimeNano: " + err.Error())
	}

	return &Typeful{
		Id:           propId,
		Int:          fbutils.GetIntSlot(table, 6),
		Int8:         fbutils.GetInt8Slot(table, 8),
		Int16:        fbutils.GetInt16Slot(table, 10),
		Int32:        fbutils.GetInt32Slot(table, 12),
		Int64:        fbutils.GetInt64Slot(table, 14),
		Uint:         fbutils.GetUintSlot(table, 16),
		Uint8:        fbutils.GetUint8Slot(table, 18),
		Uint16:       fbutils.GetUint16Slot(table, 20),
		Uint32:       fbutils.GetUint32Slot(table, 22),
		Uint64:       fbutils.GetUint64Slot(table, 24),
		Bool:         fbutils.GetBoolSlot(table, 26),
		String:       fbutils.GetStringSlot(table, 28),
		StringVector: fbutils.GetStringVectorSlot(table, 30),
		Byte:         fbutils.GetByteSlot(table, 32),
		ByteVector:   fbutils.GetByteVectorSlot(table, 34),
		Rune:         fbutils.GetRuneSlot(table, 36),
		Float32:      fbutils.GetFloat32Slot(table, 38),
		FloatVector:  fbutils.GetFloatVectorSlot(table, 40),
		Float64:      fbutils.GetFloat64Slot(table, 42),
		Date:         fbutils.GetInt64Slot(table, 44),
		Time:         propTime,
		Time2:        propTime2,
		TimeNano:     propTimeNano,
	}, nil
}

// MakeSlice is called by ObjectBox to construct a new slice to hold the read objects
func (typeful_EntityInfo) MakeSlice(capacity int) interface{} {
	return make([]*Typeful, 0, capacity)
}

// AppendToSlice is called by ObjectBox to fill the slice of the read objects
func (typeful_EntityInfo) AppendToSlice(slice interface{}, object interface{}) interface{} {
	if object == nil {
		return append(slice.([]*Typeful), nil)
	}
	return append(slice.([]*Typeful), object.(*Typeful))
}

// Box provides CRUD access to Typeful objects
type TypefulBox struct {
	*objectbox.Box
}

// BoxForTypeful opens a box of Typeful objects
func BoxForTypeful(ob *objectbox.ObjectBox) *TypefulBox {
	return &TypefulBox{
		Box: ob.InternalBox(3),
	}
}

// Put synchronously inserts/updates a single object.
// In case the Id is not specified, it would be assigned automatically (auto-increment).
// When inserting, the Typeful.Id property on the passed object will be assigned the new ID as well.
func (box *TypefulBox) Put(object *Typeful) (uint64, error) {
	return box.Box.Put(object)
}

// Insert synchronously inserts a single object. As opposed to Put, Insert will fail if given an ID that already exists.
// In case the Id is not specified, it would be assigned automatically (auto-increment).
// When inserting, the Typeful.Id property on the passed object will be assigned the new ID as well.
func (box *TypefulBox) Insert(object *Typeful) (uint64, error) {
	return box.Box.Insert(object)
}

// Update synchronously updates a single object.
// As opposed to Put, Update will fail if an object with the same ID is not found in the database.
func (box *TypefulBox) Update(object *Typeful) error {
	return box.Box.Update(object)
}

// PutAsync asynchronously inserts/updates a single object.
// Deprecated: use box.Async().Put() instead
func (box *TypefulBox) PutAsync(object *Typeful) (uint64, error) {
	return box.Box.PutAsync(object)
}

// PutMany inserts multiple objects in single transaction.
// In case Ids are not set on the objects, they would be assigned automatically (auto-increment).
//
// Returns: IDs of the put objects (in the same order).
// When inserting, the Typeful.Id property on the objects in the slice will be assigned the new IDs as well.
//
// Note: In case an error occurs during the transaction, some of the objects may already have the Typeful.Id assigned
// even though the transaction has been rolled back and the objects are not stored under those IDs.
//
// Note: The slice may be empty or even nil; in both cases, an empty IDs slice and no error is returned.
func (box *TypefulBox) PutMany(objects []*Typeful) ([]uint64, error) {
	return box.Box.PutMany(objects)
}

// Get reads a single object.
//
// Returns nil (and no error) in case the object with the given ID doesn't exist.
func (box *TypefulBox) Get(id uint64) (*Typeful, error) {
	object, err := box.Box.Get(id)
	if err != nil {
		return nil, err
	} else if object == nil {
		return nil, nil
	}
	return object.(*Typeful), nil
}

// GetMany reads multiple objects at once.
// If any of the objects doesn't exist, its position in the return slice is nil
func (box *TypefulBox) GetMany(ids ...uint64) ([]*Typeful, error) {
	objects, err := box.Box.GetMany(ids...)
	if err != nil {
		return nil, err
	}
	return objects.([]*Typeful), nil
}

// GetManyExisting reads multiple objects at once, skipping those that do not exist.
func (box *TypefulBox) GetManyExisting(ids ...uint64) ([]*Typeful, error) {
	objects, err := box.Box.GetManyExisting(ids...)
	if err != nil {
		return nil, err
	}
	return objects.([]*Typeful), nil
}

// GetAll reads all stored objects
func (box *TypefulBox) GetAll() ([]*Typeful, error) {
	objects, err := box.Box.GetAll()
	if err != nil {
		return nil, err
	}
	return objects.([]*Typeful), nil
}

// Remove deletes a single object
func (box *TypefulBox) Remove(object *Typeful) error {
	return box.Box.Remove(object)
}

// RemoveMany deletes multiple objects at once.
// Returns the number of deleted object or error on failure.
// Note that this method will not fail if an object is not found (e.g. already removed).
// In case you need to strictly check whether all of the objects exist before removing them,
// you can execute multiple box.Contains() and box.Remove() inside a single write transaction.
func (box *TypefulBox) RemoveMany(objects ...*Typeful) (uint64, error) {
	var ids = make([]uint64, len(objects))
	for k, object := range objects {
		ids[k] = object.Id
	}
	return box.Box.RemoveIds(ids...)
}

// Creates a query with the given conditions. Use the fields of the Typeful_ struct to create conditions.
// Keep the *TypefulQuery if you intend to execute the query multiple times.
// Note: this function panics if you try to create illegal queries; e.g. use properties of an alien type.
// This is typically a programming error. Use QueryOrError instead if you want the explicit error check.
func (box *TypefulBox) Query(conditions ...objectbox.Condition) *TypefulQuery {
	return &TypefulQuery{
		box.Box.Query(conditions...),
	}
}

// Creates a query with the given conditions. Use the fields of the Typeful_ struct to create conditions.
// Keep the *TypefulQuery if you intend to execute the query multiple times.
func (box *TypefulBox) QueryOrError(conditions ...objectbox.Condition) (*TypefulQuery, error) {
	if query, err := box.Box.QueryOrError(conditions...); err != nil {
		return nil, err
	} else {
		return &TypefulQuery{query}, nil
	}
}

// Async provides access to the default Async Box for asynchronous operations. See TypefulAsyncBox for more information.
func (box *TypefulBox) Async() *TypefulAsyncBox {
	return &TypefulAsyncBox{AsyncBox: box.Box.Async()}
}

// TypefulAsyncBox provides asynchronous operations on Typeful objects.
//
// Asynchronous operations are executed on a separate internal thread for better performance.
//
// There are two main use cases:
//
// 1) "execute & forget:" you gain faster put/remove operations as you don't have to wait for the transaction to finish.
//
// 2) Many small transactions: if your write load is typically a lot of individual puts that happen in parallel,
// this will merge small transactions into bigger ones. This results in a significant gain in overall throughput.
//
// In situations with (extremely) high async load, an async method may be throttled (~1ms) or delayed up to 1 second.
// In the unlikely event that the object could still not be enqueued (full queue), an error will be returned.
//
// Note that async methods do not give you hard durability guarantees like the synchronous Box provides.
// There is a small time window in which the data may not have been committed durably yet.
type TypefulAsyncBox struct {
	*objectbox.AsyncBox
}

// AsyncBoxForTypeful creates a new async box with the given operation timeout in case an async queue is full.
// The returned struct must be freed explicitly using the Close() method.
// It's usually preferable to use TypefulBox::Async() which takes care of resource management and doesn't require closing.
func AsyncBoxForTypeful(ob *objectbox.ObjectBox, timeoutMs uint64) *TypefulAsyncBox {
	var async, err = objectbox.NewAsyncBox(ob, 3, timeoutMs)
	if err != nil {
		panic("Could not create async box for entity ID 3: %s" + err.Error())
	}
	return &TypefulAsyncBox{AsyncBox: async}
}

// Put inserts/updates a single object asynchronously.
// When inserting a new object, the Id property on the passed object will be assigned the new ID the entity would hold
// if the insert is ultimately successful. The newly assigned ID may not become valid if the insert fails.
func (asyncBox *TypefulAsyncBox) Put(object *Typeful) (uint64, error) {
	return asyncBox.AsyncBox.Put(object)
}

// Insert a single object asynchronously.
// The Id property on the passed object will be assigned the new ID the entity would hold if the insert is ultimately
// successful. The newly assigned ID may not become valid if the insert fails.
// Fails silently if an object with the same ID already exists (this error is not returned).
func (asyncBox *TypefulAsyncBox) Insert(object *Typeful) (id uint64, err error) {
	return asyncBox.AsyncBox.Insert(object)
}

// Update a single object asynchronously.
// The object must already exists or the update fails silently (without an error returned).
func (asyncBox *TypefulAsyncBox) Update(object *Typeful) error {
	return asyncBox.AsyncBox.Update(object)
}

// Remove deletes a single object asynchronously.
func (asyncBox *TypefulAsyncBox) Remove(object *Typeful) error {
	return asyncBox.AsyncBox.Remove(object)
}

// Query provides a way to search stored objects
//
// For example, you can find all Typeful which Id is either 42 or 47:
//
// box.Query(Typeful_.Id.In(42, 47)).Find()
type TypefulQuery struct {
	*objectbox.Query
}

// Find returns all objects matching the query
func (query *TypefulQuery) Find() ([]*Typeful, error) {
	objects, err := query.Query.Find()
	if err != nil {
		return nil, err
	}
	return objects.([]*Typeful), nil
}

// Offset defines the index of the first object to process (how many objects to skip)
func (query *TypefulQuery) Offset(offset uint64) *TypefulQuery {
	query.Query.Offset(offset)
	return query
}

// Limit sets the number of elements to process by the query
func (query *TypefulQuery) Limit(limit uint64) *TypefulQuery {
	query.Query.Limit(limit)
	return query
}

type tSDate_EntityInfo struct {
	objectbox.Entity
	Uid uint64
}

var TSDateBinding = tSDate_EntityInfo{
	Entity: objectbox.Entity{
		Id: 4,
	},
	Uid: 2914295034816259174,
}

// TSDate_ contains type-based Property helpers to facilitate some common operations such as Queries.
var TSDate_ = struct {
	Id        *objectbox.PropertyUint64
	timestamp *objectbox.PropertyInt64
}{
	Id: &objectbox.PropertyUint64{
		BaseProperty: &objectbox.BaseProperty{
			Id:     1,
			Entity: &TSDateBinding.Entity,
		},
	},
	timestamp: &objectbox.PropertyInt64{
		BaseProperty: &objectbox.BaseProperty{
			Id:     2,
			Entity: &TSDateBinding.Entity,
		},
	},
}

// GeneratorVersion is called by ObjectBox to verify the compatibility of the generator used to generate this code
func (tSDate_EntityInfo) GeneratorVersion() int {
	return 6
}

// AddToModel is called by ObjectBox during model build
func (tSDate_EntityInfo) AddToModel(model *objectbox.Model) {
	model.Entity("TSDate", 4, 2914295034816259174)
	model.Property("Id", 6, 1, 5837486892148644279)
	model.PropertyFlags(1)
	model.Property("timestamp", 10, 2, 4736217237333769909)
	model.PropertyFlags(16384)
	model.EntityLastPropertyId(2, 4736217237333769909)
}

// GetId is called by ObjectBox during Put operations to check for existing ID on an object
func (tSDate_EntityInfo) GetId(object interface{}) (uint64, error) {
	return object.(*TSDate).Id, nil
}

// SetId is called by ObjectBox during Put to update an ID on an object that has just been inserted
func (tSDate_EntityInfo) SetId(object interface{}, id uint64) error {
	object.(*TSDate).Id = id
	return nil
}

// PutRelated is called by ObjectBox to put related entities before the object itself is flattened and put
func (tSDate_EntityInfo) PutRelated(ob *objectbox.ObjectBox, object interface{}, id uint64) error {
	return nil
}

// Flatten is called by ObjectBox to transform an object to a FlatBuffer
func (tSDate_EntityInfo) Flatten(object interface{}, fbb *flatbuffers.Builder, id uint64) error {
	obj := object.(*TSDate)

	// build the FlatBuffers object
	fbb.StartObject(2)
	fbutils.SetUint64Slot(fbb, 0, id)
	fbutils.SetInt64Slot(fbb, 1, obj.timestamp)
	return nil
}

// Load is called by ObjectBox to load an object from a FlatBuffer
func (tSDate_EntityInfo) Load(ob *objectbox.ObjectBox, bytes []byte) (interface{}, error) {
	if len(bytes) == 0 { // sanity check, should "never" happen
		return nil, errors.New("can't deserialize an object of type 'TSDate' - no data received")
	}

	var table = &flatbuffers.Table{
		Bytes: bytes,
		Pos:   flatbuffers.GetUOffsetT(bytes),
	}

	var propId = table.GetUint64Slot(4, 0)

	return &TSDate{
		Id:        propId,
		timestamp: fbutils.GetInt64Slot(table, 6),
	}, nil
}

// MakeSlice is called by ObjectBox to construct a new slice to hold the read objects
func (tSDate_EntityInfo) MakeSlice(capacity int) interface{} {
	return make([]*TSDate, 0, capacity)
}

// AppendToSlice is called by ObjectBox to fill the slice of the read objects
func (tSDate_EntityInfo) AppendToSlice(slice interface{}, object interface{}) interface{} {
	if object == nil {
		return append(slice.([]*TSDate), nil)
	}
	return append(slice.([]*TSDate), object.(*TSDate))
}

// Box provides CRUD access to TSDate objects
type TSDateBox struct {
	*objectbox.Box
}

// BoxForTSDate opens a box of TSDate objects
func BoxForTSDate(ob *objectbox.ObjectBox) *TSDateBox {
	return &TSDateBox{
		Box: ob.InternalBox(4),
	}
}

// Put synchronously inserts/updates a single object.
// In case the Id is not specified, it would be assigned automatically (auto-increment).
// When inserting, the TSDate.Id property on the passed object will be assigned the new ID as well.
func (box *TSDateBox) Put(object *TSDate) (uint64, error) {
	return box.Box.Put(object)
}

// Insert synchronously inserts a single object. As opposed to Put, Insert will fail if given an ID that already exists.
// In case the Id is not specified, it would be assigned automatically (auto-increment).
// When inserting, the TSDate.Id property on the passed object will be assigned the new ID as well.
func (box *TSDateBox) Insert(object *TSDate) (uint64, error) {
	return box.Box.Insert(object)
}

// Update synchronously updates a single object.
// As opposed to Put, Update will fail if an object with the same ID is not found in the database.
func (box *TSDateBox) Update(object *TSDate) error {
	return box.Box.Update(object)
}

// PutAsync asynchronously inserts/updates a single object.
// Deprecated: use box.Async().Put() instead
func (box *TSDateBox) PutAsync(object *TSDate) (uint64, error) {
	return box.Box.PutAsync(object)
}

// PutMany inserts multiple objects in single transaction.
// In case Ids are not set on the objects, they would be assigned automatically (auto-increment).
//
// Returns: IDs of the put objects (in the same order).
// When inserting, the TSDate.Id property on the objects in the slice will be assigned the new IDs as well.
//
// Note: In case an error occurs during the transaction, some of the objects may already have the TSDate.Id assigned
// even though the transaction has been rolled back and the objects are not stored under those IDs.
//
// Note: The slice may be empty or even nil; in both cases, an empty IDs slice and no error is returned.
func (box *TSDateBox) PutMany(objects []*TSDate) ([]uint64, error) {
	return box.Box.PutMany(objects)
}

// Get reads a single object.
//
// Returns nil (and no error) in case the object with the given ID doesn't exist.
func (box *TSDateBox) Get(id uint64) (*TSDate, error) {
	object, err := box.Box.Get(id)
	if err != nil {
		return nil, err
	} else if object == nil {
		return nil, nil
	}
	return object.(*TSDate), nil
}

// GetMany reads multiple objects at once.
// If any of the objects doesn't exist, its position in the return slice is nil
func (box *TSDateBox) GetMany(ids ...uint64) ([]*TSDate, error) {
	objects, err := box.Box.GetMany(ids...)
	if err != nil {
		return nil, err
	}
	return objects.([]*TSDate), nil
}

// GetManyExisting reads multiple objects at once, skipping those that do not exist.
func (box *TSDateBox) GetManyExisting(ids ...uint64) ([]*TSDate, error) {
	objects, err := box.Box.GetManyExisting(ids...)
	if err != nil {
		return nil, err
	}
	return objects.([]*TSDate), nil
}

// GetAll reads all stored objects
func (box *TSDateBox) GetAll() ([]*TSDate, error) {
	objects, err := box.Box.GetAll()
	if err != nil {
		return nil, err
	}
	return objects.([]*TSDate), nil
}

// Remove deletes a single object
func (box *TSDateBox) Remove(object *TSDate) error {
	return box.Box.Remove(object)
}

// RemoveMany deletes multiple objects at once.
// Returns the number of deleted object or error on failure.
// Note that this method will not fail if an object is not found (e.g. already removed).
// In case you need to strictly check whether all of the objects exist before removing them,
// you can execute multiple box.Contains() and box.Remove() inside a single write transaction.
func (box *TSDateBox) RemoveMany(objects ...*TSDate) (uint64, error) {
	var ids = make([]uint64, len(objects))
	for k, object := range objects {
		ids[k] = object.Id
	}
	return box.Box.RemoveIds(ids...)
}

// Creates a query with the given conditions. Use the fields of the TSDate_ struct to create conditions.
// Keep the *TSDateQuery if you intend to execute the query multiple times.
// Note: this function panics if you try to create illegal queries; e.g. use properties of an alien type.
// This is typically a programming error. Use QueryOrError instead if you want the explicit error check.
func (box *TSDateBox) Query(conditions ...objectbox.Condition) *TSDateQuery {
	return &TSDateQuery{
		box.Box.Query(conditions...),
	}
}

// Creates a query with the given conditions. Use the fields of the TSDate_ struct to create conditions.
// Keep the *TSDateQuery if you intend to execute the query multiple times.
func (box *TSDateBox) QueryOrError(conditions ...objectbox.Condition) (*TSDateQuery, error) {
	if query, err := box.Box.QueryOrError(conditions...); err != nil {
		return nil, err
	} else {
		return &TSDateQuery{query}, nil
	}
}

// Async provides access to the default Async Box for asynchronous operations. See TSDateAsyncBox for more information.
func (box *TSDateBox) Async() *TSDateAsyncBox {
	return &TSDateAsyncBox{AsyncBox: box.Box.Async()}
}

// TSDateAsyncBox provides asynchronous operations on TSDate objects.
//
// Asynchronous operations are executed on a separate internal thread for better performance.
//
// There are two main use cases:
//
// 1) "execute & forget:" you gain faster put/remove operations as you don't have to wait for the transaction to finish.
//
// 2) Many small transactions: if your write load is typically a lot of individual puts that happen in parallel,
// this will merge small transactions into bigger ones. This results in a significant gain in overall throughput.
//
// In situations with (extremely) high async load, an async method may be throttled (~1ms) or delayed up to 1 second.
// In the unlikely event that the object could still not be enqueued (full queue), an error will be returned.
//
// Note that async methods do not give you hard durability guarantees like the synchronous Box provides.
// There is a small time window in which the data may not have been committed durably yet.
type TSDateAsyncBox struct {
	*objectbox.AsyncBox
}

// AsyncBoxForTSDate creates a new async box with the given operation timeout in case an async queue is full.
// The returned struct must be freed explicitly using the Close() method.
// It's usually preferable to use TSDateBox::Async() which takes care of resource management and doesn't require closing.
func AsyncBoxForTSDate(ob *objectbox.ObjectBox, timeoutMs uint64) *TSDateAsyncBox {
	var async, err = objectbox.NewAsyncBox(ob, 4, timeoutMs)
	if err != nil {
		panic("Could not create async box for entity ID 4: %s" + err.Error())
	}
	return &TSDateAsyncBox{AsyncBox: async}
}

// Put inserts/updates a single object asynchronously.
// When inserting a new object, the Id property on the passed object will be assigned the new ID the entity would hold
// if the insert is ultimately successful. The newly assigned ID may not become valid if the insert fails.
func (asyncBox *TSDateAsyncBox) Put(object *TSDate) (uint64, error) {
	return asyncBox.AsyncBox.Put(object)
}

// Insert a single object asynchronously.
// The Id property on the passed object will be assigned the new ID the entity would hold if the insert is ultimately
// successful. The newly assigned ID may not become valid if the insert fails.
// Fails silently if an object with the same ID already exists (this error is not returned).
func (asyncBox *TSDateAsyncBox) Insert(object *TSDate) (id uint64, err error) {
	return asyncBox.AsyncBox.Insert(object)
}

// Update a single object asynchronously.
// The object must already exists or the update fails silently (without an error returned).
func (asyncBox *TSDateAsyncBox) Update(object *TSDate) error {
	return asyncBox.AsyncBox.Update(object)
}

// Remove deletes a single object asynchronously.
func (asyncBox *TSDateAsyncBox) Remove(object *TSDate) error {
	return asyncBox.AsyncBox.Remove(object)
}

// Query provides a way to search stored objects
//
// For example, you can find all TSDate which Id is either 42 or 47:
//
// box.Query(TSDate_.Id.In(42, 47)).Find()
type TSDateQuery struct {
	*objectbox.Query
}

// Find returns all objects matching the query
func (query *TSDateQuery) Find() ([]*TSDate, error) {
	objects, err := query.Query.Find()
	if err != nil {
		return nil, err
	}
	return objects.([]*TSDate), nil
}

// Offset defines the index of the first object to process (how many objects to skip)
func (query *TSDateQuery) Offset(offset uint64) *TSDateQuery {
	query.Query.Offset(offset)
	return query
}

// Limit sets the number of elements to process by the query
func (query *TSDateQuery) Limit(limit uint64) *TSDateQuery {
	query.Query.Limit(limit)
	return query
}

type tSDateNano_EntityInfo struct {
	objectbox.Entity
	Uid uint64
}

var TSDateNanoBinding = tSDateNano_EntityInfo{
	Entity: objectbox.Entity{
		Id: 5,
	},
	Uid: 1395437218309923052,
}

// TSDateNano_ contains type-based Property helpers to facilitate some common operations such as Queries.
var TSDateNano_ = struct {
	Id        *objectbox.PropertyUint64
	timestamp *objectbox.PropertyInt64
}{
	Id: &objectbox.PropertyUint64{
		BaseProperty: &objectbox.BaseProperty{
			Id:     1,
			Entity: &TSDateNanoBinding.Entity,
		},
	},
	timestamp: &objectbox.PropertyInt64{
		BaseProperty: &objectbox.BaseProperty{
			Id:     2,
			Entity: &TSDateNanoBinding.Entity,
		},
	},
}

// GeneratorVersion is called by ObjectBox to verify the compatibility of the generator used to generate this code
func (tSDateNano_EntityInfo) GeneratorVersion() int {
	return 6
}

// AddToModel is called by ObjectBox during model build
func (tSDateNano_EntityInfo) AddToModel(model *objectbox.Model) {
	model.Entity("TSDateNano", 5, 1395437218309923052)
	model.Property("Id", 6, 1, 2264299874001785192)
	model.PropertyFlags(1)
	model.Property("timestamp", 12, 2, 1061380815263676471)
	model.PropertyFlags(16384)
	model.EntityLastPropertyId(2, 1061380815263676471)
}

// GetId is called by ObjectBox during Put operations to check for existing ID on an object
func (tSDateNano_EntityInfo) GetId(object interface{}) (uint64, error) {
	return object.(*TSDateNano).Id, nil
}

// SetId is called by ObjectBox during Put to update an ID on an object that has just been inserted
func (tSDateNano_EntityInfo) SetId(object interface{}, id uint64) error {
	object.(*TSDateNano).Id = id
	return nil
}

// PutRelated is called by ObjectBox to put related entities before the object itself is flattened and put
func (tSDateNano_EntityInfo) PutRelated(ob *objectbox.ObjectBox, object interface{}, id uint64) error {
	return nil
}

// Flatten is called by ObjectBox to transform an object to a FlatBuffer
func (tSDateNano_EntityInfo) Flatten(object interface{}, fbb *flatbuffers.Builder, id uint64) error {
	obj := object.(*TSDateNano)

	// build the FlatBuffers object
	fbb.StartObject(2)
	fbutils.SetUint64Slot(fbb, 0, id)
	fbutils.SetInt64Slot(fbb, 1, obj.timestamp)
	return nil
}

// Load is called by ObjectBox to load an object from a FlatBuffer
func (tSDateNano_EntityInfo) Load(ob *objectbox.ObjectBox, bytes []byte) (interface{}, error) {
	if len(bytes) == 0 { // sanity check, should "never" happen
		return nil, errors.New("can't deserialize an object of type 'TSDateNano' - no data received")
	}

	var table = &flatbuffers.Table{
		Bytes: bytes,
		Pos:   flatbuffers.GetUOffsetT(bytes),
	}

	var propId = table.GetUint64Slot(4, 0)

	return &TSDateNano{
		Id:        propId,
		timestamp: fbutils.GetInt64Slot(table, 6),
	}, nil
}

// MakeSlice is called by ObjectBox to construct a new slice to hold the read objects
func (tSDateNano_EntityInfo) MakeSlice(capacity int) interface{} {
	return make([]*TSDateNano, 0, capacity)
}

// AppendToSlice is called by ObjectBox to fill the slice of the read objects
func (tSDateNano_EntityInfo) AppendToSlice(slice interface{}, object interface{}) interface{} {
	if object == nil {
		return append(slice.([]*TSDateNano), nil)
	}
	return append(slice.([]*TSDateNano), object.(*TSDateNano))
}

// Box provides CRUD access to TSDateNano objects
type TSDateNanoBox struct {
	*objectbox.Box
}

// BoxForTSDateNano opens a box of TSDateNano objects
func BoxForTSDateNano(ob *objectbox.ObjectBox) *TSDateNanoBox {
	return &TSDateNanoBox{
		Box: ob.InternalBox(5),
	}
}

// Put synchronously inserts/updates a single object.
// In case the Id is not specified, it would be assigned automatically (auto-increment).
// When inserting, the TSDateNano.Id property on the passed object will be assigned the new ID as well.
func (box *TSDateNanoBox) Put(object *TSDateNano) (uint64, error) {
	return box.Box.Put(object)
}

// Insert synchronously inserts a single object. As opposed to Put, Insert will fail if given an ID that already exists.
// In case the Id is not specified, it would be assigned automatically (auto-increment).
// When inserting, the TSDateNano.Id property on the passed object will be assigned the new ID as well.
func (box *TSDateNanoBox) Insert(object *TSDateNano) (uint64, error) {
	return box.Box.Insert(object)
}

// Update synchronously updates a single object.
// As opposed to Put, Update will fail if an object with the same ID is not found in the database.
func (box *TSDateNanoBox) Update(object *TSDateNano) error {
	return box.Box.Update(object)
}

// PutAsync asynchronously inserts/updates a single object.
// Deprecated: use box.Async().Put() instead
func (box *TSDateNanoBox) PutAsync(object *TSDateNano) (uint64, error) {
	return box.Box.PutAsync(object)
}

// PutMany inserts multiple objects in single transaction.
// In case Ids are not set on the objects, they would be assigned automatically (auto-increment).
//
// Returns: IDs of the put objects (in the same order).
// When inserting, the TSDateNano.Id property on the objects in the slice will be assigned the new IDs as well.
//
// Note: In case an error occurs during the transaction, some of the objects may already have the TSDateNano.Id assigned
// even though the transaction has been rolled back and the objects are not stored under those IDs.
//
// Note: The slice may be empty or even nil; in both cases, an empty IDs slice and no error is returned.
func (box *TSDateNanoBox) PutMany(objects []*TSDateNano) ([]uint64, error) {
	return box.Box.PutMany(objects)
}

// Get reads a single object.
//
// Returns nil (and no error) in case the object with the given ID doesn't exist.
func (box *TSDateNanoBox) Get(id uint64) (*TSDateNano, error) {
	object, err := box.Box.Get(id)
	if err != nil {
		return nil, err
	} else if object == nil {
		return nil, nil
	}
	return object.(*TSDateNano), nil
}

// GetMany reads multiple objects at once.
// If any of the objects doesn't exist, its position in the return slice is nil
func (box *TSDateNanoBox) GetMany(ids ...uint64) ([]*TSDateNano, error) {
	objects, err := box.Box.GetMany(ids...)
	if err != nil {
		return nil, err
	}
	return objects.([]*TSDateNano), nil
}

// GetManyExisting reads multiple objects at once, skipping those that do not exist.
func (box *TSDateNanoBox) GetManyExisting(ids ...uint64) ([]*TSDateNano, error) {
	objects, err := box.Box.GetManyExisting(ids...)
	if err != nil {
		return nil, err
	}
	return objects.([]*TSDateNano), nil
}

// GetAll reads all stored objects
func (box *TSDateNanoBox) GetAll() ([]*TSDateNano, error) {
	objects, err := box.Box.GetAll()
	if err != nil {
		return nil, err
	}
	return objects.([]*TSDateNano), nil
}

// Remove deletes a single object
func (box *TSDateNanoBox) Remove(object *TSDateNano) error {
	return box.Box.Remove(object)
}

// RemoveMany deletes multiple objects at once.
// Returns the number of deleted object or error on failure.
// Note that this method will not fail if an object is not found (e.g. already removed).
// In case you need to strictly check whether all of the objects exist before removing them,
// you can execute multiple box.Contains() and box.Remove() inside a single write transaction.
func (box *TSDateNanoBox) RemoveMany(objects ...*TSDateNano) (uint64, error) {
	var ids = make([]uint64, len(objects))
	for k, object := range objects {
		ids[k] = object.Id
	}
	return box.Box.RemoveIds(ids...)
}

// Creates a query with the given conditions. Use the fields of the TSDateNano_ struct to create conditions.
// Keep the *TSDateNanoQuery if you intend to execute the query multiple times.
// Note: this function panics if you try to create illegal queries; e.g. use properties of an alien type.
// This is typically a programming error. Use QueryOrError instead if you want the explicit error check.
func (box *TSDateNanoBox) Query(conditions ...objectbox.Condition) *TSDateNanoQuery {
	return &TSDateNanoQuery{
		box.Box.Query(conditions...),
	}
}

// Creates a query with the given conditions. Use the fields of the TSDateNano_ struct to create conditions.
// Keep the *TSDateNanoQuery if you intend to execute the query multiple times.
func (box *TSDateNanoBox) QueryOrError(conditions ...objectbox.Condition) (*TSDateNanoQuery, error) {
	if query, err := box.Box.QueryOrError(conditions...); err != nil {
		return nil, err
	} else {
		return &TSDateNanoQuery{query}, nil
	}
}

// Async provides access to the default Async Box for asynchronous operations. See TSDateNanoAsyncBox for more information.
func (box *TSDateNanoBox) Async() *TSDateNanoAsyncBox {
	return &TSDateNanoAsyncBox{AsyncBox: box.Box.Async()}
}

// TSDateNanoAsyncBox provides asynchronous operations on TSDateNano objects.
//
// Asynchronous operations are executed on a separate internal thread for better performance.
//
// There are two main use cases:
//
// 1) "execute & forget:" you gain faster put/remove operations as you don't have to wait for the transaction to finish.
//
// 2) Many small transactions: if your write load is typically a lot of individual puts that happen in parallel,
// this will merge small transactions into bigger ones. This results in a significant gain in overall throughput.
//
// In situations with (extremely) high async load, an async method may be throttled (~1ms) or delayed up to 1 second.
// In the unlikely event that the object could still not be enqueued (full queue), an error will be returned.
//
// Note that async methods do not give you hard durability guarantees like the synchronous Box provides.
// There is a small time window in which the data may not have been committed durably yet.
type TSDateNanoAsyncBox struct {
	*objectbox.AsyncBox
}

// AsyncBoxForTSDateNano creates a new async box with the given operation timeout in case an async queue is full.
// The returned struct must be freed explicitly using the Close() method.
// It's usually preferable to use TSDateNanoBox::Async() which takes care of resource management and doesn't require closing.
func AsyncBoxForTSDateNano(ob *objectbox.ObjectBox, timeoutMs uint64) *TSDateNanoAsyncBox {
	var async, err = objectbox.NewAsyncBox(ob, 5, timeoutMs)
	if err != nil {
		panic("Could not create async box for entity ID 5: %s" + err.Error())
	}
	return &TSDateNanoAsyncBox{AsyncBox: async}
}

// Put inserts/updates a single object asynchronously.
// When inserting a new object, the Id property on the passed object will be assigned the new ID the entity would hold
// if the insert is ultimately successful. The newly assigned ID may not become valid if the insert fails.
func (asyncBox *TSDateNanoAsyncBox) Put(object *TSDateNano) (uint64, error) {
	return asyncBox.AsyncBox.Put(object)
}

// Insert a single object asynchronously.
// The Id property on the passed object will be assigned the new ID the entity would hold if the insert is ultimately
// successful. The newly assigned ID may not become valid if the insert fails.
// Fails silently if an object with the same ID already exists (this error is not returned).
func (asyncBox *TSDateNanoAsyncBox) Insert(object *TSDateNano) (id uint64, err error) {
	return asyncBox.AsyncBox.Insert(object)
}

// Update a single object asynchronously.
// The object must already exists or the update fails silently (without an error returned).
func (asyncBox *TSDateNanoAsyncBox) Update(object *TSDateNano) error {
	return asyncBox.AsyncBox.Update(object)
}

// Remove deletes a single object asynchronously.
func (asyncBox *TSDateNanoAsyncBox) Remove(object *TSDateNano) error {
	return asyncBox.AsyncBox.Remove(object)
}

// Query provides a way to search stored objects
//
// For example, you can find all TSDateNano which Id is either 42 or 47:
//
// box.Query(TSDateNano_.Id.In(42, 47)).Find()
type TSDateNanoQuery struct {
	*objectbox.Query
}

// Find returns all objects matching the query
func (query *TSDateNanoQuery) Find() ([]*TSDateNano, error) {
	objects, err := query.Query.Find()
	if err != nil {
		return nil, err
	}
	return objects.([]*TSDateNano), nil
}

// Offset defines the index of the first object to process (how many objects to skip)
func (query *TSDateNanoQuery) Offset(offset uint64) *TSDateNanoQuery {
	query.Query.Offset(offset)
	return query
}

// Limit sets the number of elements to process by the query
func (query *TSDateNanoQuery) Limit(limit uint64) *TSDateNanoQuery {
	query.Query.Limit(limit)
	return query
}
