Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add model ProjectScoreCategory #42

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -553,130 +553,6 @@ private constructor(
}
}

/** For categorical-type project scores, defines a single category */
@JsonDeserialize(builder = ProjectScoreCategory.Builder::class)
@NoAutoDetect
class ProjectScoreCategory
private constructor(
private val name: JsonField<String>,
private val value: JsonField<Double>,
private val additionalProperties: Map<String, JsonValue>,
) {

private var validated: Boolean = false

private var hashCode: Int = 0

/** Name of the category */
fun name(): String = name.getRequired("name")

/** Numerical value of the category. Must be between 0 and 1, inclusive */
fun value(): Double = value.getRequired("value")

/** Name of the category */
@JsonProperty("name") @ExcludeMissing fun _name() = name

/** Numerical value of the category. Must be between 0 and 1, inclusive */
@JsonProperty("value") @ExcludeMissing fun _value() = value

@JsonAnyGetter
@ExcludeMissing
fun _additionalProperties(): Map<String, JsonValue> = additionalProperties

fun validate(): ProjectScoreCategory = apply {
if (!validated) {
name()
value()
validated = true
}
}

fun toBuilder() = Builder().from(this)

override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}

return other is ProjectScoreCategory &&
this.name == other.name &&
this.value == other.value &&
this.additionalProperties == other.additionalProperties
}

override fun hashCode(): Int {
if (hashCode == 0) {
hashCode =
Objects.hash(
name,
value,
additionalProperties,
)
}
return hashCode
}

override fun toString() =
"ProjectScoreCategory{name=$name, value=$value, additionalProperties=$additionalProperties}"

companion object {

@JvmStatic fun builder() = Builder()
}

class Builder {

private var name: JsonField<String> = JsonMissing.of()
private var value: JsonField<Double> = JsonMissing.of()
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()

@JvmSynthetic
internal fun from(projectScoreCategory: ProjectScoreCategory) = apply {
this.name = projectScoreCategory.name
this.value = projectScoreCategory.value
additionalProperties(projectScoreCategory.additionalProperties)
}

/** Name of the category */
fun name(name: String) = name(JsonField.of(name))

/** Name of the category */
@JsonProperty("name")
@ExcludeMissing
fun name(name: JsonField<String>) = apply { this.name = name }

/** Numerical value of the category. Must be between 0 and 1, inclusive */
fun value(value: Double) = value(JsonField.of(value))

/** Numerical value of the category. Must be between 0 and 1, inclusive */
@JsonProperty("value")
@ExcludeMissing
fun value(value: JsonField<Double>) = apply { this.value = value }

fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
this.additionalProperties.clear()
this.additionalProperties.putAll(additionalProperties)
}

@JsonAnySetter
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
this.additionalProperties.put(key, value)
}

fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) =
apply {
this.additionalProperties.putAll(additionalProperties)
}

fun build(): ProjectScoreCategory =
ProjectScoreCategory(
name,
value,
additionalProperties.toUnmodifiable(),
)
}
}

/** For weighted-type project scores, the weights of each score */
@JsonDeserialize(builder = Weighted.Builder::class)
@NoAutoDetect
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
// File generated from our OpenAPI spec by Stainless.

package com.braintrustdata.api.models

import com.braintrustdata.api.core.ExcludeMissing
import com.braintrustdata.api.core.JsonField
import com.braintrustdata.api.core.JsonMissing
import com.braintrustdata.api.core.JsonValue
import com.braintrustdata.api.core.NoAutoDetect
import com.braintrustdata.api.core.toUnmodifiable
import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonAnySetter
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import java.util.Objects

/** For categorical-type project scores, defines a single category */
@JsonDeserialize(builder = ProjectScoreCategory.Builder::class)
@NoAutoDetect
class ProjectScoreCategory
private constructor(
private val name: JsonField<String>,
private val value: JsonField<Double>,
private val additionalProperties: Map<String, JsonValue>,
) {

private var validated: Boolean = false

private var hashCode: Int = 0

/** Name of the category */
fun name(): String = name.getRequired("name")

/** Numerical value of the category. Must be between 0 and 1, inclusive */
fun value(): Double = value.getRequired("value")

/** Name of the category */
@JsonProperty("name") @ExcludeMissing fun _name() = name

/** Numerical value of the category. Must be between 0 and 1, inclusive */
@JsonProperty("value") @ExcludeMissing fun _value() = value

@JsonAnyGetter
@ExcludeMissing
fun _additionalProperties(): Map<String, JsonValue> = additionalProperties

fun validate(): ProjectScoreCategory = apply {
if (!validated) {
name()
value()
validated = true
}
}

fun toBuilder() = Builder().from(this)

override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}

return other is ProjectScoreCategory &&
this.name == other.name &&
this.value == other.value &&
this.additionalProperties == other.additionalProperties
}

override fun hashCode(): Int {
if (hashCode == 0) {
hashCode =
Objects.hash(
name,
value,
additionalProperties,
)
}
return hashCode
}

override fun toString() =
"ProjectScoreCategory{name=$name, value=$value, additionalProperties=$additionalProperties}"

companion object {

@JvmStatic fun builder() = Builder()
}

class Builder {

private var name: JsonField<String> = JsonMissing.of()
private var value: JsonField<Double> = JsonMissing.of()
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()

@JvmSynthetic
internal fun from(projectScoreCategory: ProjectScoreCategory) = apply {
this.name = projectScoreCategory.name
this.value = projectScoreCategory.value
additionalProperties(projectScoreCategory.additionalProperties)
}

/** Name of the category */
fun name(name: String) = name(JsonField.of(name))

/** Name of the category */
@JsonProperty("name")
@ExcludeMissing
fun name(name: JsonField<String>) = apply { this.name = name }

/** Numerical value of the category. Must be between 0 and 1, inclusive */
fun value(value: Double) = value(JsonField.of(value))

/** Numerical value of the category. Must be between 0 and 1, inclusive */
@JsonProperty("value")
@ExcludeMissing
fun value(value: JsonField<Double>) = apply { this.value = value }

fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
this.additionalProperties.clear()
this.additionalProperties.putAll(additionalProperties)
}

@JsonAnySetter
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
this.additionalProperties.put(key, value)
}

fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
this.additionalProperties.putAll(additionalProperties)
}

fun build(): ProjectScoreCategory =
ProjectScoreCategory(
name,
value,
additionalProperties.toUnmodifiable(),
)
}
}
Loading