Skip to content

Commit

Permalink
feat: add model ProjectScoreCategory (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored Aug 7, 2024
1 parent 9556cde commit a6ac5a4
Show file tree
Hide file tree
Showing 11 changed files with 169 additions and 583 deletions.
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

0 comments on commit a6ac5a4

Please sign in to comment.