package table

import (
	
	
)

type MetadataV1Builder struct {
	*MetadataV1
}

// NewMetadataV1Builder returns a new MetadataV1Builder.
func (
	 string,
	 *iceberg.Schema,
	 int64,
	 int,
) *MetadataV1Builder {
	return &MetadataV1Builder{
		MetadataV1: &MetadataV1{
			Schema:    ,
			Partition: []iceberg.PartitionField{}, // Deprecated: use partition-specs and default-spec-id instead. See: https://iceberg.apache.org/spec/#table-metadata
			commonMetadata: commonMetadata{
				FormatVersion:   1,
				Loc:             ,
				LastUpdatedMS:   ,
				LastColumnId:    ,
				CurrentSchemaID: .ID,
				Specs:           []iceberg.PartitionSpec{iceberg.NewPartitionSpec()},
				Props:           iceberg.Properties{},
			},
		},
	}
}

func ( Metadata) *MetadataV1Builder {
	 := &MetadataV1Builder{
		MetadataV1: &MetadataV1{
			Schema:    .CurrentSchema(),
			Partition: []iceberg.PartitionField{}, // Deprecated: use partition-specs and default-spec-id instead. See: https://iceberg.apache.org/spec/#table-metadata
			commonMetadata: commonMetadata{
				FormatVersion:      .Version(),
				UUID:               .TableUUID(),
				Loc:                .Location(),
				Specs:              .PartitionSpecs(),
				DefaultSpecID:      .DefaultPartitionSpec(),
				Props:              .Properties(),
				SchemaList:         .Schemas(),
				CurrentSchemaID:    .SchemaID(),
				LastPartitionID:    .LastPartitionSpecID(),
				SnapshotList:       .Snapshots(),
				CurrentSnapshotID:  .SnapshotID(),
				SnapshotLog:        .GetSnapshotLog(),
				MetadataLog:        .GetMetadataLog(),
				SortOrderList:      .SortOrders(),
				DefaultSortOrderID: .SortOrderID(),
				Refs:               .SnapshotRefs(),
			},
		},
	}
	return 

}

func ( *MetadataV1Builder) ( int64) *MetadataV1Builder {
	.LastUpdatedMS = 
	return 
}

func ( *MetadataV1Builder) ( int) *MetadataV1Builder {
	.FormatVersion = 
	return 
}

func ( *MetadataV1Builder) ( string) *MetadataV1Builder {
	.Loc = 
	return 
}

func ( *MetadataV1Builder) ( *iceberg.Schema) *MetadataV1Builder {
	.Schema = 
	.CurrentSchemaID = .ID
	.LastColumnId = .NumFields()
	.SchemaList = []*iceberg.Schema{}
	return 
}

// WithTableUUID sets the optional table-uuid field of the metadata.
func ( *MetadataV1Builder) ( uuid.UUID) *MetadataV1Builder {
	.UUID = 
	return 
}

// WithSchemas sets the optional schemas field of the metadata.
func ( *MetadataV1Builder) ( []*iceberg.Schema) *MetadataV1Builder {
	.SchemaList = 
	return 
}

// WithCurrentSchemaID sets the optional current-schema-id field of the metadata.
func ( *MetadataV1Builder) ( int) *MetadataV1Builder {
	.CurrentSchemaID = 
	return 
}

// WithProperties sets the optional partition-specs field of the metadata.
func ( *MetadataV1Builder) ( []iceberg.PartitionSpec) *MetadataV1Builder {
	.Specs = 
	return 
}

// WithDefaultSpecID sets the optional default-spec-id field of the metadata.
func ( *MetadataV1Builder) ( int) *MetadataV1Builder {
	.DefaultSpecID = 
	return 
}

// WithLastPartitionID sets the optional last-partition-id field of the metadata.
func ( *MetadataV1Builder) ( int) *MetadataV1Builder {
	 :=  // copy the value to prevent modification after build
	.LastPartitionID = &
	return 
}

// WithProperties sets the optional properties field of the metadata.
func ( *MetadataV1Builder) ( iceberg.Properties) *MetadataV1Builder {
	.Props = 
	return 
}

// WithCurrentSnapshotID sets the optional current-snapshot-id field of the metadata.
func ( *MetadataV1Builder) ( int64) *MetadataV1Builder {
	 :=  // copy the value to prevent modification after build
	.CurrentSnapshotID = &
	if .Refs == nil {
		.Refs = make(map[string]SnapshotRef)
	}
	.Refs["main"] = SnapshotRef{
		SnapshotID:      ,
		SnapshotRefType: BranchRef,
	}
	return 
}

// WithSnapshots sets the optional snapshots field of the metadata.
func ( *MetadataV1Builder) ( []Snapshot) *MetadataV1Builder {
	.SnapshotList = 
	return 
}

// WithSnapshotLog sets the optional snapshot-log field of the metadata.
func ( *MetadataV1Builder) ( []SnapshotLogEntry) *MetadataV1Builder {
	.SnapshotLog = 
	return 
}

// WithMetadataLog sets the optional metadata-log field of the metadata.
func ( *MetadataV1Builder) ( []MetadataLogEntry) *MetadataV1Builder {
	.MetadataLog = 
	return 
}

// WithSortOrders sets the optional sort-orders field of the metadata.
func ( *MetadataV1Builder) ( []SortOrder) *MetadataV1Builder {
	.SortOrderList = 
	return 
}

// WithDefaultSortOrderID sets the optional default-sort-order-id field of the metadata.
func ( *MetadataV1Builder) ( int) *MetadataV1Builder {
	.DefaultSortOrderID = 
	return 
}

// TODO: implement setting table statistics field

func ( *MetadataV1Builder) () Metadata {
	return .MetadataV1
}