Compare commits
27 Commits
Author | SHA1 | Date | |
---|---|---|---|
91bf93a866 | |||
73fb8b137f | |||
d3d6e79329 | |||
f2b7d924e0 | |||
f62010b4e7 | |||
5bd1534270 | |||
4c151ffeea | |||
08a0d2e47c | |||
f19476d3a3 | |||
8ede53fd5c | |||
31a9f44ec1 | |||
0eb2f126b3 | |||
0d658bd6a8 | |||
e924671c2b | |||
04996631b9 | |||
82d80873c8 | |||
487eaba741 | |||
b935cc1e1d | |||
9f2d2dd4e3 | |||
20f8a4f08f | |||
7b39e448bf | |||
3c57c8f5e4 | |||
01b6b59cf5 | |||
2c1c8fbcdc | |||
0dc2b9538f | |||
1ca7abaf0d | |||
a5376cfa82 |
12
.github/workflows/autoupdate.yml
vendored
12
.github/workflows/autoupdate.yml
vendored
@ -1,12 +0,0 @@
|
||||
name: autoupdate
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
jobs:
|
||||
autoupdate:
|
||||
name: autoupdate
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: docker://chinthakagodawita/autoupdate-action:v1
|
||||
env:
|
||||
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
|
32
CHANGELOG.md
32
CHANGELOG.md
@ -12,6 +12,38 @@
|
||||
|
||||
## Released
|
||||
|
||||
## [3.10.0] - January 4th, 2023
|
||||
|
||||
### Added
|
||||
|
||||
- Support for type enrichments! `deprecated` and `description` to start
|
||||
|
||||
## [3.9.0] - November 15th, 2022
|
||||
|
||||
### Added
|
||||
|
||||
- `protobuf-java-converter` module for converting generated protobuf objects to `JsonSchema` representations
|
||||
|
||||
### Changed
|
||||
|
||||
- Application `rootPath` is no longer prefixed to serialized route path when `NotarizedRoute` is resolved
|
||||
|
||||
## [3.8.0] - November 9th, 2022
|
||||
|
||||
### Added
|
||||
|
||||
- Add support for NotarizedResource plugin scoped to route
|
||||
|
||||
### Changed
|
||||
|
||||
- Support registering same path with different authentication and methods
|
||||
|
||||
## [3.7.0] - November 5th, 2022
|
||||
|
||||
### Added
|
||||
|
||||
- Allow users to override media type in request and response
|
||||
|
||||
## [3.6.0] - November 5th, 2022
|
||||
|
||||
### Changed
|
||||
|
@ -1,6 +1,6 @@
|
||||
plugins {
|
||||
kotlin("jvm") version "1.7.20" apply false
|
||||
kotlin("plugin.serialization") version "1.7.20" apply false
|
||||
kotlin("jvm") version "1.8.0" apply false
|
||||
kotlin("plugin.serialization") version "1.8.0" apply false
|
||||
id("io.bkbn.sourdough.library.jvm") version "0.12.0" apply false
|
||||
id("io.bkbn.sourdough.application.jvm") version "0.12.0" apply false
|
||||
id("io.bkbn.sourdough.root") version "0.12.0"
|
||||
|
@ -33,7 +33,7 @@ dependencies {
|
||||
implementation("io.ktor:ktor-server-html-builder:$ktorVersion")
|
||||
implementation("io.ktor:ktor-server-content-negotiation:$ktorVersion")
|
||||
implementation("io.ktor:ktor-serialization-kotlinx-json:$ktorVersion")
|
||||
implementation("ch.qos.logback:logback-classic:1.4.4")
|
||||
implementation("ch.qos.logback:logback-classic:1.4.5")
|
||||
|
||||
// Formatting
|
||||
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:$detektVersion")
|
||||
|
@ -1,13 +1,16 @@
|
||||
package io.bkbn.kompendium.core.metadata
|
||||
|
||||
import io.bkbn.kompendium.enrichment.TypeEnrichment
|
||||
import io.bkbn.kompendium.oas.payload.MediaType
|
||||
import kotlin.reflect.KType
|
||||
import kotlin.reflect.typeOf
|
||||
|
||||
class RequestInfo private constructor(
|
||||
val requestType: KType,
|
||||
val typeEnrichment: TypeEnrichment<*>?,
|
||||
val description: String,
|
||||
val examples: Map<String, MediaType.Example>?
|
||||
val examples: Map<String, MediaType.Example>?,
|
||||
val mediaTypes: Set<String>
|
||||
) {
|
||||
|
||||
companion object {
|
||||
@ -20,14 +23,23 @@ class RequestInfo private constructor(
|
||||
|
||||
class Builder {
|
||||
private var requestType: KType? = null
|
||||
private var typeEnrichment: TypeEnrichment<*>? = null
|
||||
private var description: String? = null
|
||||
private var examples: Map<String, MediaType.Example>? = null
|
||||
private var mediaTypes: Set<String>? = null
|
||||
|
||||
fun requestType(t: KType) = apply {
|
||||
this.requestType = t
|
||||
}
|
||||
|
||||
inline fun <reified T> requestType() = apply { requestType(typeOf<T>()) }
|
||||
fun enrichment(t: TypeEnrichment<*>) = apply {
|
||||
this.typeEnrichment = t
|
||||
}
|
||||
|
||||
inline fun <reified T> requestType(enrichment: TypeEnrichment<T>? = null) = apply {
|
||||
requestType(typeOf<T>())
|
||||
enrichment?.let { enrichment(it) }
|
||||
}
|
||||
|
||||
fun description(s: String) = apply { this.description = s }
|
||||
|
||||
@ -35,10 +47,16 @@ class RequestInfo private constructor(
|
||||
this.examples = e.toMap().mapValues { (_, v) -> MediaType.Example(v) }
|
||||
}
|
||||
|
||||
fun mediaTypes(vararg m: String) = apply {
|
||||
this.mediaTypes = m.toSet()
|
||||
}
|
||||
|
||||
fun build() = RequestInfo(
|
||||
requestType = requestType ?: error("Request type must be present"),
|
||||
description = description ?: error("Description must be present"),
|
||||
examples = examples
|
||||
typeEnrichment = typeEnrichment,
|
||||
examples = examples,
|
||||
mediaTypes = mediaTypes ?: setOf("application/json")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.bkbn.kompendium.core.metadata
|
||||
|
||||
import io.bkbn.kompendium.enrichment.TypeEnrichment
|
||||
import io.bkbn.kompendium.oas.payload.MediaType
|
||||
import io.ktor.http.HttpStatusCode
|
||||
import kotlin.reflect.KType
|
||||
@ -8,8 +9,10 @@ import kotlin.reflect.typeOf
|
||||
class ResponseInfo private constructor(
|
||||
val responseCode: HttpStatusCode,
|
||||
val responseType: KType,
|
||||
val typeEnrichment: TypeEnrichment<*>?,
|
||||
val description: String,
|
||||
val examples: Map<String, MediaType.Example>?
|
||||
val examples: Map<String, MediaType.Example>?,
|
||||
val mediaTypes: Set<String>
|
||||
) {
|
||||
|
||||
companion object {
|
||||
@ -23,8 +26,10 @@ class ResponseInfo private constructor(
|
||||
class Builder {
|
||||
private var responseCode: HttpStatusCode? = null
|
||||
private var responseType: KType? = null
|
||||
private var typeEnrichment: TypeEnrichment<*>? = null
|
||||
private var description: String? = null
|
||||
private var examples: Map<String, MediaType.Example>? = null
|
||||
private var mediaTypes: Set<String>? = null
|
||||
|
||||
fun responseCode(code: HttpStatusCode) = apply {
|
||||
this.responseCode = code
|
||||
@ -34,7 +39,14 @@ class ResponseInfo private constructor(
|
||||
this.responseType = t
|
||||
}
|
||||
|
||||
inline fun <reified T> responseType() = apply { responseType(typeOf<T>()) }
|
||||
fun enrichment(t: TypeEnrichment<*>) = apply {
|
||||
this.typeEnrichment = t
|
||||
}
|
||||
|
||||
inline fun <reified T> responseType(enrichment: TypeEnrichment<T>? = null) = apply {
|
||||
responseType(typeOf<T>())
|
||||
enrichment?.let { enrichment(it) }
|
||||
}
|
||||
|
||||
fun description(s: String) = apply { this.description = s }
|
||||
|
||||
@ -42,11 +54,17 @@ class ResponseInfo private constructor(
|
||||
this.examples = e.toMap().mapValues { (_, v) -> MediaType.Example(v) }
|
||||
}
|
||||
|
||||
fun mediaTypes(vararg m: String) = apply {
|
||||
this.mediaTypes = m.toSet()
|
||||
}
|
||||
|
||||
fun build() = ResponseInfo(
|
||||
responseCode = responseCode ?: error("You must provide a response code in order to build a Response!"),
|
||||
responseType = responseType ?: error("You must provide a response type in order to build a Response!"),
|
||||
description = description ?: error("You must provide a description in order to build a Response!"),
|
||||
examples = examples
|
||||
typeEnrichment = typeEnrichment,
|
||||
examples = examples,
|
||||
mediaTypes = mediaTypes ?: setOf("application/json")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -10,16 +10,17 @@ import io.bkbn.kompendium.core.metadata.PostInfo
|
||||
import io.bkbn.kompendium.core.metadata.PutInfo
|
||||
import io.bkbn.kompendium.core.util.Helpers.addToSpec
|
||||
import io.bkbn.kompendium.core.util.SpecConfig
|
||||
import io.bkbn.kompendium.oas.OpenApiSpec
|
||||
import io.bkbn.kompendium.oas.path.Path
|
||||
import io.bkbn.kompendium.oas.path.PathOperation
|
||||
import io.bkbn.kompendium.oas.payload.Parameter
|
||||
import io.ktor.server.application.ApplicationCallPipeline
|
||||
import io.ktor.server.application.Hook
|
||||
import io.ktor.server.application.PluginBuilder
|
||||
import io.ktor.server.application.createRouteScopedPlugin
|
||||
import io.ktor.server.routing.Route
|
||||
import io.ktor.server.routing.application
|
||||
|
||||
object NotarizedRoute {
|
||||
|
||||
class Config : SpecConfig {
|
||||
override var tags: Set<String> = emptySet()
|
||||
override var parameters: List<Parameter> = emptyList()
|
||||
@ -31,7 +32,6 @@ object NotarizedRoute {
|
||||
override var head: HeadInfo? = null
|
||||
override var options: OptionsInfo? = null
|
||||
override var security: Map<String, List<String>>? = null
|
||||
internal var path: Path? = null
|
||||
}
|
||||
|
||||
private object InstallHook : Hook<(ApplicationCallPipeline) -> Unit> {
|
||||
@ -44,69 +44,53 @@ object NotarizedRoute {
|
||||
name = "NotarizedRoute",
|
||||
createConfiguration = ::Config
|
||||
) {
|
||||
|
||||
// This is required in order to introspect the route path and authentication
|
||||
on(InstallHook) {
|
||||
val route = it as? Route ?: return@on
|
||||
val spec = application.attributes[KompendiumAttributes.openApiSpec]
|
||||
val routePath = route.calculateRoutePath()
|
||||
val authMethods = route.collectAuthMethods()
|
||||
pluginConfig.path?.addDefaultAuthMethods(authMethods)
|
||||
require(spec.paths[routePath] == null) {
|
||||
"""
|
||||
The specified path ${Parameter.Location.path} has already been documented!
|
||||
Please make sure that all notarized paths are unique
|
||||
""".trimIndent()
|
||||
}
|
||||
spec.paths[routePath] = pluginConfig.path
|
||||
?: error("This indicates a bug in Kompendium. Please file a GitHub issue!")
|
||||
|
||||
addToSpec(spec, routePath, authMethods)
|
||||
}
|
||||
|
||||
val spec = application.attributes[KompendiumAttributes.openApiSpec]
|
||||
val serializableReader = application.attributes[KompendiumAttributes.schemaConfigurator]
|
||||
|
||||
val path = Path()
|
||||
path.parameters = pluginConfig.parameters
|
||||
|
||||
pluginConfig.get?.addToSpec(path, spec, pluginConfig, serializableReader)
|
||||
pluginConfig.delete?.addToSpec(path, spec, pluginConfig, serializableReader)
|
||||
pluginConfig.head?.addToSpec(path, spec, pluginConfig, serializableReader)
|
||||
pluginConfig.options?.addToSpec(path, spec, pluginConfig, serializableReader)
|
||||
pluginConfig.post?.addToSpec(path, spec, pluginConfig, serializableReader)
|
||||
pluginConfig.put?.addToSpec(path, spec, pluginConfig, serializableReader)
|
||||
pluginConfig.patch?.addToSpec(path, spec, pluginConfig, serializableReader)
|
||||
|
||||
pluginConfig.path = path
|
||||
}
|
||||
|
||||
private fun Route.calculateRoutePath() = toString().replace(Regex("/\\(.+\\)"), "")
|
||||
private fun Route.collectAuthMethods() = toString()
|
||||
fun <T : SpecConfig> PluginBuilder<T>.addToSpec(
|
||||
spec: OpenApiSpec,
|
||||
fullPath: String,
|
||||
authMethods: List<String>
|
||||
) {
|
||||
val path = spec.paths[fullPath] ?: Path()
|
||||
|
||||
path.parameters = path.parameters?.plus(pluginConfig.parameters) ?: pluginConfig.parameters
|
||||
val serializableReader = application.attributes[KompendiumAttributes.schemaConfigurator]
|
||||
|
||||
pluginConfig.get?.addToSpec(path, spec, pluginConfig, serializableReader, fullPath, authMethods)
|
||||
pluginConfig.delete?.addToSpec(path, spec, pluginConfig, serializableReader, fullPath, authMethods)
|
||||
pluginConfig.head?.addToSpec(path, spec, pluginConfig, serializableReader, fullPath, authMethods)
|
||||
pluginConfig.options?.addToSpec(path, spec, pluginConfig, serializableReader, fullPath, authMethods)
|
||||
pluginConfig.post?.addToSpec(path, spec, pluginConfig, serializableReader, fullPath, authMethods)
|
||||
pluginConfig.put?.addToSpec(path, spec, pluginConfig, serializableReader, fullPath, authMethods)
|
||||
pluginConfig.patch?.addToSpec(path, spec, pluginConfig, serializableReader, fullPath, authMethods)
|
||||
|
||||
spec.paths[fullPath] = path
|
||||
}
|
||||
|
||||
fun Route.calculateRoutePath() = toString()
|
||||
.let {
|
||||
application.environment.rootPath.takeIf { root -> root.isNotEmpty() }
|
||||
?.let { root ->
|
||||
val sanitizedRoute = if (root.startsWith("/")) root else "/$root"
|
||||
it.replace(sanitizedRoute, "")
|
||||
}
|
||||
?: it
|
||||
}
|
||||
.replace(Regex("/\\(.+\\)"), "")
|
||||
|
||||
fun Route.collectAuthMethods() = toString()
|
||||
.split("/")
|
||||
.filter { it.contains(Regex("\\(authenticate .*\\)")) }
|
||||
.map { it.replace("(authenticate ", "").replace(")", "") }
|
||||
.map { it.split(", ") }
|
||||
.flatten()
|
||||
|
||||
private fun Path.addDefaultAuthMethods(methods: List<String>) {
|
||||
get?.addDefaultAuthMethods(methods)
|
||||
put?.addDefaultAuthMethods(methods)
|
||||
post?.addDefaultAuthMethods(methods)
|
||||
delete?.addDefaultAuthMethods(methods)
|
||||
options?.addDefaultAuthMethods(methods)
|
||||
head?.addDefaultAuthMethods(methods)
|
||||
patch?.addDefaultAuthMethods(methods)
|
||||
trace?.addDefaultAuthMethods(methods)
|
||||
}
|
||||
|
||||
private fun PathOperation.addDefaultAuthMethods(methods: List<String>) {
|
||||
methods.forEach { m ->
|
||||
if (security == null || security?.all { s -> !s.containsKey(m) } == true) {
|
||||
if (security == null) {
|
||||
security = mutableListOf(mapOf(m to emptyList()))
|
||||
} else {
|
||||
security?.add(mapOf(m to emptyList()))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,13 +10,14 @@ import io.bkbn.kompendium.core.metadata.PatchInfo
|
||||
import io.bkbn.kompendium.core.metadata.PostInfo
|
||||
import io.bkbn.kompendium.core.metadata.PutInfo
|
||||
import io.bkbn.kompendium.core.metadata.ResponseInfo
|
||||
import io.bkbn.kompendium.enrichment.TypeEnrichment
|
||||
import io.bkbn.kompendium.json.schema.SchemaConfigurator
|
||||
import io.bkbn.kompendium.json.schema.SchemaGenerator
|
||||
import io.bkbn.kompendium.json.schema.definition.NullableDefinition
|
||||
import io.bkbn.kompendium.json.schema.definition.OneOfDefinition
|
||||
import io.bkbn.kompendium.json.schema.definition.ReferenceDefinition
|
||||
import io.bkbn.kompendium.json.schema.util.Helpers.getReferenceSlug
|
||||
import io.bkbn.kompendium.json.schema.util.Helpers.getSimpleSlug
|
||||
import io.bkbn.kompendium.json.schema.util.Helpers.getSlug
|
||||
import io.bkbn.kompendium.oas.OpenApiSpec
|
||||
import io.bkbn.kompendium.oas.path.Path
|
||||
import io.bkbn.kompendium.oas.path.PathOperation
|
||||
@ -24,32 +25,60 @@ import io.bkbn.kompendium.oas.payload.MediaType
|
||||
import io.bkbn.kompendium.oas.payload.Request
|
||||
import io.bkbn.kompendium.oas.payload.Response
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.reflect.KMutableProperty1
|
||||
import kotlin.reflect.KType
|
||||
|
||||
object Helpers {
|
||||
|
||||
fun MethodInfo.addToSpec(path: Path, spec: OpenApiSpec, config: SpecConfig, schemaConfigurator: SchemaConfigurator) {
|
||||
private fun PathOperation.addDefaultAuthMethods(methods: List<String>) {
|
||||
methods.forEach { m ->
|
||||
if (security == null || security?.all { s -> !s.containsKey(m) } == true) {
|
||||
if (security == null) {
|
||||
security = mutableListOf(mapOf(m to emptyList()))
|
||||
} else {
|
||||
security?.add(mapOf(m to emptyList()))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun MethodInfo.addToSpec(
|
||||
path: Path,
|
||||
spec: OpenApiSpec,
|
||||
config: SpecConfig,
|
||||
schemaConfigurator: SchemaConfigurator,
|
||||
routePath: String,
|
||||
authMethods: List<String> = emptyList()
|
||||
) {
|
||||
SchemaGenerator.fromTypeOrUnit(
|
||||
this.response.responseType,
|
||||
spec.components.schemas, schemaConfigurator
|
||||
type = this.response.responseType,
|
||||
cache = spec.components.schemas,
|
||||
schemaConfigurator = schemaConfigurator,
|
||||
enrichment = this.response.typeEnrichment,
|
||||
)?.let { schema ->
|
||||
spec.components.schemas[this.response.responseType.getSimpleSlug()] = schema
|
||||
spec.components.schemas[this.response.responseType.getSlug(this.response.typeEnrichment)] = schema
|
||||
}
|
||||
|
||||
errors.forEach { error ->
|
||||
SchemaGenerator.fromTypeOrUnit(error.responseType, spec.components.schemas, schemaConfigurator)?.let { schema ->
|
||||
spec.components.schemas[error.responseType.getSimpleSlug()] = schema
|
||||
SchemaGenerator.fromTypeOrUnit(
|
||||
type = error.responseType,
|
||||
cache = spec.components.schemas,
|
||||
schemaConfigurator = schemaConfigurator,
|
||||
enrichment = error.typeEnrichment,
|
||||
)?.let { schema ->
|
||||
spec.components.schemas[error.responseType.getSlug(error.typeEnrichment)] = schema
|
||||
}
|
||||
}
|
||||
|
||||
when (this) {
|
||||
is MethodInfoWithRequest -> {
|
||||
SchemaGenerator.fromTypeOrUnit(
|
||||
this.request.requestType,
|
||||
spec.components.schemas,
|
||||
schemaConfigurator
|
||||
type = this.request.requestType,
|
||||
cache = spec.components.schemas,
|
||||
schemaConfigurator = schemaConfigurator,
|
||||
enrichment = this.request.typeEnrichment,
|
||||
)?.let { schema ->
|
||||
spec.components.schemas[this.request.requestType.getSimpleSlug()] = schema
|
||||
spec.components.schemas[this.request.requestType.getSlug(this.request.typeEnrichment)] = schema
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,15 +86,25 @@ object Helpers {
|
||||
}
|
||||
|
||||
val operations = this.toPathOperation(config)
|
||||
operations.addDefaultAuthMethods(authMethods)
|
||||
|
||||
when (this) {
|
||||
is DeleteInfo -> path.delete = operations
|
||||
is GetInfo -> path.get = operations
|
||||
is HeadInfo -> path.head = operations
|
||||
is PatchInfo -> path.patch = operations
|
||||
is PostInfo -> path.post = operations
|
||||
is PutInfo -> path.put = operations
|
||||
is OptionsInfo -> path.options = operations
|
||||
fun setOperation(
|
||||
property: KMutableProperty1<Path, PathOperation?>
|
||||
) {
|
||||
require(property.get(path) == null) {
|
||||
"A route has already been registered for path: $routePath and method: ${property.name.uppercase()}"
|
||||
}
|
||||
property.set(path, operations)
|
||||
}
|
||||
|
||||
return when (this) {
|
||||
is DeleteInfo -> setOperation(Path::delete)
|
||||
is GetInfo -> setOperation(Path::get)
|
||||
is HeadInfo -> setOperation(Path::head)
|
||||
is PatchInfo -> setOperation(Path::patch)
|
||||
is PostInfo -> setOperation(Path::post)
|
||||
is PutInfo -> setOperation(Path::put)
|
||||
is OptionsInfo -> setOperation(Path::options)
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,7 +123,11 @@ object Helpers {
|
||||
requestBody = when (this) {
|
||||
is MethodInfoWithRequest -> Request(
|
||||
description = this.request.description,
|
||||
content = this.request.requestType.toReferenceContent(this.request.examples),
|
||||
content = this.request.requestType.toReferenceContent(
|
||||
examples = this.request.examples,
|
||||
mediaTypes = this.request.mediaTypes,
|
||||
enrichment = this.request.typeEnrichment
|
||||
),
|
||||
required = true
|
||||
)
|
||||
|
||||
@ -93,7 +136,11 @@ object Helpers {
|
||||
responses = mapOf(
|
||||
this.response.responseCode.value to Response(
|
||||
description = this.response.description,
|
||||
content = this.response.responseType.toReferenceContent(this.response.examples)
|
||||
content = this.response.responseType.toReferenceContent(
|
||||
examples = this.response.examples,
|
||||
mediaTypes = this.response.mediaTypes,
|
||||
enrichment = this.response.typeEnrichment
|
||||
)
|
||||
)
|
||||
).plus(this.errors.toResponseMap())
|
||||
)
|
||||
@ -101,21 +148,33 @@ object Helpers {
|
||||
private fun List<ResponseInfo>.toResponseMap(): Map<Int, Response> = associate { error ->
|
||||
error.responseCode.value to Response(
|
||||
description = error.description,
|
||||
content = error.responseType.toReferenceContent(error.examples)
|
||||
content = error.responseType.toReferenceContent(
|
||||
examples = error.examples,
|
||||
mediaTypes = error.mediaTypes,
|
||||
enrichment = error.typeEnrichment
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private fun KType.toReferenceContent(examples: Map<String, MediaType.Example>?): Map<String, MediaType>? =
|
||||
private fun KType.toReferenceContent(
|
||||
examples: Map<String, MediaType.Example>?,
|
||||
mediaTypes: Set<String>,
|
||||
enrichment: TypeEnrichment<*>?
|
||||
): Map<String, MediaType>? =
|
||||
when (this.classifier as KClass<*>) {
|
||||
Unit::class -> null
|
||||
else -> mapOf(
|
||||
"application/json" to MediaType(
|
||||
schema = if (this.isMarkedNullable) OneOfDefinition(
|
||||
NullableDefinition(),
|
||||
ReferenceDefinition(this.getReferenceSlug())
|
||||
) else ReferenceDefinition(this.getReferenceSlug()),
|
||||
else -> mediaTypes.associateWith {
|
||||
MediaType(
|
||||
schema = if (this.isMarkedNullable) {
|
||||
OneOfDefinition(
|
||||
NullableDefinition(),
|
||||
ReferenceDefinition(this.getReferenceSlug(enrichment))
|
||||
)
|
||||
} else {
|
||||
ReferenceDefinition(this.getReferenceSlug(enrichment))
|
||||
},
|
||||
examples = examples
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,57 +2,64 @@ package io.bkbn.kompendium.core
|
||||
|
||||
import dev.forst.ktor.apikey.apiKey
|
||||
import io.bkbn.kompendium.core.fixtures.TestHelpers.openApiTestAllSerializers
|
||||
import io.bkbn.kompendium.core.util.TestModules.complexRequest
|
||||
import io.bkbn.kompendium.core.util.TestModules.customAuthConfig
|
||||
import io.bkbn.kompendium.core.util.TestModules.customFieldNameResponse
|
||||
import io.bkbn.kompendium.core.util.TestModules.dateTimeString
|
||||
import io.bkbn.kompendium.core.util.TestModules.defaultAuthConfig
|
||||
import io.bkbn.kompendium.core.util.TestModules.defaultField
|
||||
import io.bkbn.kompendium.core.util.TestModules.defaultParameter
|
||||
import io.bkbn.kompendium.core.util.TestModules.exampleParams
|
||||
import io.bkbn.kompendium.core.util.TestModules.genericException
|
||||
import io.bkbn.kompendium.core.util.TestModules.genericPolymorphicResponse
|
||||
import io.bkbn.kompendium.core.util.TestModules.genericPolymorphicResponseMultipleImpls
|
||||
import io.bkbn.kompendium.core.util.TestModules.gnarlyGenericResponse
|
||||
import io.bkbn.kompendium.core.util.TestModules.headerParameter
|
||||
import io.bkbn.kompendium.core.util.TestModules.ignoredFieldsResponse
|
||||
import io.bkbn.kompendium.core.util.TestModules.multipleAuthStrategies
|
||||
import io.bkbn.kompendium.core.util.TestModules.multipleExceptions
|
||||
import io.bkbn.kompendium.core.util.TestModules.nestedGenericCollection
|
||||
import io.bkbn.kompendium.core.util.TestModules.nestedGenericMultipleParamsCollection
|
||||
import io.bkbn.kompendium.core.util.TestModules.nestedGenericResponse
|
||||
import io.bkbn.kompendium.core.util.TestModules.nestedTypeName
|
||||
import io.bkbn.kompendium.core.util.TestModules.nestedUnderRoot
|
||||
import io.bkbn.kompendium.core.util.TestModules.nonRequiredParam
|
||||
import io.bkbn.kompendium.core.util.TestModules.nonRequiredParams
|
||||
import io.bkbn.kompendium.core.util.TestModules.notarizedDelete
|
||||
import io.bkbn.kompendium.core.util.TestModules.notarizedGet
|
||||
import io.bkbn.kompendium.core.util.TestModules.notarizedHead
|
||||
import io.bkbn.kompendium.core.util.TestModules.notarizedOptions
|
||||
import io.bkbn.kompendium.core.util.TestModules.notarizedPatch
|
||||
import io.bkbn.kompendium.core.util.TestModules.notarizedPost
|
||||
import io.bkbn.kompendium.core.util.TestModules.notarizedPut
|
||||
import io.bkbn.kompendium.core.util.TestModules.nullableEnumField
|
||||
import io.bkbn.kompendium.core.util.TestModules.nullableField
|
||||
import io.bkbn.kompendium.core.util.TestModules.nullableNestedObject
|
||||
import io.bkbn.kompendium.core.util.TestModules.nullableReference
|
||||
import io.bkbn.kompendium.core.util.TestModules.polymorphicCollectionResponse
|
||||
import io.bkbn.kompendium.core.util.TestModules.polymorphicException
|
||||
import io.bkbn.kompendium.core.util.TestModules.polymorphicMapResponse
|
||||
import io.bkbn.kompendium.core.util.TestModules.polymorphicResponse
|
||||
import io.bkbn.kompendium.core.util.TestModules.primitives
|
||||
import io.bkbn.kompendium.core.util.TestModules.reqRespExamples
|
||||
import io.bkbn.kompendium.core.util.TestModules.requiredParams
|
||||
import io.bkbn.kompendium.core.util.TestModules.returnsList
|
||||
import io.bkbn.kompendium.core.util.TestModules.rootRoute
|
||||
import io.bkbn.kompendium.core.util.TestModules.simpleGenericResponse
|
||||
import io.bkbn.kompendium.core.util.TestModules.simplePathParsing
|
||||
import io.bkbn.kompendium.core.util.TestModules.simpleRecursive
|
||||
import io.bkbn.kompendium.core.util.TestModules.singleException
|
||||
import io.bkbn.kompendium.core.util.TestModules.topLevelNullable
|
||||
import io.bkbn.kompendium.core.util.TestModules.trailingSlash
|
||||
import io.bkbn.kompendium.core.util.TestModules.unbackedFieldsResponse
|
||||
import io.bkbn.kompendium.core.util.TestModules.withOperationId
|
||||
import io.bkbn.kompendium.core.util.complexRequest
|
||||
import io.bkbn.kompendium.core.util.customAuthConfig
|
||||
import io.bkbn.kompendium.core.util.customFieldNameResponse
|
||||
import io.bkbn.kompendium.core.util.dateTimeString
|
||||
import io.bkbn.kompendium.core.util.defaultAuthConfig
|
||||
import io.bkbn.kompendium.core.util.defaultField
|
||||
import io.bkbn.kompendium.core.util.defaultParameter
|
||||
import io.bkbn.kompendium.core.util.enrichedComplexGenericType
|
||||
import io.bkbn.kompendium.core.util.enrichedNestedCollection
|
||||
import io.bkbn.kompendium.core.util.enrichedSimpleRequest
|
||||
import io.bkbn.kompendium.core.util.enrichedSimpleResponse
|
||||
import io.bkbn.kompendium.core.util.exampleParams
|
||||
import io.bkbn.kompendium.core.util.genericException
|
||||
import io.bkbn.kompendium.core.util.genericPolymorphicResponse
|
||||
import io.bkbn.kompendium.core.util.genericPolymorphicResponseMultipleImpls
|
||||
import io.bkbn.kompendium.core.util.gnarlyGenericResponse
|
||||
import io.bkbn.kompendium.core.util.headerParameter
|
||||
import io.bkbn.kompendium.core.util.ignoredFieldsResponse
|
||||
import io.bkbn.kompendium.core.util.multipleAuthStrategies
|
||||
import io.bkbn.kompendium.core.util.multipleExceptions
|
||||
import io.bkbn.kompendium.core.util.nestedGenericCollection
|
||||
import io.bkbn.kompendium.core.util.nestedGenericMultipleParamsCollection
|
||||
import io.bkbn.kompendium.core.util.nestedGenericResponse
|
||||
import io.bkbn.kompendium.core.util.nestedTypeName
|
||||
import io.bkbn.kompendium.core.util.nestedUnderRoot
|
||||
import io.bkbn.kompendium.core.util.nonRequiredParam
|
||||
import io.bkbn.kompendium.core.util.nonRequiredParams
|
||||
import io.bkbn.kompendium.core.util.notarizedDelete
|
||||
import io.bkbn.kompendium.core.util.notarizedGet
|
||||
import io.bkbn.kompendium.core.util.notarizedHead
|
||||
import io.bkbn.kompendium.core.util.notarizedOptions
|
||||
import io.bkbn.kompendium.core.util.notarizedPatch
|
||||
import io.bkbn.kompendium.core.util.notarizedPost
|
||||
import io.bkbn.kompendium.core.util.notarizedPut
|
||||
import io.bkbn.kompendium.core.util.nullableEnumField
|
||||
import io.bkbn.kompendium.core.util.nullableField
|
||||
import io.bkbn.kompendium.core.util.nullableNestedObject
|
||||
import io.bkbn.kompendium.core.util.nullableReference
|
||||
import io.bkbn.kompendium.core.util.overrideMediaTypes
|
||||
import io.bkbn.kompendium.core.util.polymorphicCollectionResponse
|
||||
import io.bkbn.kompendium.core.util.polymorphicException
|
||||
import io.bkbn.kompendium.core.util.polymorphicMapResponse
|
||||
import io.bkbn.kompendium.core.util.polymorphicResponse
|
||||
import io.bkbn.kompendium.core.util.primitives
|
||||
import io.bkbn.kompendium.core.util.reqRespExamples
|
||||
import io.bkbn.kompendium.core.util.requiredParams
|
||||
import io.bkbn.kompendium.core.util.returnsList
|
||||
import io.bkbn.kompendium.core.util.rootRoute
|
||||
import io.bkbn.kompendium.core.util.samePathDifferentMethodsAndAuth
|
||||
import io.bkbn.kompendium.core.util.samePathSameMethod
|
||||
import io.bkbn.kompendium.core.util.simpleGenericResponse
|
||||
import io.bkbn.kompendium.core.util.simplePathParsing
|
||||
import io.bkbn.kompendium.core.util.simpleRecursive
|
||||
import io.bkbn.kompendium.core.util.singleException
|
||||
import io.bkbn.kompendium.core.util.topLevelNullable
|
||||
import io.bkbn.kompendium.core.util.trailingSlash
|
||||
import io.bkbn.kompendium.core.util.unbackedFieldsResponse
|
||||
import io.bkbn.kompendium.core.util.withOperationId
|
||||
import io.bkbn.kompendium.json.schema.definition.TypeDefinition
|
||||
import io.bkbn.kompendium.json.schema.exception.UnknownSchemaException
|
||||
import io.bkbn.kompendium.oas.component.Components
|
||||
@ -74,8 +81,9 @@ import io.ktor.server.auth.UserIdPrincipal
|
||||
import io.ktor.server.auth.basic
|
||||
import io.ktor.server.auth.jwt.jwt
|
||||
import io.ktor.server.auth.oauth
|
||||
import kotlin.reflect.typeOf
|
||||
import java.net.URI
|
||||
import java.time.Instant
|
||||
import kotlin.reflect.typeOf
|
||||
|
||||
class KompendiumTest : DescribeSpec({
|
||||
describe("Notarized Open API Metadata Tests") {
|
||||
@ -112,6 +120,9 @@ class KompendiumTest : DescribeSpec({
|
||||
it("Can notarize a route with non-required params") {
|
||||
openApiTestAllSerializers("T0011__non_required_params.json") { nonRequiredParams() }
|
||||
}
|
||||
it("Can override media types") {
|
||||
openApiTestAllSerializers("T0052__override_media_types.json") { overrideMediaTypes() }
|
||||
}
|
||||
}
|
||||
describe("Route Parsing") {
|
||||
it("Can parse a simple path and store it under the expected route") {
|
||||
@ -247,12 +258,65 @@ class KompendiumTest : DescribeSpec({
|
||||
it("Can handle top level nullable types") {
|
||||
openApiTestAllSerializers("T0051__top_level_nullable.json") { topLevelNullable() }
|
||||
}
|
||||
it("Can handle multiple registrations for different methods with the same path and different auth") {
|
||||
openApiTestAllSerializers(
|
||||
"T0053__same_path_different_methods_and_auth.json",
|
||||
applicationSetup = {
|
||||
install(Authentication) {
|
||||
basic("basic") {
|
||||
realm = "Ktor Server"
|
||||
validate { UserIdPrincipal("Placeholder") }
|
||||
}
|
||||
}
|
||||
},
|
||||
specOverrides = {
|
||||
this.copy(
|
||||
components = Components(
|
||||
securitySchemes = mutableMapOf(
|
||||
"basic" to BasicAuth()
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
) { samePathDifferentMethodsAndAuth() }
|
||||
}
|
||||
it("Can generate paths without application root-path") {
|
||||
openApiTestAllSerializers(
|
||||
"T0054__app_with_rootpath.json",
|
||||
applicationEnvironmentBuilder = {
|
||||
rootPath = "/example"
|
||||
},
|
||||
specOverrides = {
|
||||
copy(
|
||||
servers = servers.map { it.copy(url = URI("${it.url}/example")) }.toMutableList()
|
||||
)
|
||||
}
|
||||
) { notarizedGet() }
|
||||
}
|
||||
}
|
||||
describe("Error Handling") {
|
||||
it("Throws a clear exception when an unidentified type is encountered") {
|
||||
val exception = shouldThrow<UnknownSchemaException> { openApiTestAllSerializers("") { dateTimeString() } }
|
||||
exception.message should startWith("An unknown type was encountered: class java.time.Instant")
|
||||
}
|
||||
it("Throws an exception when same method for same path has been previously registered") {
|
||||
val exception = shouldThrow<IllegalArgumentException> {
|
||||
openApiTestAllSerializers(
|
||||
snapshotName = "",
|
||||
applicationSetup = {
|
||||
install(Authentication) {
|
||||
basic("basic") {
|
||||
realm = "Ktor Server"
|
||||
validate { UserIdPrincipal("Placeholder") }
|
||||
}
|
||||
}
|
||||
},
|
||||
) {
|
||||
samePathSameMethod()
|
||||
}
|
||||
}
|
||||
exception.message should startWith("A route has already been registered for path: /test/{a} and method: GET")
|
||||
}
|
||||
}
|
||||
describe("Constraints") {
|
||||
// TODO Assess strategies here
|
||||
@ -364,4 +428,18 @@ class KompendiumTest : DescribeSpec({
|
||||
) { multipleAuthStrategies() }
|
||||
}
|
||||
}
|
||||
describe("Enrichment") {
|
||||
it("Can enrich a simple request") {
|
||||
openApiTestAllSerializers("T0055__enriched_simple_request.json") { enrichedSimpleRequest() }
|
||||
}
|
||||
it("Can enrich a simple response") {
|
||||
openApiTestAllSerializers("T0058__enriched_simple_response.json") { enrichedSimpleResponse() }
|
||||
}
|
||||
it("Can enrich a nested collection") {
|
||||
openApiTestAllSerializers("T0056__enriched_nested_collection.json") { enrichedNestedCollection() }
|
||||
}
|
||||
it("Can enrich a complex generic type") {
|
||||
openApiTestAllSerializers("T0057__enriched_complex_generic_type.json") { enrichedComplexGenericType() }
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -0,0 +1,51 @@
|
||||
package io.bkbn.kompendium.core.util
|
||||
|
||||
import io.bkbn.kompendium.core.fixtures.TestResponse
|
||||
import io.bkbn.kompendium.core.metadata.GetInfo
|
||||
import io.bkbn.kompendium.core.plugin.NotarizedRoute
|
||||
import io.bkbn.kompendium.core.util.TestModules.defaultPathDescription
|
||||
import io.bkbn.kompendium.core.util.TestModules.defaultPathSummary
|
||||
import io.bkbn.kompendium.core.util.TestModules.defaultResponseDescription
|
||||
import io.bkbn.kompendium.core.util.TestModules.rootPath
|
||||
import io.ktor.http.HttpStatusCode
|
||||
import io.ktor.server.application.install
|
||||
import io.ktor.server.auth.authenticate
|
||||
import io.ktor.server.routing.Routing
|
||||
import io.ktor.server.routing.route
|
||||
|
||||
fun Routing.defaultAuthConfig() {
|
||||
authenticate("basic") {
|
||||
route(rootPath) {
|
||||
basicGetGenerator<TestResponse>()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.customAuthConfig() {
|
||||
authenticate("auth-oauth-google") {
|
||||
route(rootPath) {
|
||||
install(NotarizedRoute()) {
|
||||
get = GetInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
response {
|
||||
description(defaultResponseDescription)
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<TestResponse>()
|
||||
}
|
||||
security = mapOf(
|
||||
"auth-oauth-google" to listOf("read:pets")
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.multipleAuthStrategies() {
|
||||
authenticate("jwt", "api-key") {
|
||||
route(rootPath) {
|
||||
basicGetGenerator<TestResponse>()
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package io.bkbn.kompendium.core.util
|
||||
|
||||
import io.bkbn.kompendium.core.fixtures.SerialNameObject
|
||||
import io.bkbn.kompendium.core.fixtures.TransientObject
|
||||
import io.bkbn.kompendium.core.fixtures.UnbackedObject
|
||||
import io.ktor.server.routing.Routing
|
||||
|
||||
fun Routing.ignoredFieldsResponse() = basicGetGenerator<TransientObject>()
|
||||
fun Routing.unbackedFieldsResponse() = basicGetGenerator<UnbackedObject>()
|
||||
fun Routing.customFieldNameResponse() = basicGetGenerator<SerialNameObject>()
|
@ -0,0 +1,16 @@
|
||||
package io.bkbn.kompendium.core.util
|
||||
|
||||
import io.bkbn.kompendium.core.fixtures.TestResponse
|
||||
import io.bkbn.kompendium.json.schema.definition.TypeDefinition
|
||||
import io.bkbn.kompendium.oas.payload.Parameter
|
||||
import io.ktor.server.routing.Routing
|
||||
|
||||
fun Routing.defaultParameter() = basicGetGenerator<TestResponse>(
|
||||
params = listOf(
|
||||
Parameter(
|
||||
name = "id",
|
||||
`in` = Parameter.Location.path,
|
||||
schema = TypeDefinition.STRING.withDefault("IDK")
|
||||
)
|
||||
)
|
||||
)
|
137
core/src/test/kotlin/io/bkbn/kompendium/core/util/Enrichment.kt
Normal file
137
core/src/test/kotlin/io/bkbn/kompendium/core/util/Enrichment.kt
Normal file
@ -0,0 +1,137 @@
|
||||
package io.bkbn.kompendium.core.util
|
||||
|
||||
import io.bkbn.kompendium.core.fixtures.ComplexRequest
|
||||
import io.bkbn.kompendium.core.fixtures.MultiNestedGenerics
|
||||
import io.bkbn.kompendium.core.fixtures.NestedComplexItem
|
||||
import io.bkbn.kompendium.core.fixtures.TestCreatedResponse
|
||||
import io.bkbn.kompendium.core.fixtures.TestResponse
|
||||
import io.bkbn.kompendium.core.fixtures.TestSimpleRequest
|
||||
import io.bkbn.kompendium.core.metadata.GetInfo
|
||||
import io.bkbn.kompendium.core.metadata.PostInfo
|
||||
import io.bkbn.kompendium.core.plugin.NotarizedRoute
|
||||
import io.bkbn.kompendium.enrichment.TypeEnrichment
|
||||
import io.ktor.http.HttpStatusCode
|
||||
import io.ktor.server.application.install
|
||||
import io.ktor.server.routing.Routing
|
||||
import io.ktor.server.routing.route
|
||||
|
||||
fun Routing.enrichedSimpleResponse() {
|
||||
route("/enriched") {
|
||||
install(NotarizedRoute()) {
|
||||
get = GetInfo.builder {
|
||||
summary(TestModules.defaultPathSummary)
|
||||
description(TestModules.defaultPathDescription)
|
||||
response {
|
||||
responseType(
|
||||
enrichment = TypeEnrichment("simple") {
|
||||
TestResponse::c {
|
||||
description = "A simple description"
|
||||
}
|
||||
}
|
||||
)
|
||||
description("A good response")
|
||||
responseCode(HttpStatusCode.Created)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.enrichedSimpleRequest() {
|
||||
route("/example") {
|
||||
install(NotarizedRoute()) {
|
||||
parameters = TestModules.defaultParams
|
||||
post = PostInfo.builder {
|
||||
summary(TestModules.defaultPathSummary)
|
||||
description(TestModules.defaultPathDescription)
|
||||
request {
|
||||
requestType(
|
||||
enrichment = TypeEnrichment("simple") {
|
||||
TestSimpleRequest::a {
|
||||
description = "A simple description"
|
||||
}
|
||||
TestSimpleRequest::b {
|
||||
deprecated = true
|
||||
}
|
||||
}
|
||||
)
|
||||
description("A test request")
|
||||
}
|
||||
response {
|
||||
responseCode(HttpStatusCode.Created)
|
||||
responseType<TestCreatedResponse>()
|
||||
description(TestModules.defaultResponseDescription)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.enrichedNestedCollection() {
|
||||
route("/example") {
|
||||
install(NotarizedRoute()) {
|
||||
parameters = TestModules.defaultParams
|
||||
post = PostInfo.builder {
|
||||
summary(TestModules.defaultPathSummary)
|
||||
description(TestModules.defaultPathDescription)
|
||||
request {
|
||||
requestType(
|
||||
enrichment = TypeEnrichment("simple") {
|
||||
ComplexRequest::tables {
|
||||
description = "A nested item"
|
||||
typeEnrichment = TypeEnrichment("nested") {
|
||||
NestedComplexItem::name {
|
||||
description = "A nested description"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
description("A test request")
|
||||
}
|
||||
response {
|
||||
responseCode(HttpStatusCode.Created)
|
||||
responseType<TestCreatedResponse>()
|
||||
description(TestModules.defaultResponseDescription)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.enrichedComplexGenericType() {
|
||||
route("/example") {
|
||||
install(NotarizedRoute()) {
|
||||
parameters = TestModules.defaultParams
|
||||
post = PostInfo.builder {
|
||||
summary(TestModules.defaultPathSummary)
|
||||
description(TestModules.defaultPathDescription)
|
||||
request {
|
||||
requestType(
|
||||
enrichment = TypeEnrichment("simple") {
|
||||
MultiNestedGenerics<String, ComplexRequest>::content {
|
||||
description = "Getting pretty crazy"
|
||||
typeEnrichment = TypeEnrichment("nested") {
|
||||
ComplexRequest::tables {
|
||||
description = "A nested item"
|
||||
typeEnrichment = TypeEnrichment("nested") {
|
||||
NestedComplexItem::name {
|
||||
description = "A nested description"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
description("A test request")
|
||||
}
|
||||
response {
|
||||
responseCode(HttpStatusCode.Created)
|
||||
responseType<TestCreatedResponse>()
|
||||
description(TestModules.defaultResponseDescription)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package io.bkbn.kompendium.core.util
|
||||
|
||||
import io.bkbn.kompendium.core.fixtures.TestResponse
|
||||
import io.bkbn.kompendium.core.util.TestModules.defaultPath
|
||||
import io.ktor.server.auth.authenticate
|
||||
import io.ktor.server.routing.Routing
|
||||
import io.ktor.server.routing.route
|
||||
|
||||
fun Routing.samePathSameMethod() {
|
||||
route(defaultPath) {
|
||||
basicGetGenerator<TestResponse>()
|
||||
authenticate("basic") {
|
||||
basicGetGenerator<TestResponse>()
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package io.bkbn.kompendium.core.util
|
||||
|
||||
import io.bkbn.kompendium.core.fixtures.TestNested
|
||||
import io.bkbn.kompendium.core.fixtures.TestRequest
|
||||
import io.bkbn.kompendium.core.fixtures.TestResponse
|
||||
import io.bkbn.kompendium.core.metadata.PostInfo
|
||||
import io.bkbn.kompendium.core.plugin.NotarizedRoute
|
||||
import io.bkbn.kompendium.core.util.TestModules.defaultPathDescription
|
||||
import io.bkbn.kompendium.core.util.TestModules.defaultPathSummary
|
||||
import io.bkbn.kompendium.core.util.TestModules.defaultRequestDescription
|
||||
import io.bkbn.kompendium.core.util.TestModules.defaultResponseDescription
|
||||
import io.bkbn.kompendium.core.util.TestModules.rootPath
|
||||
import io.bkbn.kompendium.json.schema.definition.TypeDefinition
|
||||
import io.bkbn.kompendium.oas.payload.Parameter
|
||||
import io.ktor.http.HttpStatusCode
|
||||
import io.ktor.server.application.install
|
||||
import io.ktor.server.routing.Routing
|
||||
import io.ktor.server.routing.route
|
||||
|
||||
fun Routing.reqRespExamples() {
|
||||
route(rootPath) {
|
||||
install(NotarizedRoute()) {
|
||||
post = PostInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
request {
|
||||
description(defaultRequestDescription)
|
||||
requestType<TestRequest>()
|
||||
examples(
|
||||
"Testerina" to TestRequest(TestNested("asdf"), 1.5, emptyList())
|
||||
)
|
||||
}
|
||||
response {
|
||||
description(defaultResponseDescription)
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<TestResponse>()
|
||||
examples(
|
||||
"Testerino" to TestResponse("Heya")
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.exampleParams() = basicGetGenerator<TestResponse>(
|
||||
params = listOf(
|
||||
Parameter(
|
||||
name = "id",
|
||||
`in` = Parameter.Location.path,
|
||||
schema = TypeDefinition.STRING,
|
||||
examples = mapOf(
|
||||
"foo" to Parameter.Example("testing")
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
105
core/src/test/kotlin/io/bkbn/kompendium/core/util/Exceptions.kt
Normal file
105
core/src/test/kotlin/io/bkbn/kompendium/core/util/Exceptions.kt
Normal file
@ -0,0 +1,105 @@
|
||||
package io.bkbn.kompendium.core.util
|
||||
|
||||
import io.bkbn.kompendium.core.fixtures.ExceptionResponse
|
||||
import io.bkbn.kompendium.core.fixtures.Flibbity
|
||||
import io.bkbn.kompendium.core.fixtures.FlibbityGibbit
|
||||
import io.bkbn.kompendium.core.fixtures.TestResponse
|
||||
import io.bkbn.kompendium.core.metadata.GetInfo
|
||||
import io.bkbn.kompendium.core.plugin.NotarizedRoute
|
||||
import io.bkbn.kompendium.core.util.TestModules.defaultPathDescription
|
||||
import io.bkbn.kompendium.core.util.TestModules.defaultPathSummary
|
||||
import io.bkbn.kompendium.core.util.TestModules.defaultResponseDescription
|
||||
import io.bkbn.kompendium.core.util.TestModules.rootPath
|
||||
import io.ktor.http.HttpStatusCode
|
||||
import io.ktor.server.application.install
|
||||
import io.ktor.server.routing.Routing
|
||||
import io.ktor.server.routing.route
|
||||
|
||||
fun Routing.singleException() {
|
||||
route(rootPath) {
|
||||
install(NotarizedRoute()) {
|
||||
get = GetInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
response {
|
||||
description(defaultResponseDescription)
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<TestResponse>()
|
||||
}
|
||||
canRespond {
|
||||
description("Bad Things Happened")
|
||||
responseCode(HttpStatusCode.BadRequest)
|
||||
responseType<ExceptionResponse>()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.multipleExceptions() {
|
||||
route(rootPath) {
|
||||
install(NotarizedRoute()) {
|
||||
get = GetInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
response {
|
||||
description(defaultResponseDescription)
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<TestResponse>()
|
||||
}
|
||||
canRespond {
|
||||
description("Bad Things Happened")
|
||||
responseCode(HttpStatusCode.BadRequest)
|
||||
responseType<ExceptionResponse>()
|
||||
}
|
||||
canRespond {
|
||||
description("Access Denied")
|
||||
responseCode(HttpStatusCode.Forbidden)
|
||||
responseType<ExceptionResponse>()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.polymorphicException() {
|
||||
route(rootPath) {
|
||||
install(NotarizedRoute()) {
|
||||
get = GetInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
response {
|
||||
description(defaultResponseDescription)
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<TestResponse>()
|
||||
}
|
||||
canRespond {
|
||||
description("Bad Things Happened")
|
||||
responseCode(HttpStatusCode.InternalServerError)
|
||||
responseType<FlibbityGibbit>()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.genericException() {
|
||||
route(rootPath) {
|
||||
install(NotarizedRoute()) {
|
||||
get = GetInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
response {
|
||||
description(defaultResponseDescription)
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<TestResponse>()
|
||||
}
|
||||
canRespond {
|
||||
description("Bad Things Happened")
|
||||
responseCode(HttpStatusCode.BadRequest)
|
||||
responseType<Flibbity<String>>()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package io.bkbn.kompendium.core.util
|
||||
|
||||
import io.bkbn.kompendium.core.fixtures.ColumnSchema
|
||||
import io.bkbn.kompendium.core.fixtures.DateTimeString
|
||||
import io.bkbn.kompendium.core.fixtures.ManyThings
|
||||
import io.bkbn.kompendium.core.fixtures.Nested
|
||||
import io.bkbn.kompendium.core.fixtures.NullableEnum
|
||||
import io.bkbn.kompendium.core.fixtures.ProfileUpdateRequest
|
||||
import io.bkbn.kompendium.core.fixtures.TestCreatedResponse
|
||||
import io.bkbn.kompendium.core.fixtures.TestResponse
|
||||
import io.bkbn.kompendium.core.fixtures.TestSimpleRequest
|
||||
import io.bkbn.kompendium.core.metadata.GetInfo
|
||||
import io.bkbn.kompendium.core.metadata.PutInfo
|
||||
import io.bkbn.kompendium.core.plugin.NotarizedRoute
|
||||
import io.bkbn.kompendium.core.util.TestModules.defaultParams
|
||||
import io.bkbn.kompendium.core.util.TestModules.defaultPath
|
||||
import io.bkbn.kompendium.core.util.TestModules.defaultPathDescription
|
||||
import io.bkbn.kompendium.core.util.TestModules.defaultPathSummary
|
||||
import io.bkbn.kompendium.core.util.TestModules.defaultRequestDescription
|
||||
import io.bkbn.kompendium.core.util.TestModules.defaultResponseDescription
|
||||
import io.bkbn.kompendium.json.schema.definition.TypeDefinition
|
||||
import io.bkbn.kompendium.oas.payload.Parameter
|
||||
import io.ktor.http.HttpStatusCode
|
||||
import io.ktor.server.application.install
|
||||
import io.ktor.server.auth.authenticate
|
||||
import io.ktor.server.routing.Routing
|
||||
import io.ktor.server.routing.route
|
||||
|
||||
fun Routing.withOperationId() = basicGetGenerator<TestResponse>(operationId = "getThisDude")
|
||||
fun Routing.nullableNestedObject() = basicGetGenerator<ProfileUpdateRequest>()
|
||||
fun Routing.nullableEnumField() = basicGetGenerator<NullableEnum>()
|
||||
fun Routing.nullableReference() = basicGetGenerator<ManyThings>()
|
||||
fun Routing.dateTimeString() = basicGetGenerator<DateTimeString>()
|
||||
fun Routing.headerParameter() = basicGetGenerator<TestResponse>(
|
||||
params = listOf(
|
||||
Parameter(
|
||||
name = "X-User-Email",
|
||||
`in` = Parameter.Location.header,
|
||||
schema = TypeDefinition.STRING,
|
||||
required = true
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
fun Routing.nestedTypeName() = basicGetGenerator<Nested.Response>()
|
||||
fun Routing.topLevelNullable() = basicGetGenerator<TestResponse?>()
|
||||
fun Routing.simpleRecursive() = basicGetGenerator<ColumnSchema>()
|
||||
fun Routing.samePathDifferentMethodsAndAuth() {
|
||||
route(defaultPath) {
|
||||
install(NotarizedRoute()) {
|
||||
parameters = defaultParams
|
||||
get = GetInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
response {
|
||||
description(defaultResponseDescription)
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<TestResponse>()
|
||||
}
|
||||
}
|
||||
}
|
||||
authenticate("basic") {
|
||||
install(NotarizedRoute()) {
|
||||
put = PutInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
request {
|
||||
description(defaultRequestDescription)
|
||||
requestType<TestSimpleRequest>()
|
||||
}
|
||||
response {
|
||||
description(defaultResponseDescription)
|
||||
responseCode(HttpStatusCode.Created)
|
||||
responseType<TestCreatedResponse>()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,301 @@
|
||||
package io.bkbn.kompendium.core.util
|
||||
|
||||
import io.bkbn.kompendium.core.fixtures.ComplexRequest
|
||||
import io.bkbn.kompendium.core.fixtures.TestCreatedResponse
|
||||
import io.bkbn.kompendium.core.fixtures.TestRequest
|
||||
import io.bkbn.kompendium.core.fixtures.TestResponse
|
||||
import io.bkbn.kompendium.core.fixtures.TestSimpleRequest
|
||||
import io.bkbn.kompendium.core.metadata.DeleteInfo
|
||||
import io.bkbn.kompendium.core.metadata.GetInfo
|
||||
import io.bkbn.kompendium.core.metadata.HeadInfo
|
||||
import io.bkbn.kompendium.core.metadata.OptionsInfo
|
||||
import io.bkbn.kompendium.core.metadata.PatchInfo
|
||||
import io.bkbn.kompendium.core.metadata.PostInfo
|
||||
import io.bkbn.kompendium.core.metadata.PutInfo
|
||||
import io.bkbn.kompendium.core.plugin.NotarizedRoute
|
||||
import io.bkbn.kompendium.core.util.TestModules.defaultParams
|
||||
import io.bkbn.kompendium.core.util.TestModules.defaultPath
|
||||
import io.bkbn.kompendium.core.util.TestModules.defaultPathDescription
|
||||
import io.bkbn.kompendium.core.util.TestModules.defaultPathSummary
|
||||
import io.bkbn.kompendium.core.util.TestModules.defaultResponseDescription
|
||||
import io.bkbn.kompendium.core.util.TestModules.rootPath
|
||||
import io.bkbn.kompendium.json.schema.definition.TypeDefinition
|
||||
import io.bkbn.kompendium.oas.payload.Parameter
|
||||
import io.ktor.http.HttpStatusCode
|
||||
import io.ktor.server.application.call
|
||||
import io.ktor.server.application.install
|
||||
import io.ktor.server.response.respond
|
||||
import io.ktor.server.response.respondText
|
||||
import io.ktor.server.routing.Routing
|
||||
import io.ktor.server.routing.delete
|
||||
import io.ktor.server.routing.get
|
||||
import io.ktor.server.routing.head
|
||||
import io.ktor.server.routing.options
|
||||
import io.ktor.server.routing.patch
|
||||
import io.ktor.server.routing.post
|
||||
import io.ktor.server.routing.put
|
||||
import io.ktor.server.routing.route
|
||||
|
||||
fun Routing.notarizedGet() {
|
||||
route(defaultPath) {
|
||||
install(NotarizedRoute()) {
|
||||
parameters = defaultParams
|
||||
get = GetInfo.builder {
|
||||
response {
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<TestResponse>()
|
||||
description(defaultResponseDescription)
|
||||
}
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
}
|
||||
}
|
||||
get {
|
||||
call.respondText { "hey dude ‼️ congrats on the get request" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.notarizedPost() {
|
||||
route(defaultPath) {
|
||||
install(NotarizedRoute()) {
|
||||
parameters = defaultParams
|
||||
post = PostInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
request {
|
||||
requestType<TestSimpleRequest>()
|
||||
description("A Test request")
|
||||
}
|
||||
response {
|
||||
responseCode(HttpStatusCode.Created)
|
||||
responseType<TestCreatedResponse>()
|
||||
description(defaultResponseDescription)
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
call.respondText { "hey dude ‼️ congrats on the post request" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.notarizedPut() {
|
||||
route(defaultPath) {
|
||||
install(NotarizedRoute()) {
|
||||
parameters = defaultParams
|
||||
put = PutInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
request {
|
||||
requestType<TestSimpleRequest>()
|
||||
description("A Test request")
|
||||
}
|
||||
response {
|
||||
responseCode(HttpStatusCode.Created)
|
||||
responseType<TestCreatedResponse>()
|
||||
description(defaultResponseDescription)
|
||||
}
|
||||
}
|
||||
}
|
||||
put {
|
||||
call.respondText { "hey dude ‼️ congrats on the post request" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.notarizedDelete() {
|
||||
route(defaultPath) {
|
||||
install(NotarizedRoute()) {
|
||||
parameters = defaultParams
|
||||
delete = DeleteInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
response {
|
||||
responseCode(HttpStatusCode.NoContent)
|
||||
responseType<Unit>()
|
||||
description(defaultResponseDescription)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
delete {
|
||||
call.respond(HttpStatusCode.NoContent)
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.notarizedPatch() {
|
||||
route(defaultPath) {
|
||||
install(NotarizedRoute()) {
|
||||
parameters = defaultParams
|
||||
patch = PatchInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
request {
|
||||
description("A Test request")
|
||||
requestType<TestSimpleRequest>()
|
||||
}
|
||||
response {
|
||||
responseCode(HttpStatusCode.Created)
|
||||
responseType<TestCreatedResponse>()
|
||||
description(defaultResponseDescription)
|
||||
}
|
||||
}
|
||||
}
|
||||
patch {
|
||||
call.respond(HttpStatusCode.Created) { TestCreatedResponse(123, "Nice!") }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.notarizedHead() {
|
||||
route(defaultPath) {
|
||||
install(NotarizedRoute()) {
|
||||
parameters = defaultParams
|
||||
head = HeadInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
|
||||
response {
|
||||
description("great!")
|
||||
responseCode(HttpStatusCode.Created)
|
||||
responseType<Unit>()
|
||||
}
|
||||
}
|
||||
}
|
||||
head {
|
||||
call.respond(HttpStatusCode.OK)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.notarizedOptions() {
|
||||
route(defaultPath) {
|
||||
install(NotarizedRoute()) {
|
||||
parameters = defaultParams
|
||||
options = OptionsInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
response {
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<TestResponse>()
|
||||
description("nice")
|
||||
}
|
||||
}
|
||||
}
|
||||
options {
|
||||
call.respond(HttpStatusCode.NoContent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.complexRequest() {
|
||||
route(rootPath) {
|
||||
install(NotarizedRoute()) {
|
||||
put = PutInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
request {
|
||||
requestType<ComplexRequest>()
|
||||
description("A Complex request")
|
||||
}
|
||||
response {
|
||||
responseCode(HttpStatusCode.Created)
|
||||
responseType<TestCreatedResponse>()
|
||||
description(defaultResponseDescription)
|
||||
}
|
||||
}
|
||||
}
|
||||
patch {
|
||||
call.respond(HttpStatusCode.Created, TestCreatedResponse(123, "nice!"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.primitives() {
|
||||
route(rootPath) {
|
||||
install(NotarizedRoute()) {
|
||||
put = PutInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
request {
|
||||
requestType<Int>()
|
||||
description("A Test Request")
|
||||
}
|
||||
response {
|
||||
responseCode(HttpStatusCode.Created)
|
||||
responseType<Boolean>()
|
||||
description(defaultResponseDescription)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.returnsList() {
|
||||
route(defaultPath) {
|
||||
install(NotarizedRoute()) {
|
||||
parameters = defaultParams
|
||||
get = GetInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
response {
|
||||
description("A Successful List-y Endeavor")
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<List<TestResponse>>()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.nonRequiredParams() {
|
||||
route("/optional") {
|
||||
install(NotarizedRoute()) {
|
||||
parameters = listOf(
|
||||
Parameter(
|
||||
name = "notRequired",
|
||||
`in` = Parameter.Location.query,
|
||||
schema = TypeDefinition.STRING,
|
||||
required = false,
|
||||
),
|
||||
Parameter(
|
||||
name = "required",
|
||||
`in` = Parameter.Location.query,
|
||||
schema = TypeDefinition.STRING
|
||||
)
|
||||
)
|
||||
get = GetInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
response {
|
||||
responseType<Unit>()
|
||||
description("Empty")
|
||||
responseCode(HttpStatusCode.NoContent)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.overrideMediaTypes() {
|
||||
route("/media_types") {
|
||||
install(NotarizedRoute()) {
|
||||
put = PutInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
request {
|
||||
mediaTypes("multipart/form-data", "application/json")
|
||||
requestType<TestRequest>()
|
||||
description("A cool request")
|
||||
}
|
||||
response {
|
||||
mediaTypes("application/xml")
|
||||
responseType<TestResponse>()
|
||||
description("A good response")
|
||||
responseCode(HttpStatusCode.Created)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package io.bkbn.kompendium.core.util
|
||||
|
||||
import io.bkbn.kompendium.core.fixtures.Barzo
|
||||
import io.bkbn.kompendium.core.fixtures.ComplexRequest
|
||||
import io.bkbn.kompendium.core.fixtures.Flibbity
|
||||
import io.bkbn.kompendium.core.fixtures.FlibbityGibbit
|
||||
import io.bkbn.kompendium.core.fixtures.Foosy
|
||||
import io.bkbn.kompendium.core.fixtures.Gibbity
|
||||
import io.bkbn.kompendium.core.fixtures.MultiNestedGenerics
|
||||
import io.bkbn.kompendium.core.fixtures.Page
|
||||
import io.ktor.server.routing.Routing
|
||||
|
||||
fun Routing.polymorphicResponse() = basicGetGenerator<FlibbityGibbit>()
|
||||
fun Routing.polymorphicCollectionResponse() = basicGetGenerator<List<FlibbityGibbit>>()
|
||||
fun Routing.polymorphicMapResponse() = basicGetGenerator<Map<String, FlibbityGibbit>>()
|
||||
fun Routing.simpleGenericResponse() = basicGetGenerator<Gibbity<String>>()
|
||||
fun Routing.gnarlyGenericResponse() = basicGetGenerator<Foosy<Barzo<Int>, String>>()
|
||||
fun Routing.nestedGenericResponse() = basicGetGenerator<Gibbity<Map<String, String>>>()
|
||||
fun Routing.genericPolymorphicResponse() = basicGetGenerator<Flibbity<Double>>()
|
||||
fun Routing.genericPolymorphicResponseMultipleImpls() = basicGetGenerator<Flibbity<FlibbityGibbit>>()
|
||||
fun Routing.nestedGenericCollection() = basicGetGenerator<Page<Int>>()
|
||||
fun Routing.nestedGenericMultipleParamsCollection() = basicGetGenerator<MultiNestedGenerics<String, ComplexRequest>>()
|
@ -0,0 +1,32 @@
|
||||
package io.bkbn.kompendium.core.util
|
||||
|
||||
import io.bkbn.kompendium.core.fixtures.DefaultField
|
||||
import io.bkbn.kompendium.core.fixtures.NullableField
|
||||
import io.bkbn.kompendium.core.fixtures.TestResponse
|
||||
import io.bkbn.kompendium.json.schema.definition.TypeDefinition
|
||||
import io.bkbn.kompendium.oas.payload.Parameter
|
||||
import io.ktor.server.routing.Routing
|
||||
|
||||
fun Routing.requiredParams() = basicGetGenerator<TestResponse>(
|
||||
params = listOf(
|
||||
Parameter(
|
||||
name = "id",
|
||||
`in` = Parameter.Location.path,
|
||||
schema = TypeDefinition.STRING
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
fun Routing.nonRequiredParam() = basicGetGenerator<TestResponse>(
|
||||
params = listOf(
|
||||
Parameter(
|
||||
name = "id",
|
||||
`in` = Parameter.Location.query,
|
||||
schema = TypeDefinition.STRING,
|
||||
required = false
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
fun Routing.defaultField() = basicGetGenerator<DefaultField>()
|
||||
fun Routing.nullableField() = basicGetGenerator<NullableField>()
|
@ -0,0 +1,102 @@
|
||||
package io.bkbn.kompendium.core.util
|
||||
|
||||
import io.bkbn.kompendium.core.fixtures.TestResponse
|
||||
import io.bkbn.kompendium.core.metadata.GetInfo
|
||||
import io.bkbn.kompendium.core.plugin.NotarizedRoute
|
||||
import io.bkbn.kompendium.core.util.TestModules.defaultParams
|
||||
import io.bkbn.kompendium.core.util.TestModules.defaultPathDescription
|
||||
import io.bkbn.kompendium.core.util.TestModules.defaultPathSummary
|
||||
import io.bkbn.kompendium.core.util.TestModules.defaultResponseDescription
|
||||
import io.bkbn.kompendium.core.util.TestModules.rootPath
|
||||
import io.bkbn.kompendium.json.schema.definition.TypeDefinition
|
||||
import io.bkbn.kompendium.oas.payload.Parameter
|
||||
import io.ktor.http.HttpStatusCode
|
||||
import io.ktor.server.application.install
|
||||
import io.ktor.server.routing.Routing
|
||||
import io.ktor.server.routing.route
|
||||
|
||||
fun Routing.simplePathParsing() {
|
||||
route("/this") {
|
||||
route("/is") {
|
||||
route("/a") {
|
||||
route("/complex") {
|
||||
route("path") {
|
||||
route("with/an/{id}") {
|
||||
install(NotarizedRoute()) {
|
||||
get = GetInfo.builder {
|
||||
parameters = listOf(
|
||||
Parameter(
|
||||
name = "id",
|
||||
`in` = Parameter.Location.path,
|
||||
schema = TypeDefinition.STRING
|
||||
)
|
||||
)
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
response {
|
||||
description(defaultResponseDescription)
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<TestResponse>()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.rootRoute() {
|
||||
route(rootPath) {
|
||||
install(NotarizedRoute()) {
|
||||
parameters = listOf(defaultParams.last())
|
||||
get = GetInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
response {
|
||||
description(defaultResponseDescription)
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<TestResponse>()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.nestedUnderRoot() {
|
||||
route("/") {
|
||||
route("/testerino") {
|
||||
install(NotarizedRoute()) {
|
||||
get = GetInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
response {
|
||||
description(defaultResponseDescription)
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<TestResponse>()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.trailingSlash() {
|
||||
route("/test") {
|
||||
route("/") {
|
||||
install(NotarizedRoute()) {
|
||||
get = GetInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
response {
|
||||
description(defaultResponseDescription)
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<TestResponse>()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,66 +1,29 @@
|
||||
package io.bkbn.kompendium.core.util
|
||||
|
||||
import io.bkbn.kompendium.core.fixtures.Barzo
|
||||
import io.bkbn.kompendium.core.fixtures.ColumnSchema
|
||||
import io.bkbn.kompendium.core.fixtures.ComplexRequest
|
||||
import io.bkbn.kompendium.core.fixtures.DateTimeString
|
||||
import io.bkbn.kompendium.core.fixtures.DefaultField
|
||||
import io.bkbn.kompendium.core.fixtures.ExceptionResponse
|
||||
import io.bkbn.kompendium.core.fixtures.Flibbity
|
||||
import io.bkbn.kompendium.core.fixtures.FlibbityGibbit
|
||||
import io.bkbn.kompendium.core.fixtures.Foosy
|
||||
import io.bkbn.kompendium.core.fixtures.Gibbity
|
||||
import io.bkbn.kompendium.core.fixtures.ManyThings
|
||||
import io.bkbn.kompendium.core.fixtures.MultiNestedGenerics
|
||||
import io.bkbn.kompendium.core.fixtures.Nested
|
||||
import io.bkbn.kompendium.core.fixtures.NullableEnum
|
||||
import io.bkbn.kompendium.core.fixtures.NullableField
|
||||
import io.bkbn.kompendium.core.fixtures.Page
|
||||
import io.bkbn.kompendium.core.fixtures.ProfileUpdateRequest
|
||||
import io.bkbn.kompendium.core.fixtures.SerialNameObject
|
||||
import io.bkbn.kompendium.core.fixtures.TestCreatedResponse
|
||||
import io.bkbn.kompendium.core.fixtures.TestNested
|
||||
import io.bkbn.kompendium.core.fixtures.TestRequest
|
||||
import io.bkbn.kompendium.core.fixtures.TestResponse
|
||||
import io.bkbn.kompendium.core.fixtures.TestSimpleRequest
|
||||
import io.bkbn.kompendium.core.fixtures.TransientObject
|
||||
import io.bkbn.kompendium.core.fixtures.UnbackedObject
|
||||
import io.bkbn.kompendium.core.metadata.DeleteInfo
|
||||
import io.bkbn.kompendium.core.metadata.GetInfo
|
||||
import io.bkbn.kompendium.core.metadata.HeadInfo
|
||||
import io.bkbn.kompendium.core.metadata.OptionsInfo
|
||||
import io.bkbn.kompendium.core.metadata.PatchInfo
|
||||
import io.bkbn.kompendium.core.metadata.PostInfo
|
||||
import io.bkbn.kompendium.core.metadata.PutInfo
|
||||
import io.bkbn.kompendium.core.plugin.NotarizedRoute
|
||||
import io.bkbn.kompendium.core.util.TestModules.defaultPathDescription
|
||||
import io.bkbn.kompendium.core.util.TestModules.defaultPathSummary
|
||||
import io.bkbn.kompendium.core.util.TestModules.defaultResponseDescription
|
||||
import io.bkbn.kompendium.core.util.TestModules.rootPath
|
||||
import io.bkbn.kompendium.json.schema.definition.TypeDefinition
|
||||
import io.bkbn.kompendium.oas.payload.Parameter
|
||||
import io.ktor.http.HttpStatusCode
|
||||
import io.ktor.server.application.call
|
||||
import io.ktor.server.application.install
|
||||
import io.ktor.server.auth.authenticate
|
||||
import io.ktor.server.response.respond
|
||||
import io.ktor.server.response.respondText
|
||||
import io.ktor.server.routing.Route
|
||||
import io.ktor.server.routing.Routing
|
||||
import io.ktor.server.routing.delete
|
||||
import io.ktor.server.routing.get
|
||||
import io.ktor.server.routing.head
|
||||
import io.ktor.server.routing.options
|
||||
import io.ktor.server.routing.patch
|
||||
import io.ktor.server.routing.post
|
||||
import io.ktor.server.routing.put
|
||||
import io.ktor.server.routing.route
|
||||
|
||||
object TestModules {
|
||||
private const val defaultPath = "/test/{a}"
|
||||
private const val rootPath = "/"
|
||||
private const val defaultResponseDescription = "A Successful Endeavor"
|
||||
private const val defaultRequestDescription = "You gotta send it"
|
||||
private const val defaultPathSummary = "Great Summary!"
|
||||
private const val defaultPathDescription = "testing more"
|
||||
|
||||
private val defaultParams = listOf(
|
||||
const val defaultPath = "/test/{a}"
|
||||
const val rootPath = "/"
|
||||
const val defaultResponseDescription = "A Successful Endeavor"
|
||||
const val defaultRequestDescription = "You gotta send it"
|
||||
const val defaultPathSummary = "Great Summary!"
|
||||
const val defaultPathDescription = "testing more"
|
||||
|
||||
val defaultParams = listOf(
|
||||
Parameter(
|
||||
name = "a",
|
||||
`in` = Parameter.Location.path,
|
||||
@ -72,612 +35,31 @@ object TestModules {
|
||||
schema = TypeDefinition.INT
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
fun Routing.notarizedGet() {
|
||||
route(defaultPath) {
|
||||
install(NotarizedRoute()) {
|
||||
parameters = defaultParams
|
||||
get = GetInfo.builder {
|
||||
response {
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<TestResponse>()
|
||||
description(defaultResponseDescription)
|
||||
}
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
}
|
||||
}
|
||||
get {
|
||||
call.respondText { "hey dude ‼️ congrats on the get request" }
|
||||
}
|
||||
}
|
||||
internal inline fun <reified T> Routing.basicGetGenerator(
|
||||
params: List<Parameter> = emptyList(),
|
||||
operationId: String? = null
|
||||
) {
|
||||
route(rootPath) {
|
||||
basicGetGenerator<T>(params, operationId)
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.notarizedPost() {
|
||||
route(defaultPath) {
|
||||
install(NotarizedRoute()) {
|
||||
parameters = defaultParams
|
||||
post = PostInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
request {
|
||||
requestType<TestSimpleRequest>()
|
||||
description("A Test request")
|
||||
}
|
||||
response {
|
||||
responseCode(HttpStatusCode.Created)
|
||||
responseType<TestCreatedResponse>()
|
||||
description(defaultResponseDescription)
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
call.respondText { "hey dude ‼️ congrats on the post request" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.notarizedPut() {
|
||||
route(defaultPath) {
|
||||
install(NotarizedRoute()) {
|
||||
parameters = defaultParams
|
||||
put = PutInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
request {
|
||||
requestType<TestSimpleRequest>()
|
||||
description("A Test request")
|
||||
}
|
||||
response {
|
||||
responseCode(HttpStatusCode.Created)
|
||||
responseType<TestCreatedResponse>()
|
||||
description(defaultResponseDescription)
|
||||
}
|
||||
}
|
||||
}
|
||||
put {
|
||||
call.respondText { "hey dude ‼️ congrats on the post request" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.notarizedDelete() {
|
||||
route(defaultPath) {
|
||||
install(NotarizedRoute()) {
|
||||
parameters = defaultParams
|
||||
delete = DeleteInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
response {
|
||||
responseCode(HttpStatusCode.NoContent)
|
||||
responseType<Unit>()
|
||||
description(defaultResponseDescription)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
delete {
|
||||
call.respond(HttpStatusCode.NoContent)
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.notarizedPatch() {
|
||||
route(defaultPath) {
|
||||
install(NotarizedRoute()) {
|
||||
parameters = defaultParams
|
||||
patch = PatchInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
request {
|
||||
description("A Test request")
|
||||
requestType<TestSimpleRequest>()
|
||||
}
|
||||
response {
|
||||
responseCode(HttpStatusCode.Created)
|
||||
responseType<TestCreatedResponse>()
|
||||
description(defaultResponseDescription)
|
||||
}
|
||||
}
|
||||
}
|
||||
patch {
|
||||
call.respond(HttpStatusCode.Created) { TestCreatedResponse(123, "Nice!") }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.notarizedHead() {
|
||||
route(defaultPath) {
|
||||
install(NotarizedRoute()) {
|
||||
parameters = defaultParams
|
||||
head = HeadInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
|
||||
response {
|
||||
description("great!")
|
||||
responseCode(HttpStatusCode.Created)
|
||||
responseType<Unit>()
|
||||
}
|
||||
}
|
||||
}
|
||||
head {
|
||||
call.respond(HttpStatusCode.OK)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.notarizedOptions() {
|
||||
route(defaultPath) {
|
||||
install(NotarizedRoute()) {
|
||||
parameters = defaultParams
|
||||
options = OptionsInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
response {
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<TestResponse>()
|
||||
description("nice")
|
||||
}
|
||||
}
|
||||
}
|
||||
options {
|
||||
call.respond(HttpStatusCode.NoContent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.complexRequest() {
|
||||
route(rootPath) {
|
||||
install(NotarizedRoute()) {
|
||||
put = PutInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
request {
|
||||
requestType<ComplexRequest>()
|
||||
description("A Complex request")
|
||||
}
|
||||
response {
|
||||
responseCode(HttpStatusCode.Created)
|
||||
responseType<TestCreatedResponse>()
|
||||
description(defaultResponseDescription)
|
||||
}
|
||||
}
|
||||
}
|
||||
patch {
|
||||
call.respond(HttpStatusCode.Created, TestCreatedResponse(123, "nice!"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.primitives() {
|
||||
route(rootPath) {
|
||||
install(NotarizedRoute()) {
|
||||
put = PutInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
request {
|
||||
requestType<Int>()
|
||||
description("A Test Request")
|
||||
}
|
||||
response {
|
||||
responseCode(HttpStatusCode.Created)
|
||||
responseType<Boolean>()
|
||||
description(defaultResponseDescription)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.returnsList() {
|
||||
route(defaultPath) {
|
||||
install(NotarizedRoute()) {
|
||||
parameters = defaultParams
|
||||
get = GetInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
response {
|
||||
description("A Successful List-y Endeavor")
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<List<TestResponse>>()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.nonRequiredParams() {
|
||||
route("/optional") {
|
||||
install(NotarizedRoute()) {
|
||||
parameters = listOf(
|
||||
Parameter(
|
||||
name = "notRequired",
|
||||
`in` = Parameter.Location.query,
|
||||
schema = TypeDefinition.STRING,
|
||||
required = false,
|
||||
),
|
||||
Parameter(
|
||||
name = "required",
|
||||
`in` = Parameter.Location.query,
|
||||
schema = TypeDefinition.STRING
|
||||
)
|
||||
)
|
||||
get = GetInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
response {
|
||||
responseType<Unit>()
|
||||
description("Empty")
|
||||
responseCode(HttpStatusCode.NoContent)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.simplePathParsing() {
|
||||
route("/this") {
|
||||
route("/is") {
|
||||
route("/a") {
|
||||
route("/complex") {
|
||||
route("path") {
|
||||
route("with/an/{id}") {
|
||||
install(NotarizedRoute()) {
|
||||
get = GetInfo.builder {
|
||||
parameters = listOf(
|
||||
Parameter(
|
||||
name = "id",
|
||||
`in` = Parameter.Location.path,
|
||||
schema = TypeDefinition.STRING
|
||||
)
|
||||
)
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
response {
|
||||
description(defaultResponseDescription)
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<TestResponse>()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.rootRoute() {
|
||||
route(rootPath) {
|
||||
install(NotarizedRoute()) {
|
||||
parameters = listOf(defaultParams.last())
|
||||
get = GetInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
response {
|
||||
description(defaultResponseDescription)
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<TestResponse>()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.nestedUnderRoot() {
|
||||
route("/") {
|
||||
route("/testerino") {
|
||||
install(NotarizedRoute()) {
|
||||
get = GetInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
response {
|
||||
description(defaultResponseDescription)
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<TestResponse>()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.trailingSlash() {
|
||||
route("/test") {
|
||||
route("/") {
|
||||
install(NotarizedRoute()) {
|
||||
get = GetInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
response {
|
||||
description(defaultResponseDescription)
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<TestResponse>()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.singleException() {
|
||||
route(rootPath) {
|
||||
install(NotarizedRoute()) {
|
||||
get = GetInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
response {
|
||||
description(defaultResponseDescription)
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<TestResponse>()
|
||||
}
|
||||
canRespond {
|
||||
description("Bad Things Happened")
|
||||
responseCode(HttpStatusCode.BadRequest)
|
||||
responseType<ExceptionResponse>()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.multipleExceptions() {
|
||||
route(rootPath) {
|
||||
install(NotarizedRoute()) {
|
||||
get = GetInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
response {
|
||||
description(defaultResponseDescription)
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<TestResponse>()
|
||||
}
|
||||
canRespond {
|
||||
description("Bad Things Happened")
|
||||
responseCode(HttpStatusCode.BadRequest)
|
||||
responseType<ExceptionResponse>()
|
||||
}
|
||||
canRespond {
|
||||
description("Access Denied")
|
||||
responseCode(HttpStatusCode.Forbidden)
|
||||
responseType<ExceptionResponse>()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.polymorphicException() {
|
||||
route(rootPath) {
|
||||
install(NotarizedRoute()) {
|
||||
get = GetInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
response {
|
||||
description(defaultResponseDescription)
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<TestResponse>()
|
||||
}
|
||||
canRespond {
|
||||
description("Bad Things Happened")
|
||||
responseCode(HttpStatusCode.InternalServerError)
|
||||
responseType<FlibbityGibbit>()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.genericException() {
|
||||
route(rootPath) {
|
||||
install(NotarizedRoute()) {
|
||||
get = GetInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
response {
|
||||
description(defaultResponseDescription)
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<TestResponse>()
|
||||
}
|
||||
canRespond {
|
||||
description("Bad Things Happened")
|
||||
responseCode(HttpStatusCode.BadRequest)
|
||||
responseType<Flibbity<String>>()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.reqRespExamples() {
|
||||
route(rootPath) {
|
||||
install(NotarizedRoute()) {
|
||||
post = PostInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
request {
|
||||
description(defaultRequestDescription)
|
||||
requestType<TestRequest>()
|
||||
examples(
|
||||
"Testerina" to TestRequest(TestNested("asdf"), 1.5, emptyList())
|
||||
)
|
||||
}
|
||||
response {
|
||||
description(defaultResponseDescription)
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<TestResponse>()
|
||||
examples(
|
||||
"Testerino" to TestResponse("Heya")
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.exampleParams() = basicGetGenerator<TestResponse>(
|
||||
params = listOf(
|
||||
Parameter(
|
||||
name = "id",
|
||||
`in` = Parameter.Location.path,
|
||||
schema = TypeDefinition.STRING,
|
||||
examples = mapOf(
|
||||
"foo" to Parameter.Example("testing")
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
fun Routing.defaultParameter() = basicGetGenerator<TestResponse>(
|
||||
params = listOf(
|
||||
Parameter(
|
||||
name = "id",
|
||||
`in` = Parameter.Location.path,
|
||||
schema = TypeDefinition.STRING.withDefault("IDK")
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
fun Routing.requiredParams() = basicGetGenerator<TestResponse>(
|
||||
params = listOf(
|
||||
Parameter(
|
||||
name = "id",
|
||||
`in` = Parameter.Location.path,
|
||||
schema = TypeDefinition.STRING
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
fun Routing.nonRequiredParam() = basicGetGenerator<TestResponse>(
|
||||
params = listOf(
|
||||
Parameter(
|
||||
name = "id",
|
||||
`in` = Parameter.Location.query,
|
||||
schema = TypeDefinition.STRING,
|
||||
required = false
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
fun Routing.defaultField() = basicGetGenerator<DefaultField>()
|
||||
|
||||
fun Routing.nullableField() = basicGetGenerator<NullableField>()
|
||||
|
||||
fun Routing.polymorphicResponse() = basicGetGenerator<FlibbityGibbit>()
|
||||
|
||||
fun Routing.ignoredFieldsResponse() = basicGetGenerator<TransientObject>()
|
||||
|
||||
fun Routing.unbackedFieldsResponse() = basicGetGenerator<UnbackedObject>()
|
||||
|
||||
fun Routing.customFieldNameResponse() = basicGetGenerator<SerialNameObject>()
|
||||
|
||||
fun Routing.polymorphicCollectionResponse() = basicGetGenerator<List<FlibbityGibbit>>()
|
||||
|
||||
fun Routing.polymorphicMapResponse() = basicGetGenerator<Map<String, FlibbityGibbit>>()
|
||||
|
||||
fun Routing.simpleGenericResponse() = basicGetGenerator<Gibbity<String>>()
|
||||
|
||||
fun Routing.gnarlyGenericResponse() = basicGetGenerator<Foosy<Barzo<Int>, String>>()
|
||||
|
||||
fun Routing.nestedGenericResponse() = basicGetGenerator<Gibbity<Map<String, String>>>()
|
||||
|
||||
fun Routing.genericPolymorphicResponse() = basicGetGenerator<Flibbity<Double>>()
|
||||
|
||||
fun Routing.genericPolymorphicResponseMultipleImpls() = basicGetGenerator<Flibbity<FlibbityGibbit>>()
|
||||
|
||||
fun Routing.nestedGenericCollection() = basicGetGenerator<Page<Int>>()
|
||||
|
||||
fun Routing.nestedGenericMultipleParamsCollection() = basicGetGenerator<MultiNestedGenerics<String, ComplexRequest>>()
|
||||
|
||||
fun Routing.withOperationId() = basicGetGenerator<TestResponse>(operationId = "getThisDude")
|
||||
|
||||
fun Routing.nullableNestedObject() = basicGetGenerator<ProfileUpdateRequest>()
|
||||
|
||||
fun Routing.nullableEnumField() = basicGetGenerator<NullableEnum>()
|
||||
|
||||
fun Routing.nullableReference() = basicGetGenerator<ManyThings>()
|
||||
|
||||
fun Routing.dateTimeString() = basicGetGenerator<DateTimeString>()
|
||||
|
||||
fun Routing.headerParameter() = basicGetGenerator<TestResponse>(
|
||||
params = listOf(
|
||||
Parameter(
|
||||
name = "X-User-Email",
|
||||
`in` = Parameter.Location.header,
|
||||
schema = TypeDefinition.STRING,
|
||||
required = true
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
fun Routing.nestedTypeName() = basicGetGenerator<Nested.Response>()
|
||||
|
||||
fun Routing.topLevelNullable() = basicGetGenerator<TestResponse?>()
|
||||
|
||||
fun Routing.simpleRecursive() = basicGetGenerator<ColumnSchema>()
|
||||
|
||||
fun Routing.defaultAuthConfig() {
|
||||
authenticate("basic") {
|
||||
route(rootPath) {
|
||||
basicGetGenerator<TestResponse>()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.customAuthConfig() {
|
||||
authenticate("auth-oauth-google") {
|
||||
route(rootPath) {
|
||||
install(NotarizedRoute()) {
|
||||
get = GetInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
response {
|
||||
description(defaultResponseDescription)
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<TestResponse>()
|
||||
}
|
||||
security = mapOf(
|
||||
"auth-oauth-google" to listOf("read:pets")
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.multipleAuthStrategies() {
|
||||
authenticate("jwt", "api-key") {
|
||||
route(rootPath) {
|
||||
basicGetGenerator<TestResponse>()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private inline fun <reified T> Routing.basicGetGenerator(
|
||||
params: List<Parameter> = emptyList(),
|
||||
operationId: String? = null
|
||||
) {
|
||||
route(rootPath) {
|
||||
basicGetGenerator<T>(params, operationId)
|
||||
}
|
||||
}
|
||||
|
||||
private inline fun <reified T> Route.basicGetGenerator(
|
||||
params: List<Parameter> = emptyList(),
|
||||
operationId: String? = null
|
||||
) {
|
||||
install(NotarizedRoute()) {
|
||||
get = GetInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
operationId?.let { operationId(it) }
|
||||
parameters = params
|
||||
response {
|
||||
description(defaultResponseDescription)
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<T>()
|
||||
}
|
||||
internal inline fun <reified T> Route.basicGetGenerator(
|
||||
params: List<Parameter> = emptyList(),
|
||||
operationId: String? = null
|
||||
) {
|
||||
install(NotarizedRoute()) {
|
||||
get = GetInfo.builder {
|
||||
summary(defaultPathSummary)
|
||||
description(defaultPathDescription)
|
||||
operationId?.let { operationId(it) }
|
||||
parameters = params
|
||||
response {
|
||||
description(defaultResponseDescription)
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<T>()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
123
core/src/test/resources/T0052__override_media_types.json
Normal file
123
core/src/test/resources/T0052__override_media_types.json
Normal file
@ -0,0 +1,123 @@
|
||||
{
|
||||
"openapi": "3.1.0",
|
||||
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||
"info": {
|
||||
"title": "Test API",
|
||||
"version": "1.33.7",
|
||||
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||
"termsOfService": "https://example.com",
|
||||
"contact": {
|
||||
"name": "Homer Simpson",
|
||||
"url": "https://gph.is/1NPUDiM",
|
||||
"email": "chunkylover53@aol.com"
|
||||
},
|
||||
"license": {
|
||||
"name": "MIT",
|
||||
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||
}
|
||||
},
|
||||
"servers": [
|
||||
{
|
||||
"url": "https://myawesomeapi.com",
|
||||
"description": "Production instance of my API"
|
||||
},
|
||||
{
|
||||
"url": "https://staging.myawesomeapi.com",
|
||||
"description": "Where the fun stuff happens"
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"/media_types": {
|
||||
"put": {
|
||||
"tags": [],
|
||||
"summary": "Great Summary!",
|
||||
"description": "testing more",
|
||||
"parameters": [],
|
||||
"requestBody": {
|
||||
"description": "A cool request",
|
||||
"content": {
|
||||
"multipart/form-data": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/TestRequest"
|
||||
}
|
||||
},
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/TestRequest"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": true
|
||||
},
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "A good response",
|
||||
"content": {
|
||||
"application/xml": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/TestResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"deprecated": false
|
||||
},
|
||||
"parameters": []
|
||||
}
|
||||
},
|
||||
"webhooks": {},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"TestResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"c": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"c"
|
||||
]
|
||||
},
|
||||
"TestRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"aaa": {
|
||||
"items": {
|
||||
"type": "number",
|
||||
"format": "int64"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"b": {
|
||||
"type": "number",
|
||||
"format": "double"
|
||||
},
|
||||
"fieldName": {
|
||||
"$ref": "#/components/schemas/TestNested"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"aaa",
|
||||
"b",
|
||||
"fieldName"
|
||||
]
|
||||
},
|
||||
"TestNested": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"nesty": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"nesty"
|
||||
]
|
||||
}
|
||||
},
|
||||
"securitySchemes": {}
|
||||
},
|
||||
"security": [],
|
||||
"tags": []
|
||||
}
|
@ -0,0 +1,164 @@
|
||||
{
|
||||
"openapi": "3.1.0",
|
||||
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||
"info": {
|
||||
"title": "Test API",
|
||||
"version": "1.33.7",
|
||||
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||
"termsOfService": "https://example.com",
|
||||
"contact": {
|
||||
"name": "Homer Simpson",
|
||||
"url": "https://gph.is/1NPUDiM",
|
||||
"email": "chunkylover53@aol.com"
|
||||
},
|
||||
"license": {
|
||||
"name": "MIT",
|
||||
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||
}
|
||||
},
|
||||
"servers": [
|
||||
{
|
||||
"url": "https://myawesomeapi.com",
|
||||
"description": "Production instance of my API"
|
||||
},
|
||||
{
|
||||
"url": "https://staging.myawesomeapi.com",
|
||||
"description": "Where the fun stuff happens"
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"/test/{a}": {
|
||||
"get": {
|
||||
"tags": [],
|
||||
"summary": "Great Summary!",
|
||||
"description": "testing more",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A Successful Endeavor",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/TestResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"deprecated": false
|
||||
},
|
||||
"put": {
|
||||
"tags": [],
|
||||
"summary": "Great Summary!",
|
||||
"description": "testing more",
|
||||
"parameters": [],
|
||||
"requestBody": {
|
||||
"description": "You gotta send it",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/TestSimpleRequest"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": true
|
||||
},
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "A Successful Endeavor",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/TestCreatedResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"deprecated": false,
|
||||
"security": [
|
||||
{
|
||||
"basic": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "a",
|
||||
"in": "path",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"required": true,
|
||||
"deprecated": false
|
||||
},
|
||||
{
|
||||
"name": "aa",
|
||||
"in": "query",
|
||||
"schema": {
|
||||
"type": "number",
|
||||
"format": "int32"
|
||||
},
|
||||
"required": true,
|
||||
"deprecated": false
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"webhooks": {},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"TestResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"c": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"c"
|
||||
]
|
||||
},
|
||||
"TestCreatedResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"c": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "number",
|
||||
"format": "int32"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"c",
|
||||
"id"
|
||||
]
|
||||
},
|
||||
"TestSimpleRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"a": {
|
||||
"type": "string"
|
||||
},
|
||||
"b": {
|
||||
"type": "number",
|
||||
"format": "int32"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"a",
|
||||
"b"
|
||||
]
|
||||
}
|
||||
},
|
||||
"securitySchemes": {
|
||||
"basic": {
|
||||
"type": "http",
|
||||
"scheme": "basic"
|
||||
}
|
||||
}
|
||||
},
|
||||
"security": [],
|
||||
"tags": []
|
||||
}
|
92
core/src/test/resources/T0054__app_with_rootpath.json
Normal file
92
core/src/test/resources/T0054__app_with_rootpath.json
Normal file
@ -0,0 +1,92 @@
|
||||
{
|
||||
"openapi": "3.1.0",
|
||||
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||
"info": {
|
||||
"title": "Test API",
|
||||
"version": "1.33.7",
|
||||
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||
"termsOfService": "https://example.com",
|
||||
"contact": {
|
||||
"name": "Homer Simpson",
|
||||
"url": "https://gph.is/1NPUDiM",
|
||||
"email": "chunkylover53@aol.com"
|
||||
},
|
||||
"license": {
|
||||
"name": "MIT",
|
||||
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||
}
|
||||
},
|
||||
"servers": [
|
||||
{
|
||||
"url": "https://myawesomeapi.com/example",
|
||||
"description": "Production instance of my API"
|
||||
},
|
||||
{
|
||||
"url": "https://staging.myawesomeapi.com/example",
|
||||
"description": "Where the fun stuff happens"
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"/test/{a}": {
|
||||
"get": {
|
||||
"tags": [],
|
||||
"summary": "Great Summary!",
|
||||
"description": "testing more",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A Successful Endeavor",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/TestResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"deprecated": false
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "a",
|
||||
"in": "path",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"required": true,
|
||||
"deprecated": false
|
||||
},
|
||||
{
|
||||
"name": "aa",
|
||||
"in": "query",
|
||||
"schema": {
|
||||
"type": "number",
|
||||
"format": "int32"
|
||||
},
|
||||
"required": true,
|
||||
"deprecated": false
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"webhooks": {},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"TestResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"c": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"c"
|
||||
]
|
||||
}
|
||||
},
|
||||
"securitySchemes": {}
|
||||
},
|
||||
"security": [],
|
||||
"tags": []
|
||||
}
|
126
core/src/test/resources/T0055__enriched_simple_request.json
Normal file
126
core/src/test/resources/T0055__enriched_simple_request.json
Normal file
@ -0,0 +1,126 @@
|
||||
{
|
||||
"openapi": "3.1.0",
|
||||
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||
"info": {
|
||||
"title": "Test API",
|
||||
"version": "1.33.7",
|
||||
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||
"termsOfService": "https://example.com",
|
||||
"contact": {
|
||||
"name": "Homer Simpson",
|
||||
"url": "https://gph.is/1NPUDiM",
|
||||
"email": "chunkylover53@aol.com"
|
||||
},
|
||||
"license": {
|
||||
"name": "MIT",
|
||||
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||
}
|
||||
},
|
||||
"servers": [
|
||||
{
|
||||
"url": "https://myawesomeapi.com",
|
||||
"description": "Production instance of my API"
|
||||
},
|
||||
{
|
||||
"url": "https://staging.myawesomeapi.com",
|
||||
"description": "Where the fun stuff happens"
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"/example": {
|
||||
"post": {
|
||||
"tags": [],
|
||||
"summary": "Great Summary!",
|
||||
"description": "testing more",
|
||||
"parameters": [],
|
||||
"requestBody": {
|
||||
"description": "A test request",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/TestSimpleRequest-simple"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": true
|
||||
},
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "A Successful Endeavor",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/TestCreatedResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"deprecated": false
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "a",
|
||||
"in": "path",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"required": true,
|
||||
"deprecated": false
|
||||
},
|
||||
{
|
||||
"name": "aa",
|
||||
"in": "query",
|
||||
"schema": {
|
||||
"type": "number",
|
||||
"format": "int32"
|
||||
},
|
||||
"required": true,
|
||||
"deprecated": false
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"webhooks": {},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"TestCreatedResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"c": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "number",
|
||||
"format": "int32"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"c",
|
||||
"id"
|
||||
]
|
||||
},
|
||||
"TestSimpleRequest-simple": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"a": {
|
||||
"type": "string",
|
||||
"description": "A simple description"
|
||||
},
|
||||
"b": {
|
||||
"type": "number",
|
||||
"format": "int32",
|
||||
"deprecated": true
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"a",
|
||||
"b"
|
||||
]
|
||||
}
|
||||
},
|
||||
"securitySchemes": {}
|
||||
},
|
||||
"security": [],
|
||||
"tags": []
|
||||
}
|
168
core/src/test/resources/T0056__enriched_nested_collection.json
Normal file
168
core/src/test/resources/T0056__enriched_nested_collection.json
Normal file
@ -0,0 +1,168 @@
|
||||
{
|
||||
"openapi": "3.1.0",
|
||||
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||
"info": {
|
||||
"title": "Test API",
|
||||
"version": "1.33.7",
|
||||
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||
"termsOfService": "https://example.com",
|
||||
"contact": {
|
||||
"name": "Homer Simpson",
|
||||
"url": "https://gph.is/1NPUDiM",
|
||||
"email": "chunkylover53@aol.com"
|
||||
},
|
||||
"license": {
|
||||
"name": "MIT",
|
||||
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||
}
|
||||
},
|
||||
"servers": [
|
||||
{
|
||||
"url": "https://myawesomeapi.com",
|
||||
"description": "Production instance of my API"
|
||||
},
|
||||
{
|
||||
"url": "https://staging.myawesomeapi.com",
|
||||
"description": "Where the fun stuff happens"
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"/example": {
|
||||
"post": {
|
||||
"tags": [],
|
||||
"summary": "Great Summary!",
|
||||
"description": "testing more",
|
||||
"parameters": [],
|
||||
"requestBody": {
|
||||
"description": "A test request",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ComplexRequest-simple"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": true
|
||||
},
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "A Successful Endeavor",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/TestCreatedResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"deprecated": false
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "a",
|
||||
"in": "path",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"required": true,
|
||||
"deprecated": false
|
||||
},
|
||||
{
|
||||
"name": "aa",
|
||||
"in": "query",
|
||||
"schema": {
|
||||
"type": "number",
|
||||
"format": "int32"
|
||||
},
|
||||
"required": true,
|
||||
"deprecated": false
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"webhooks": {},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"TestCreatedResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"c": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "number",
|
||||
"format": "int32"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"c",
|
||||
"id"
|
||||
]
|
||||
},
|
||||
"ComplexRequest-simple": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"amazingField": {
|
||||
"type": "string"
|
||||
},
|
||||
"org": {
|
||||
"type": "string"
|
||||
},
|
||||
"tables": {
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/NestedComplexItem-nested"
|
||||
},
|
||||
"description": "A nested item",
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"amazingField",
|
||||
"org",
|
||||
"tables"
|
||||
]
|
||||
},
|
||||
"NestedComplexItem-nested": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"alias": {
|
||||
"additionalProperties": {
|
||||
"$ref": "#/components/schemas/CrazyItem"
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "A nested description"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"alias",
|
||||
"name"
|
||||
]
|
||||
},
|
||||
"CrazyItem": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"enumeration": {
|
||||
"$ref": "#/components/schemas/SimpleEnum"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"enumeration"
|
||||
]
|
||||
},
|
||||
"SimpleEnum": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"ONE",
|
||||
"TWO"
|
||||
]
|
||||
}
|
||||
},
|
||||
"securitySchemes": {}
|
||||
},
|
||||
"security": [],
|
||||
"tags": []
|
||||
}
|
@ -0,0 +1,183 @@
|
||||
{
|
||||
"openapi": "3.1.0",
|
||||
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||
"info": {
|
||||
"title": "Test API",
|
||||
"version": "1.33.7",
|
||||
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||
"termsOfService": "https://example.com",
|
||||
"contact": {
|
||||
"name": "Homer Simpson",
|
||||
"url": "https://gph.is/1NPUDiM",
|
||||
"email": "chunkylover53@aol.com"
|
||||
},
|
||||
"license": {
|
||||
"name": "MIT",
|
||||
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||
}
|
||||
},
|
||||
"servers": [
|
||||
{
|
||||
"url": "https://myawesomeapi.com",
|
||||
"description": "Production instance of my API"
|
||||
},
|
||||
{
|
||||
"url": "https://staging.myawesomeapi.com",
|
||||
"description": "Where the fun stuff happens"
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"/example": {
|
||||
"post": {
|
||||
"tags": [],
|
||||
"summary": "Great Summary!",
|
||||
"description": "testing more",
|
||||
"parameters": [],
|
||||
"requestBody": {
|
||||
"description": "A test request",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/MultiNestedGenerics-String-ComplexRequest-simple"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": true
|
||||
},
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "A Successful Endeavor",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/TestCreatedResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"deprecated": false
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "a",
|
||||
"in": "path",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"required": true,
|
||||
"deprecated": false
|
||||
},
|
||||
{
|
||||
"name": "aa",
|
||||
"in": "query",
|
||||
"schema": {
|
||||
"type": "number",
|
||||
"format": "int32"
|
||||
},
|
||||
"required": true,
|
||||
"deprecated": false
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"webhooks": {},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"TestCreatedResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"c": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "number",
|
||||
"format": "int32"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"c",
|
||||
"id"
|
||||
]
|
||||
},
|
||||
"MultiNestedGenerics-String-ComplexRequest-simple": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"content": {
|
||||
"additionalProperties": {
|
||||
"$ref": "#/components/schemas/ComplexRequest-nested"
|
||||
},
|
||||
"description": "Getting pretty crazy",
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"content"
|
||||
]
|
||||
},
|
||||
"ComplexRequest-nested": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"amazingField": {
|
||||
"type": "string"
|
||||
},
|
||||
"org": {
|
||||
"type": "string"
|
||||
},
|
||||
"tables": {
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/NestedComplexItem-nested"
|
||||
},
|
||||
"description": "A nested item",
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"amazingField",
|
||||
"org",
|
||||
"tables"
|
||||
]
|
||||
},
|
||||
"NestedComplexItem-nested": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"alias": {
|
||||
"additionalProperties": {
|
||||
"$ref": "#/components/schemas/CrazyItem"
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "A nested description"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"alias",
|
||||
"name"
|
||||
]
|
||||
},
|
||||
"CrazyItem": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"enumeration": {
|
||||
"$ref": "#/components/schemas/SimpleEnum"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"enumeration"
|
||||
]
|
||||
},
|
||||
"SimpleEnum": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"ONE",
|
||||
"TWO"
|
||||
]
|
||||
}
|
||||
},
|
||||
"securitySchemes": {}
|
||||
},
|
||||
"security": [],
|
||||
"tags": []
|
||||
}
|
73
core/src/test/resources/T0058__enriched_simple_response.json
Normal file
73
core/src/test/resources/T0058__enriched_simple_response.json
Normal file
@ -0,0 +1,73 @@
|
||||
{
|
||||
"openapi": "3.1.0",
|
||||
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||
"info": {
|
||||
"title": "Test API",
|
||||
"version": "1.33.7",
|
||||
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||
"termsOfService": "https://example.com",
|
||||
"contact": {
|
||||
"name": "Homer Simpson",
|
||||
"url": "https://gph.is/1NPUDiM",
|
||||
"email": "chunkylover53@aol.com"
|
||||
},
|
||||
"license": {
|
||||
"name": "MIT",
|
||||
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||
}
|
||||
},
|
||||
"servers": [
|
||||
{
|
||||
"url": "https://myawesomeapi.com",
|
||||
"description": "Production instance of my API"
|
||||
},
|
||||
{
|
||||
"url": "https://staging.myawesomeapi.com",
|
||||
"description": "Where the fun stuff happens"
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"/enriched": {
|
||||
"get": {
|
||||
"tags": [],
|
||||
"summary": "Great Summary!",
|
||||
"description": "testing more",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "A good response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/TestResponse-simple"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"deprecated": false
|
||||
},
|
||||
"parameters": []
|
||||
}
|
||||
},
|
||||
"webhooks": {},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"TestResponse-simple": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"c": {
|
||||
"type": "string",
|
||||
"description": "A simple description"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"c"
|
||||
]
|
||||
}
|
||||
},
|
||||
"securitySchemes": {}
|
||||
},
|
||||
"security": [],
|
||||
"tags": []
|
||||
}
|
@ -21,13 +21,14 @@ import io.ktor.serialization.gson.gson
|
||||
import io.ktor.serialization.jackson.jackson
|
||||
import io.ktor.serialization.kotlinx.json.json
|
||||
import io.ktor.server.application.Application
|
||||
import io.ktor.server.engine.ApplicationEngineEnvironmentBuilder
|
||||
import io.ktor.server.plugins.contentnegotiation.ContentNegotiation
|
||||
import io.ktor.server.routing.Routing
|
||||
import io.ktor.server.testing.ApplicationTestBuilder
|
||||
import io.ktor.server.testing.testApplication
|
||||
import kotlin.reflect.KType
|
||||
import kotlinx.serialization.json.Json
|
||||
import java.io.File
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlin.reflect.KType
|
||||
|
||||
object TestHelpers {
|
||||
private const val OPEN_API_ENDPOINT = "/openapi.json"
|
||||
@ -43,8 +44,8 @@ object TestHelpers {
|
||||
* exists as expected, and that the content matches the expected blob found in the specified file
|
||||
* @param snapshotName The snapshot file to retrieve from the resources folder
|
||||
*/
|
||||
private suspend fun ApplicationTestBuilder.compareOpenAPISpec(snapshotName: String) {
|
||||
val response = client.get(OPEN_API_ENDPOINT)
|
||||
private suspend fun ApplicationTestBuilder.compareOpenAPISpec(rootPath: String, snapshotName: String) {
|
||||
val response = client.get("$rootPath$OPEN_API_ENDPOINT")
|
||||
response shouldHaveStatus HttpStatusCode.OK
|
||||
response.bodyAsText() shouldNot beBlank()
|
||||
response.bodyAsText() shouldEqualJson getFileSnapshot(snapshotName)
|
||||
@ -61,11 +62,36 @@ object TestHelpers {
|
||||
customTypes: Map<KType, JsonSchema> = emptyMap(),
|
||||
applicationSetup: Application.() -> Unit = { },
|
||||
specOverrides: OpenApiSpec.() -> OpenApiSpec = { this },
|
||||
applicationEnvironmentBuilder: ApplicationEngineEnvironmentBuilder.() -> Unit = {},
|
||||
routeUnderTest: Routing.() -> Unit
|
||||
) {
|
||||
openApiTest(snapshotName, SupportedSerializer.KOTLINX, routeUnderTest, applicationSetup, specOverrides, customTypes)
|
||||
openApiTest(snapshotName, SupportedSerializer.JACKSON, routeUnderTest, applicationSetup, specOverrides, customTypes)
|
||||
openApiTest(snapshotName, SupportedSerializer.GSON, routeUnderTest, applicationSetup, specOverrides, customTypes)
|
||||
openApiTest(
|
||||
snapshotName,
|
||||
SupportedSerializer.KOTLINX,
|
||||
routeUnderTest,
|
||||
applicationSetup,
|
||||
specOverrides,
|
||||
customTypes,
|
||||
applicationEnvironmentBuilder
|
||||
)
|
||||
openApiTest(
|
||||
snapshotName,
|
||||
SupportedSerializer.JACKSON,
|
||||
routeUnderTest,
|
||||
applicationSetup,
|
||||
specOverrides,
|
||||
customTypes,
|
||||
applicationEnvironmentBuilder
|
||||
)
|
||||
openApiTest(
|
||||
snapshotName,
|
||||
SupportedSerializer.GSON,
|
||||
routeUnderTest,
|
||||
applicationSetup,
|
||||
specOverrides,
|
||||
customTypes,
|
||||
applicationEnvironmentBuilder
|
||||
)
|
||||
}
|
||||
|
||||
private fun openApiTest(
|
||||
@ -74,8 +100,10 @@ object TestHelpers {
|
||||
routeUnderTest: Routing.() -> Unit,
|
||||
applicationSetup: Application.() -> Unit,
|
||||
specOverrides: OpenApiSpec.() -> OpenApiSpec,
|
||||
typeOverrides: Map<KType, JsonSchema> = emptyMap()
|
||||
typeOverrides: Map<KType, JsonSchema> = emptyMap(),
|
||||
applicationBuilder: ApplicationEngineEnvironmentBuilder.() -> Unit = {}
|
||||
) = testApplication {
|
||||
environment(applicationBuilder)
|
||||
install(NotarizedApplication()) {
|
||||
customTypes = typeOverrides
|
||||
spec = defaultSpec().specOverrides()
|
||||
@ -105,6 +133,7 @@ object TestHelpers {
|
||||
redoc()
|
||||
routeUnderTest()
|
||||
}
|
||||
compareOpenAPISpec(snapshotName)
|
||||
val root = ApplicationEngineEnvironmentBuilder().apply(applicationBuilder).rootPath
|
||||
compareOpenAPISpec(root, snapshotName)
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
# Summary
|
||||
|
||||
* [Introduction](index.md)
|
||||
* [Helpers](helpers/index.md)
|
||||
* [Protobuf java converter](helpers/protobuf_java_converter.md)
|
||||
* [Plugins](plugins/index.md)
|
||||
* [Notarized Application](plugins/notarized_application.md)
|
||||
* [Notarized Route](plugins/notarized_route.md)
|
||||
|
7
docs/helpers/index.md
Normal file
7
docs/helpers/index.md
Normal file
@ -0,0 +1,7 @@
|
||||
Helper modules help you to interact with Kompendium.
|
||||
|
||||
Some functionality is not possible or difficult to do with Kompendium by default. Modules in this folder help you to get
|
||||
functionality that would otherwise be difficult.
|
||||
|
||||
The first one of which is [Protobuf java converter](protobuf_java_converter.md) which translates java protobuf classes
|
||||
to `customTypes` entries.
|
153
docs/helpers/protobuf_java_converter.md
Normal file
153
docs/helpers/protobuf_java_converter.md
Normal file
@ -0,0 +1,153 @@
|
||||
The `Protobuf java converter` functions allow you to generate documentation from your generated Java classes.
|
||||
Since Kompendium relies a lot on `KProperties` we have yet to find a way to connect this with our Java.
|
||||
For now the documentation is generated for the `customTypes` in `NotarizedApplication`.
|
||||
|
||||
## Usage with Kotlinx
|
||||
|
||||
setup:
|
||||
```kotlin
|
||||
install(ContentNegotiation) {
|
||||
json(Json {
|
||||
encodeDefaults = false
|
||||
// Combine the kompendium serializers with your custom java proto serializers
|
||||
serializersModule =
|
||||
KompendiumSerializersModule.module + SerializersModule { serializersModule = yourCustomProtoSerializers }
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
For one message and all its nested sub messages:
|
||||
```kotlin
|
||||
private fun Application.mainModule() {
|
||||
// ...
|
||||
install(NotarizedApplication()) {
|
||||
spec = baseSpec
|
||||
customTypes = MyJavaProto.getDefaultInstance().createCustomTypesForTypeAndSubTypes().toMap()
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
For multiple messages and their submesages:
|
||||
```kotlin
|
||||
private fun Application.mainModule() {
|
||||
// ...
|
||||
install(NotarizedApplication()) {
|
||||
spec = baseSpec
|
||||
customTypes = MyJavaProto.getDefaultInstance().createCustomTypesForTypeAndSubTypes()
|
||||
.plus(AnotherJavaProto.getDefaultInstance().createCustomTypesForTypeAndSubTypes()).toMap()
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Example User
|
||||
|
||||
The protobuf that is used on our endpoint
|
||||
```proto
|
||||
message User {
|
||||
string id = 1;
|
||||
string email = 2;
|
||||
string mobile_phone = 3;
|
||||
string name = 4;
|
||||
}
|
||||
```
|
||||
|
||||
A custom serializer deserializer:
|
||||
```kotlin
|
||||
@OptIn(ExperimentalSerializationApi::class)
|
||||
object UserSerializer : KSerializer<User> {
|
||||
|
||||
override val descriptor: SerialDescriptor = buildClassSerialDescriptor("User") {
|
||||
element("id", serialDescriptor<String>())
|
||||
element("email", serialDescriptor<String>())
|
||||
element("mobile_phone", serialDescriptor<String>())
|
||||
element("name", serialDescriptor<String>())
|
||||
}
|
||||
|
||||
override fun deserialize(decoder: Decoder): User {
|
||||
return decoder.decodeStructure(descriptor) {
|
||||
var id: String? = null
|
||||
var email: String? = null
|
||||
var mobilePhone: String? = null
|
||||
var name: String? = null
|
||||
|
||||
loop@ while (true) {
|
||||
when (val index = decodeElementIndex(descriptor)) {
|
||||
CompositeDecoder.DECODE_DONE -> break@loop
|
||||
0 -> id = decodeStringElement(descriptor, index)
|
||||
1 -> email = decodeStringElement(descriptor, index)
|
||||
2 -> mobilePhone = decodeStringElement(descriptor, index)
|
||||
3 -> name = decodeStringElement(descriptor, index)
|
||||
else -> throw RuntimeException(
|
||||
"Unexpected index field ${descriptor.getElementName(index)}"
|
||||
)
|
||||
}
|
||||
}
|
||||
// building the protobuf object
|
||||
val user = User.newBuilder().apply {
|
||||
id?.let { v -> this.id = v }
|
||||
email?.let { v -> this.email = v }
|
||||
mobilePhone?.let { v -> this.mobilePhone = v }
|
||||
name?.let { v -> this.name = v }
|
||||
}.build()
|
||||
user
|
||||
}
|
||||
}
|
||||
|
||||
override fun serialize(encoder: Encoder, value: User) {
|
||||
encoder.encodeStructure(descriptor) {
|
||||
encodeStringElement(descriptor, 0, value.id)
|
||||
encodeStringElement(descriptor, 1, value.email)
|
||||
encodeStringElement(descriptor, 2, value.mobilePhone)
|
||||
encodeStringElement(descriptor, 3, value.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
Setting the content type:
|
||||
```kotlin
|
||||
install(ContentNegotiation) {
|
||||
json(Json {
|
||||
encodeDefaults = false
|
||||
// Combine the kompendium serializers with your custom java proto serializers
|
||||
serializersModule =
|
||||
KompendiumSerializersModule.module + SerializersModule {
|
||||
serializersModule = SerializersModule {
|
||||
contextual(UserSerializer)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
```
|
||||
The installation of the noterized application:
|
||||
```kotlin
|
||||
install(NotarizedApplication()) {
|
||||
spec = baseSpec
|
||||
customTypes = User.getDefaultInstance().createCustomTypesForTypeAndSubTypes().toMap()
|
||||
}
|
||||
```
|
||||
Route configuration as you normally would with one exception which is `createType()` to create kotlin type from a javaClass.
|
||||
|
||||
```kotlin
|
||||
private fun Route.userDocumentation() {
|
||||
install(NotarizedRoute()) {
|
||||
post = PostInfo.builder {
|
||||
summary("My User API")
|
||||
description("Create a user")
|
||||
request {
|
||||
requestType(User::class.createType())
|
||||
description("My user creation object")
|
||||
}
|
||||
response {
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType(CreateUserResponse::class.createType())
|
||||
description("Returns simulation object")
|
||||
}
|
||||
canRespond {
|
||||
responseCode(HttpStatusCode.NotFound)
|
||||
responseType<String>()
|
||||
description("Indicates that the user could not be found")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
@ -4,6 +4,12 @@ You can read more about it [here](https://ktor.io/docs/type-safe-routing.html).
|
||||
|
||||
Kompendium supports Ktor-Resources through an ancillary module `kompendium-resources`
|
||||
|
||||
{% hint style="warning" %}
|
||||
The resources module contains _two_ plugins: `KompendiumResources` and `KompendiumResource`. You will find more
|
||||
information on both below, but in a nutshell, the former is an application level plugin intended to define your entire
|
||||
application, while the latter is a route level approach should you wish to split out your route definitions.
|
||||
{% endhint %}
|
||||
|
||||
## Adding the Artifact
|
||||
|
||||
Prior to documenting your resources, you will need to add the artifact to your gradle build file.
|
||||
@ -14,9 +20,11 @@ dependencies {
|
||||
}
|
||||
```
|
||||
|
||||
## Installing Plugin
|
||||
## NotarizedResources
|
||||
|
||||
Once you have installed the dependency, you can install the plugin. The `NotarizedResources` plugin is an _application_ level plugin, and **must** be install after both the `NotarizedApplication` plugin and the Ktor `Resources` plugin.
|
||||
The `NotarizedResources` plugin is an _application_ level plugin, and **must** be installed after both the
|
||||
`NotarizedApplication` plugin and the Ktor `Resources` plugin. It is intended to be used to document your entire
|
||||
application in a single block.
|
||||
|
||||
```kotlin
|
||||
private fun Application.mainModule() {
|
||||
@ -54,7 +62,64 @@ private fun Application.mainModule() {
|
||||
}
|
||||
```
|
||||
|
||||
Here, the `resources` property is a map of `KClass<*>` to `ResourceMetadata` instance describing that resource. This metadata is functionally identical to how a standard `NotarizedRoute` is defined.
|
||||
Here, the `resources` property is a map of `KClass<*>` to `ResourceMetadata` instance describing that resource. This
|
||||
metadata is functionally identical to how a standard `NotarizedRoute` is defined.
|
||||
|
||||
> ⚠️ If you try to map a class that is not annotated with the ktor `@Resource` annotation, you will get a runtime
|
||||
> exception!
|
||||
{% hint style="danger" %}
|
||||
If you try to map a class that is not annotated with the ktor `@Resource` annotation, you will get a runtime exception!
|
||||
{% endhint %}
|
||||
|
||||
## NotarizedResource
|
||||
|
||||
If you prefer a route-based approach similar to `NotarizedRoute`, you can use the `NotarizedResource<MyResourceType>()`
|
||||
plugin instead of `NotarizedResources`. It will combine paths from any parent route with the route defined in the
|
||||
resource, exactly as Ktor itself does:
|
||||
|
||||
```kotlin
|
||||
@Serializable
|
||||
@Resource("/list/{name}/page/{page}")
|
||||
data class Listing(val name: String, val page: Int)
|
||||
|
||||
private fun Application.mainModule() {
|
||||
install(Resources)
|
||||
route("/api") {
|
||||
listingDocumentation()
|
||||
get<Listing> { listing ->
|
||||
call.respondText("Listing ${listing.name}, page ${listing.page}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun Route.listingDocumentation() {
|
||||
install(NotarizedResource<Listing>()) {
|
||||
parameters = listOf(
|
||||
Parameter(
|
||||
name = "name",
|
||||
`in` = Parameter.Location.path,
|
||||
schema = TypeDefinition.STRING
|
||||
),
|
||||
Parameter(
|
||||
name = "page",
|
||||
`in` = Parameter.Location.path,
|
||||
schema = TypeDefinition.INT
|
||||
)
|
||||
)
|
||||
get = GetInfo.builder {
|
||||
summary("Get user by id")
|
||||
description("A very neat endpoint!")
|
||||
response {
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<ExampleResponse>()
|
||||
description("Will return whether or not the user is real 😱")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
In this case, the generated path will be `/api/list/{name}/page/{page}`, combining the route prefix with the path in the
|
||||
resource.
|
||||
|
||||
{% hint style="danger" %}
|
||||
If you try to map a class that is not annotated with the ktor `@Resource` annotation, you will get a runtime exception!
|
||||
{% endhint %}
|
||||
|
@ -165,3 +165,128 @@ get = GetInfo.builder {
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Media Types
|
||||
|
||||
By default, Kompendium will set the only media type to "application/json". If you would like to override the media type
|
||||
for a specific request or response (including errors), you can do so with the `mediaTypes` method
|
||||
|
||||
```kotlin
|
||||
get = GetInfo.builder {
|
||||
summary("Get user by id")
|
||||
description("A very neat endpoint!")
|
||||
response {
|
||||
mediaTypes("application/xml")
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<ExampleResponse>()
|
||||
description("Will return whether or not the user is real 😱")
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Partial Authentication
|
||||
|
||||
One might want to have a public GET endpoint but a protected PUT endpoint. This can be achieved by registering two
|
||||
separate notarized routes. Note that you will get an error if you try to register the same method twice, as each path
|
||||
can only have one registration per method. Example:
|
||||
|
||||
```kotlin
|
||||
route("/user/{id}") {
|
||||
get = GetInfo.builder {
|
||||
// ...
|
||||
}
|
||||
// ...
|
||||
authenticate {
|
||||
put = PutInfo.builder {
|
||||
// ...
|
||||
}
|
||||
// ...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Enrichment
|
||||
|
||||
Kompendium allows users to enrich their data types with additional information. This can be done by defining a
|
||||
`TypeEnrichment` object and passing it to the `enrich` function on the `NotarizedRoute` builder. Enrichments
|
||||
can be added to any request or response.
|
||||
|
||||
```kotlin
|
||||
data class SimpleData(val a: String, val b: Int? = null)
|
||||
|
||||
val myEnrichment = TypeEnrichment<SimpleData>(id = "simple-enrichment") {
|
||||
SimpleData::a {
|
||||
description = "This will update the field description"
|
||||
}
|
||||
SimpleData::b {
|
||||
// Will indicate in the UI that the field will be removed soon
|
||||
deprecated = true
|
||||
}
|
||||
}
|
||||
|
||||
// In your route documentation
|
||||
fun Routing.enrichedSimpleRequest() {
|
||||
route("/example") {
|
||||
install(NotarizedRoute()) {
|
||||
parameters = TestModules.defaultParams
|
||||
post = PostInfo.builder {
|
||||
summary(TestModules.defaultPathSummary)
|
||||
description(TestModules.defaultPathDescription)
|
||||
request {
|
||||
requestType<SimpleData>(enrichment = myEnrichment) // Simply attach the enrichment to the request
|
||||
description("A test request")
|
||||
}
|
||||
response {
|
||||
responseCode(HttpStatusCode.Created)
|
||||
responseType<TestCreatedResponse>()
|
||||
description(TestModules.defaultResponseDescription)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
{% hint style="warning" %}
|
||||
An enrichment must provide an `id` field that is unique to the data class that is being enriched. This is because
|
||||
under the hood, Kompendium appends this id to the data class identifier in order to support multiple different
|
||||
enrichments
|
||||
on the same data class.
|
||||
|
||||
If you provide duplicate ids, all but the first enrichment will be ignored, as Kompendium will view that as a cache hit,
|
||||
and skip analyzing the new enrichment.
|
||||
{% endhint %}
|
||||
|
||||
At the moment, the only available enrichments are the following
|
||||
|
||||
- description -> Provides a reader friendly description of the field in the object
|
||||
- deprecated -> Indicates that the field is deprecated and should not be used
|
||||
|
||||
### Nested Enrichments
|
||||
|
||||
Enrichments are portable and composable, meaning that we can take an enrichment for a child data class
|
||||
and apply it inside a parent data class using the `typeEnrichment` property.
|
||||
|
||||
```kotlin
|
||||
data class ParentData(val a: String, val b: ChildData)
|
||||
data class ChildData(val c: String, val d: Int? = null)
|
||||
|
||||
val childEnrichment = TypeEnrichment<ChildData>(id = "child-enrichment") {
|
||||
ChildData::c {
|
||||
description = "This will update the field description of field c on child data"
|
||||
}
|
||||
ChildData::d {
|
||||
description = "This will update the field description of field d on child data"
|
||||
}
|
||||
}
|
||||
|
||||
val parentEnrichment = TypeEnrichment<ParentData>(id = "parent-enrichment") {
|
||||
ParentData::a {
|
||||
description = "This will update the field description"
|
||||
}
|
||||
ParentData::b {
|
||||
description = "This will update the field description of field b on parent data"
|
||||
typeEnrichment = childEnrichment // Will apply the child enrichment to the internals of field b
|
||||
}
|
||||
}
|
||||
```
|
||||
|
34
enrichment/build.gradle.kts
Normal file
34
enrichment/build.gradle.kts
Normal file
@ -0,0 +1,34 @@
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("io.bkbn.sourdough.library.jvm")
|
||||
id("io.gitlab.arturbosch.detekt")
|
||||
id("com.adarshr.test-logger")
|
||||
id("maven-publish")
|
||||
id("java-library")
|
||||
id("signing")
|
||||
id("org.jetbrains.kotlinx.kover")
|
||||
}
|
||||
|
||||
sourdoughLibrary {
|
||||
libraryName.set("Kompendium Type Enrichment")
|
||||
libraryDescription.set("Utility library for creating portable type enrichments")
|
||||
compilerArgs.set(listOf("-opt-in=kotlin.RequiresOptIn"))
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Versions
|
||||
val detektVersion: String by project
|
||||
|
||||
// Formatting
|
||||
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:$detektVersion")
|
||||
|
||||
testImplementation(testFixtures(projects.kompendiumCore))
|
||||
}
|
||||
|
||||
testing {
|
||||
suites {
|
||||
named("test", JvmTestSuite::class) {
|
||||
useJUnitJupiter()
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
package io.bkbn.kompendium.enrichment
|
||||
|
||||
sealed interface Enrichment
|
@ -0,0 +1,7 @@
|
||||
package io.bkbn.kompendium.enrichment
|
||||
|
||||
class PropertyEnrichment : Enrichment {
|
||||
var deprecated: Boolean? = null
|
||||
var description: String? = null
|
||||
var typeEnrichment: TypeEnrichment<*>? = null
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package io.bkbn.kompendium.enrichment
|
||||
|
||||
import kotlin.reflect.KProperty
|
||||
import kotlin.reflect.KProperty1
|
||||
|
||||
class TypeEnrichment<T>(val id: String) : Enrichment {
|
||||
|
||||
private val enrichments: MutableMap<KProperty1<*, *>, Enrichment> = mutableMapOf()
|
||||
|
||||
fun getEnrichmentForProperty(property: KProperty<*>): Enrichment? = enrichments[property]
|
||||
|
||||
operator fun <R> KProperty1<T, R>.invoke(init: PropertyEnrichment.() -> Unit) {
|
||||
require(!enrichments.containsKey(this)) { "${this.name} has already been registered" }
|
||||
val propertyEnrichment = PropertyEnrichment()
|
||||
init.invoke(propertyEnrichment)
|
||||
enrichments[this] = propertyEnrichment
|
||||
}
|
||||
|
||||
companion object {
|
||||
inline operator fun <reified T> invoke(id: String, init: TypeEnrichment<T>.() -> Unit): TypeEnrichment<T> {
|
||||
val builder = TypeEnrichment<T>(id)
|
||||
return builder.apply(init)
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
# Kompendium
|
||||
project.version=3.6.0
|
||||
project.version=3.10.0
|
||||
# Kotlin
|
||||
kotlin.code.style=official
|
||||
# Gradle
|
||||
@ -8,6 +8,6 @@ org.gradle.vfs.verbose=true
|
||||
org.gradle.jvmargs=-Xmx2000m
|
||||
|
||||
# Dependencies
|
||||
ktorVersion=2.1.3
|
||||
ktorVersion=2.2.1
|
||||
kotestVersion=5.5.4
|
||||
detektVersion=1.21.0
|
||||
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
6
gradlew
vendored
6
gradlew
vendored
@ -205,6 +205,12 @@ set -- \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
|
14
gradlew.bat
vendored
14
gradlew.bat
vendored
@ -14,7 +14,7 @@
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@ -25,7 +25,7 @@
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
@ -20,7 +20,10 @@ dependencies {
|
||||
// Versions
|
||||
val detektVersion: String by project
|
||||
|
||||
implementation("org.jetbrains.kotlin:kotlin-reflect:1.7.20")
|
||||
// Kompendium
|
||||
api(projects.kompendiumEnrichment)
|
||||
|
||||
implementation("org.jetbrains.kotlin:kotlin-reflect:1.8.0")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1")
|
||||
|
||||
// Formatting
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.bkbn.kompendium.json.schema
|
||||
|
||||
import io.bkbn.kompendium.enrichment.TypeEnrichment
|
||||
import io.bkbn.kompendium.json.schema.definition.JsonSchema
|
||||
import io.bkbn.kompendium.json.schema.definition.NullableDefinition
|
||||
import io.bkbn.kompendium.json.schema.definition.OneOfDefinition
|
||||
@ -9,28 +10,26 @@ import io.bkbn.kompendium.json.schema.handler.EnumHandler
|
||||
import io.bkbn.kompendium.json.schema.handler.MapHandler
|
||||
import io.bkbn.kompendium.json.schema.handler.SealedObjectHandler
|
||||
import io.bkbn.kompendium.json.schema.handler.SimpleObjectHandler
|
||||
import io.bkbn.kompendium.json.schema.util.Helpers.getSimpleSlug
|
||||
import io.bkbn.kompendium.json.schema.util.Helpers.getSlug
|
||||
import java.util.UUID
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.reflect.KType
|
||||
import kotlin.reflect.full.isSubclassOf
|
||||
import kotlin.reflect.typeOf
|
||||
import java.util.UUID
|
||||
|
||||
object SchemaGenerator {
|
||||
|
||||
inline fun <reified T : Any?> fromTypeToSchema(
|
||||
cache: MutableMap<String, JsonSchema> = mutableMapOf(),
|
||||
schemaConfigurator: SchemaConfigurator = SchemaConfigurator.Default()
|
||||
) = fromTypeToSchema(typeOf<T>(), cache, schemaConfigurator)
|
||||
|
||||
fun fromTypeToSchema(
|
||||
type: KType,
|
||||
cache: MutableMap<String, JsonSchema>,
|
||||
schemaConfigurator: SchemaConfigurator
|
||||
schemaConfigurator: SchemaConfigurator,
|
||||
enrichment: TypeEnrichment<*>? = null
|
||||
): JsonSchema {
|
||||
cache[type.getSimpleSlug()]?.let {
|
||||
val slug = type.getSlug(enrichment)
|
||||
|
||||
cache[slug]?.let {
|
||||
return it
|
||||
}
|
||||
|
||||
return when (val clazz = type.classifier as KClass<*>) {
|
||||
Unit::class -> error(
|
||||
"""
|
||||
@ -48,14 +47,14 @@ object SchemaGenerator {
|
||||
Boolean::class -> checkForNull(type, TypeDefinition.BOOLEAN)
|
||||
UUID::class -> checkForNull(type, TypeDefinition.UUID)
|
||||
else -> when {
|
||||
clazz.isSubclassOf(Enum::class) -> EnumHandler.handle(type, clazz, cache)
|
||||
clazz.isSubclassOf(Collection::class) -> CollectionHandler.handle(type, cache, schemaConfigurator)
|
||||
clazz.isSubclassOf(Map::class) -> MapHandler.handle(type, cache, schemaConfigurator)
|
||||
clazz.isSubclassOf(Enum::class) -> EnumHandler.handle(type, clazz, cache, enrichment)
|
||||
clazz.isSubclassOf(Collection::class) -> CollectionHandler.handle(type, cache, schemaConfigurator, enrichment)
|
||||
clazz.isSubclassOf(Map::class) -> MapHandler.handle(type, cache, schemaConfigurator, enrichment)
|
||||
else -> {
|
||||
if (clazz.isSealed) {
|
||||
SealedObjectHandler.handle(type, clazz, cache, schemaConfigurator)
|
||||
SealedObjectHandler.handle(type, clazz, cache, schemaConfigurator, enrichment)
|
||||
} else {
|
||||
SimpleObjectHandler.handle(type, clazz, cache, schemaConfigurator)
|
||||
SimpleObjectHandler.handle(type, clazz, cache, schemaConfigurator, enrichment)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -65,11 +64,12 @@ object SchemaGenerator {
|
||||
fun fromTypeOrUnit(
|
||||
type: KType,
|
||||
cache: MutableMap<String, JsonSchema> = mutableMapOf(),
|
||||
schemaConfigurator: SchemaConfigurator
|
||||
schemaConfigurator: SchemaConfigurator,
|
||||
enrichment: TypeEnrichment<*>? = null
|
||||
): JsonSchema? =
|
||||
when (type.classifier as KClass<*>) {
|
||||
Unit::class -> null
|
||||
else -> fromTypeToSchema(type, cache, schemaConfigurator)
|
||||
else -> fromTypeToSchema(type, cache, schemaConfigurator, enrichment)
|
||||
}
|
||||
|
||||
private fun checkForNull(type: KType, schema: JsonSchema): JsonSchema = when (type.isMarkedNullable) {
|
||||
|
@ -3,4 +3,8 @@ package io.bkbn.kompendium.json.schema.definition
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class AnyOfDefinition(val anyOf: Set<JsonSchema>) : JsonSchema
|
||||
data class AnyOfDefinition(
|
||||
val anyOf: Set<JsonSchema>,
|
||||
override val deprecated: Boolean? = null,
|
||||
override val description: String? = null,
|
||||
) : JsonSchema
|
||||
|
@ -4,7 +4,9 @@ import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class ArrayDefinition(
|
||||
val items: JsonSchema
|
||||
val items: JsonSchema,
|
||||
override val deprecated: Boolean? = null,
|
||||
override val description: String? = null,
|
||||
) : JsonSchema {
|
||||
val type: String = "array"
|
||||
}
|
||||
|
@ -5,5 +5,7 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class EnumDefinition(
|
||||
val type: String,
|
||||
val enum: Set<String>
|
||||
val enum: Set<String>,
|
||||
override val deprecated: Boolean? = null,
|
||||
override val description: String? = null,
|
||||
) : JsonSchema
|
||||
|
@ -11,6 +11,9 @@ import kotlinx.serialization.encoding.Encoder
|
||||
@Serializable(with = JsonSchema.Serializer::class)
|
||||
sealed interface JsonSchema {
|
||||
|
||||
val description: String?
|
||||
val deprecated: Boolean?
|
||||
|
||||
object Serializer : KSerializer<JsonSchema> {
|
||||
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("JsonSchema", PrimitiveKind.STRING)
|
||||
override fun deserialize(decoder: Decoder): JsonSchema {
|
||||
|
@ -4,7 +4,9 @@ import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class MapDefinition(
|
||||
val additionalProperties: JsonSchema
|
||||
val additionalProperties: JsonSchema,
|
||||
override val deprecated: Boolean? = null,
|
||||
override val description: String? = null,
|
||||
) : JsonSchema {
|
||||
val type: String = "object"
|
||||
}
|
||||
|
@ -3,4 +3,8 @@ package io.bkbn.kompendium.json.schema.definition
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class NullableDefinition(val type: String = "null") : JsonSchema
|
||||
data class NullableDefinition(
|
||||
val type: String = "null",
|
||||
override val deprecated: Boolean? = null,
|
||||
override val description: String? = null,
|
||||
) : JsonSchema
|
||||
|
@ -3,6 +3,10 @@ package io.bkbn.kompendium.json.schema.definition
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class OneOfDefinition(val oneOf: Set<JsonSchema>) : JsonSchema {
|
||||
data class OneOfDefinition(
|
||||
val oneOf: Set<JsonSchema>,
|
||||
override val deprecated: Boolean? = null,
|
||||
override val description: String? = null,
|
||||
) : JsonSchema {
|
||||
constructor(vararg types: JsonSchema) : this(types.toSet())
|
||||
}
|
||||
|
@ -3,4 +3,8 @@ package io.bkbn.kompendium.json.schema.definition
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class ReferenceDefinition(val `$ref`: String) : JsonSchema
|
||||
data class ReferenceDefinition(
|
||||
val `$ref`: String,
|
||||
override val deprecated: Boolean? = null,
|
||||
override val description: String? = null,
|
||||
) : JsonSchema
|
||||
|
@ -7,10 +7,11 @@ import kotlinx.serialization.Serializable
|
||||
data class TypeDefinition(
|
||||
val type: String,
|
||||
val format: String? = null,
|
||||
val description: String? = null,
|
||||
val properties: Map<String, JsonSchema>? = null,
|
||||
val required: Set<String>? = null,
|
||||
@Contextual val default: Any? = null,
|
||||
override val deprecated: Boolean? = null,
|
||||
override val description: String? = null,
|
||||
) : JsonSchema {
|
||||
|
||||
fun withDefault(default: Any): TypeDefinition = this.copy(default = default)
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.bkbn.kompendium.json.schema.handler
|
||||
|
||||
import io.bkbn.kompendium.enrichment.TypeEnrichment
|
||||
import io.bkbn.kompendium.json.schema.SchemaConfigurator
|
||||
import io.bkbn.kompendium.json.schema.SchemaGenerator
|
||||
import io.bkbn.kompendium.json.schema.definition.ArrayDefinition
|
||||
@ -9,17 +10,22 @@ import io.bkbn.kompendium.json.schema.definition.OneOfDefinition
|
||||
import io.bkbn.kompendium.json.schema.definition.ReferenceDefinition
|
||||
import io.bkbn.kompendium.json.schema.definition.TypeDefinition
|
||||
import io.bkbn.kompendium.json.schema.util.Helpers.getReferenceSlug
|
||||
import io.bkbn.kompendium.json.schema.util.Helpers.getSimpleSlug
|
||||
import io.bkbn.kompendium.json.schema.util.Helpers.getSlug
|
||||
import kotlin.reflect.KType
|
||||
|
||||
object CollectionHandler {
|
||||
fun handle(type: KType, cache: MutableMap<String, JsonSchema>, schemaConfigurator: SchemaConfigurator): JsonSchema {
|
||||
fun handle(
|
||||
type: KType,
|
||||
cache: MutableMap<String, JsonSchema>,
|
||||
schemaConfigurator: SchemaConfigurator,
|
||||
enrichment: TypeEnrichment<*>? = null
|
||||
): JsonSchema {
|
||||
val collectionType = type.arguments.first().type
|
||||
?: error("This indicates a bug in Kompendium, please open a GitHub issue!")
|
||||
val typeSchema = SchemaGenerator.fromTypeToSchema(collectionType, cache, schemaConfigurator).let {
|
||||
val typeSchema = SchemaGenerator.fromTypeToSchema(collectionType, cache, schemaConfigurator, enrichment).let {
|
||||
if (it is TypeDefinition && it.type == "object") {
|
||||
cache[collectionType.getSimpleSlug()] = it
|
||||
ReferenceDefinition(collectionType.getReferenceSlug())
|
||||
cache[collectionType.getSlug(enrichment)] = it
|
||||
ReferenceDefinition(collectionType.getReferenceSlug(enrichment))
|
||||
} else {
|
||||
it
|
||||
}
|
||||
|
@ -1,16 +1,22 @@
|
||||
package io.bkbn.kompendium.json.schema.handler
|
||||
|
||||
import io.bkbn.kompendium.enrichment.TypeEnrichment
|
||||
import io.bkbn.kompendium.json.schema.definition.EnumDefinition
|
||||
import io.bkbn.kompendium.json.schema.definition.JsonSchema
|
||||
import io.bkbn.kompendium.json.schema.definition.ReferenceDefinition
|
||||
import io.bkbn.kompendium.json.schema.util.Helpers.getReferenceSlug
|
||||
import io.bkbn.kompendium.json.schema.util.Helpers.getSimpleSlug
|
||||
import io.bkbn.kompendium.json.schema.util.Helpers.getSlug
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.reflect.KType
|
||||
|
||||
object EnumHandler {
|
||||
fun handle(type: KType, clazz: KClass<*>, cache: MutableMap<String, JsonSchema>): JsonSchema {
|
||||
cache[type.getSimpleSlug()] = ReferenceDefinition(type.getReferenceSlug())
|
||||
fun handle(
|
||||
type: KType,
|
||||
clazz: KClass<*>,
|
||||
cache: MutableMap<String, JsonSchema>,
|
||||
enrichment: TypeEnrichment<*>? = null
|
||||
): JsonSchema {
|
||||
cache[type.getSlug(enrichment)] = ReferenceDefinition(type.getReferenceSlug(enrichment))
|
||||
|
||||
val options = clazz.java.enumConstants.map { it.toString() }.toSet()
|
||||
return EnumDefinition(type = "string", enum = options)
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.bkbn.kompendium.json.schema.handler
|
||||
|
||||
import io.bkbn.kompendium.enrichment.TypeEnrichment
|
||||
import io.bkbn.kompendium.json.schema.SchemaConfigurator
|
||||
import io.bkbn.kompendium.json.schema.SchemaGenerator
|
||||
import io.bkbn.kompendium.json.schema.definition.JsonSchema
|
||||
@ -9,21 +10,26 @@ import io.bkbn.kompendium.json.schema.definition.OneOfDefinition
|
||||
import io.bkbn.kompendium.json.schema.definition.ReferenceDefinition
|
||||
import io.bkbn.kompendium.json.schema.definition.TypeDefinition
|
||||
import io.bkbn.kompendium.json.schema.util.Helpers.getReferenceSlug
|
||||
import io.bkbn.kompendium.json.schema.util.Helpers.getSimpleSlug
|
||||
import io.bkbn.kompendium.json.schema.util.Helpers.getSlug
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.reflect.KType
|
||||
|
||||
object MapHandler {
|
||||
|
||||
fun handle(type: KType, cache: MutableMap<String, JsonSchema>, schemaConfigurator: SchemaConfigurator): JsonSchema {
|
||||
fun handle(
|
||||
type: KType,
|
||||
cache: MutableMap<String, JsonSchema>,
|
||||
schemaConfigurator: SchemaConfigurator,
|
||||
enrichment: TypeEnrichment<*>? = null
|
||||
): JsonSchema {
|
||||
require(type.arguments.first().type?.classifier as KClass<*> == String::class) {
|
||||
"JSON requires that map keys MUST be Strings. You provided ${type.arguments.first().type}"
|
||||
}
|
||||
val valueType = type.arguments[1].type ?: error("this indicates a bug in Kompendium, please open a GitHub issue")
|
||||
val valueSchema = SchemaGenerator.fromTypeToSchema(valueType, cache, schemaConfigurator).let {
|
||||
val valueSchema = SchemaGenerator.fromTypeToSchema(valueType, cache, schemaConfigurator, enrichment).let {
|
||||
if (it is TypeDefinition && it.type == "object") {
|
||||
cache[valueType.getSimpleSlug()] = it
|
||||
ReferenceDefinition(valueType.getReferenceSlug())
|
||||
cache[valueType.getSlug(enrichment)] = it
|
||||
ReferenceDefinition(valueType.getReferenceSlug(enrichment))
|
||||
} else {
|
||||
it
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.bkbn.kompendium.json.schema.handler
|
||||
|
||||
import io.bkbn.kompendium.enrichment.TypeEnrichment
|
||||
import io.bkbn.kompendium.json.schema.SchemaConfigurator
|
||||
import io.bkbn.kompendium.json.schema.SchemaGenerator
|
||||
import io.bkbn.kompendium.json.schema.definition.AnyOfDefinition
|
||||
@ -7,7 +8,7 @@ import io.bkbn.kompendium.json.schema.definition.JsonSchema
|
||||
import io.bkbn.kompendium.json.schema.definition.ReferenceDefinition
|
||||
import io.bkbn.kompendium.json.schema.definition.TypeDefinition
|
||||
import io.bkbn.kompendium.json.schema.util.Helpers.getReferenceSlug
|
||||
import io.bkbn.kompendium.json.schema.util.Helpers.getSimpleSlug
|
||||
import io.bkbn.kompendium.json.schema.util.Helpers.getSlug
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.reflect.KType
|
||||
import kotlin.reflect.full.createType
|
||||
@ -18,15 +19,17 @@ object SealedObjectHandler {
|
||||
type: KType,
|
||||
clazz: KClass<*>,
|
||||
cache: MutableMap<String, JsonSchema>,
|
||||
schemaConfigurator: SchemaConfigurator
|
||||
schemaConfigurator: SchemaConfigurator,
|
||||
enrichment: TypeEnrichment<*>? = null,
|
||||
): JsonSchema {
|
||||
val subclasses = clazz.sealedSubclasses
|
||||
.map { it.createType(type.arguments) }
|
||||
.map { t ->
|
||||
SchemaGenerator.fromTypeToSchema(t, cache, schemaConfigurator).let { js ->
|
||||
SchemaGenerator.fromTypeToSchema(t, cache, schemaConfigurator, enrichment).let { js ->
|
||||
if (js is TypeDefinition && js.type == "object") {
|
||||
cache[t.getSimpleSlug()] = js
|
||||
ReferenceDefinition(t.getReferenceSlug())
|
||||
val slug = t.getSlug(enrichment)
|
||||
cache[slug] = js
|
||||
ReferenceDefinition(t.getReferenceSlug(enrichment))
|
||||
} else {
|
||||
js
|
||||
}
|
||||
|
@ -1,16 +1,21 @@
|
||||
package io.bkbn.kompendium.json.schema.handler
|
||||
|
||||
import io.bkbn.kompendium.enrichment.PropertyEnrichment
|
||||
import io.bkbn.kompendium.enrichment.TypeEnrichment
|
||||
import io.bkbn.kompendium.json.schema.SchemaConfigurator
|
||||
import io.bkbn.kompendium.json.schema.SchemaGenerator
|
||||
import io.bkbn.kompendium.json.schema.definition.AnyOfDefinition
|
||||
import io.bkbn.kompendium.json.schema.definition.ArrayDefinition
|
||||
import io.bkbn.kompendium.json.schema.definition.EnumDefinition
|
||||
import io.bkbn.kompendium.json.schema.definition.JsonSchema
|
||||
import io.bkbn.kompendium.json.schema.definition.MapDefinition
|
||||
import io.bkbn.kompendium.json.schema.definition.NullableDefinition
|
||||
import io.bkbn.kompendium.json.schema.definition.OneOfDefinition
|
||||
import io.bkbn.kompendium.json.schema.definition.ReferenceDefinition
|
||||
import io.bkbn.kompendium.json.schema.definition.TypeDefinition
|
||||
import io.bkbn.kompendium.json.schema.exception.UnknownSchemaException
|
||||
import io.bkbn.kompendium.json.schema.util.Helpers.getReferenceSlug
|
||||
import io.bkbn.kompendium.json.schema.util.Helpers.getSimpleSlug
|
||||
import io.bkbn.kompendium.json.schema.util.Helpers.getSlug
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.reflect.KProperty
|
||||
import kotlin.reflect.KType
|
||||
@ -26,26 +31,34 @@ object SimpleObjectHandler {
|
||||
type: KType,
|
||||
clazz: KClass<*>,
|
||||
cache: MutableMap<String, JsonSchema>,
|
||||
schemaConfigurator: SchemaConfigurator
|
||||
schemaConfigurator: SchemaConfigurator,
|
||||
enrichment: TypeEnrichment<*>?,
|
||||
): JsonSchema {
|
||||
|
||||
cache[type.getSimpleSlug()] = ReferenceDefinition(type.getReferenceSlug())
|
||||
cache[type.getSlug(enrichment)] = ReferenceDefinition(type.getReferenceSlug(enrichment))
|
||||
|
||||
val typeMap = clazz.typeParameters.zip(type.arguments).toMap()
|
||||
val props = schemaConfigurator.serializableMemberProperties(clazz)
|
||||
.filterNot { it.javaField == null }
|
||||
.associate { prop ->
|
||||
val propTypeEnrichment = when (val pe = enrichment?.getEnrichmentForProperty(prop)) {
|
||||
is PropertyEnrichment -> pe
|
||||
else -> null
|
||||
}
|
||||
|
||||
val schema = when (prop.needsToInjectGenerics(typeMap)) {
|
||||
true -> handleNestedGenerics(typeMap, prop, cache, schemaConfigurator)
|
||||
true -> handleNestedGenerics(typeMap, prop, cache, schemaConfigurator, propTypeEnrichment)
|
||||
false -> when (typeMap.containsKey(prop.returnType.classifier)) {
|
||||
true -> handleGenericProperty(prop, typeMap, cache, schemaConfigurator)
|
||||
false -> handleProperty(prop, cache, schemaConfigurator)
|
||||
true -> handleGenericProperty(prop, typeMap, cache, schemaConfigurator, propTypeEnrichment)
|
||||
false -> handleProperty(prop, cache, schemaConfigurator, propTypeEnrichment?.typeEnrichment)
|
||||
}
|
||||
}
|
||||
|
||||
val nullCheckSchema = when (prop.returnType.isMarkedNullable && !schema.isNullable()) {
|
||||
true -> OneOfDefinition(NullableDefinition(), schema)
|
||||
false -> schema
|
||||
val enrichedSchema = propTypeEnrichment?.applyToSchema(schema) ?: schema
|
||||
|
||||
val nullCheckSchema = when (prop.returnType.isMarkedNullable && !enrichedSchema.isNullable()) {
|
||||
true -> OneOfDefinition(NullableDefinition(), enrichedSchema)
|
||||
false -> enrichedSchema
|
||||
}
|
||||
|
||||
schemaConfigurator.serializableName(prop) to nullCheckSchema
|
||||
@ -90,7 +103,8 @@ object SimpleObjectHandler {
|
||||
typeMap: Map<KTypeParameter, KTypeProjection>,
|
||||
prop: KProperty<*>,
|
||||
cache: MutableMap<String, JsonSchema>,
|
||||
schemaConfigurator: SchemaConfigurator
|
||||
schemaConfigurator: SchemaConfigurator,
|
||||
propEnrichment: PropertyEnrichment?
|
||||
): JsonSchema {
|
||||
val propClass = prop.returnType.classifier as KClass<*>
|
||||
val types = prop.returnType.arguments.map {
|
||||
@ -98,28 +112,30 @@ object SimpleObjectHandler {
|
||||
typeMap.filterKeys { k -> k.name == typeSymbol }.values.first()
|
||||
}
|
||||
val constructedType = propClass.createType(types)
|
||||
return SchemaGenerator.fromTypeToSchema(constructedType, cache, schemaConfigurator).let {
|
||||
if (it.isOrContainsObjectOrEnumDef()) {
|
||||
cache[constructedType.getSimpleSlug()] = it
|
||||
ReferenceDefinition(prop.returnType.getReferenceSlug())
|
||||
} else {
|
||||
it
|
||||
return SchemaGenerator.fromTypeToSchema(constructedType, cache, schemaConfigurator, propEnrichment?.typeEnrichment)
|
||||
.let {
|
||||
if (it.isOrContainsObjectOrEnumDef()) {
|
||||
cache[constructedType.getSlug(propEnrichment)] = it
|
||||
ReferenceDefinition(prop.returnType.getReferenceSlug(propEnrichment))
|
||||
} else {
|
||||
it
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleGenericProperty(
|
||||
prop: KProperty<*>,
|
||||
typeMap: Map<KTypeParameter, KTypeProjection>,
|
||||
cache: MutableMap<String, JsonSchema>,
|
||||
schemaConfigurator: SchemaConfigurator
|
||||
schemaConfigurator: SchemaConfigurator,
|
||||
propEnrichment: PropertyEnrichment?
|
||||
): JsonSchema {
|
||||
val type = typeMap[prop.returnType.classifier]?.type
|
||||
?: error("This indicates a bug in Kompendium, please open a GitHub issue")
|
||||
return SchemaGenerator.fromTypeToSchema(type, cache, schemaConfigurator).let {
|
||||
return SchemaGenerator.fromTypeToSchema(type, cache, schemaConfigurator, propEnrichment?.typeEnrichment).let {
|
||||
if (it.isOrContainsObjectOrEnumDef()) {
|
||||
cache[type.getSimpleSlug()] = it
|
||||
ReferenceDefinition(type.getReferenceSlug())
|
||||
cache[type.getSlug(propEnrichment)] = it
|
||||
ReferenceDefinition(type.getReferenceSlug(propEnrichment))
|
||||
} else {
|
||||
it
|
||||
}
|
||||
@ -129,12 +145,13 @@ object SimpleObjectHandler {
|
||||
private fun handleProperty(
|
||||
prop: KProperty<*>,
|
||||
cache: MutableMap<String, JsonSchema>,
|
||||
schemaConfigurator: SchemaConfigurator
|
||||
schemaConfigurator: SchemaConfigurator,
|
||||
propEnrichment: TypeEnrichment<*>?
|
||||
): JsonSchema =
|
||||
SchemaGenerator.fromTypeToSchema(prop.returnType, cache, schemaConfigurator).let {
|
||||
SchemaGenerator.fromTypeToSchema(prop.returnType, cache, schemaConfigurator, propEnrichment).let {
|
||||
if (it.isOrContainsObjectOrEnumDef()) {
|
||||
cache[prop.returnType.getSimpleSlug()] = it
|
||||
ReferenceDefinition(prop.returnType.getReferenceSlug())
|
||||
cache[prop.returnType.getSlug(propEnrichment)] = it
|
||||
ReferenceDefinition(prop.returnType.getReferenceSlug(propEnrichment))
|
||||
} else {
|
||||
it
|
||||
}
|
||||
@ -149,4 +166,15 @@ object SimpleObjectHandler {
|
||||
}
|
||||
|
||||
private fun JsonSchema.isNullable(): Boolean = this is OneOfDefinition && this.oneOf.any { it is NullableDefinition }
|
||||
|
||||
private fun PropertyEnrichment.applyToSchema(schema: JsonSchema): JsonSchema = when (schema) {
|
||||
is AnyOfDefinition -> schema.copy(deprecated = deprecated, description = description)
|
||||
is ArrayDefinition -> schema.copy(deprecated = deprecated, description = description)
|
||||
is EnumDefinition -> schema.copy(deprecated = deprecated, description = description)
|
||||
is MapDefinition -> schema.copy(deprecated = deprecated, description = description)
|
||||
is NullableDefinition -> schema.copy(deprecated = deprecated, description = description)
|
||||
is OneOfDefinition -> schema.copy(deprecated = deprecated, description = description)
|
||||
is ReferenceDefinition -> schema.copy(deprecated = deprecated, description = description)
|
||||
is TypeDefinition -> schema.copy(deprecated = deprecated, description = description)
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
package io.bkbn.kompendium.json.schema.util
|
||||
|
||||
import io.bkbn.kompendium.enrichment.Enrichment
|
||||
import io.bkbn.kompendium.enrichment.PropertyEnrichment
|
||||
import io.bkbn.kompendium.enrichment.TypeEnrichment
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.reflect.KType
|
||||
|
||||
@ -7,12 +10,26 @@ object Helpers {
|
||||
|
||||
private const val COMPONENT_SLUG = "#/components/schemas"
|
||||
|
||||
fun KType.getSlug(enrichment: Enrichment? = null) = when (enrichment) {
|
||||
is TypeEnrichment<*> -> getEnrichedSlug(enrichment)
|
||||
is PropertyEnrichment -> error("Slugs should not be generated for field enrichments")
|
||||
null -> getSimpleSlug()
|
||||
}
|
||||
|
||||
fun KType.getSimpleSlug(): String = when {
|
||||
this.arguments.isNotEmpty() -> genericNameAdapter(this, classifier as KClass<*>)
|
||||
else -> (classifier as KClass<*>).kompendiumSlug() ?: error("Could not determine simple name for $this")
|
||||
}
|
||||
|
||||
fun KType.getReferenceSlug(): String = when {
|
||||
private fun KType.getEnrichedSlug(enrichment: TypeEnrichment<*>) = getSimpleSlug() + "-${enrichment.id}"
|
||||
|
||||
fun KType.getReferenceSlug(enrichment: Enrichment? = null): String = when (enrichment) {
|
||||
is TypeEnrichment<*> -> getSimpleReferenceSlug() + "-${enrichment.id}"
|
||||
is PropertyEnrichment -> error("Reference slugs should never be generated for field enrichments")
|
||||
null -> getSimpleReferenceSlug()
|
||||
}
|
||||
|
||||
private fun KType.getSimpleReferenceSlug() = when {
|
||||
arguments.isNotEmpty() -> "$COMPONENT_SLUG/${genericNameAdapter(this, classifier as KClass<*>)}"
|
||||
else -> "$COMPONENT_SLUG/${(classifier as KClass<*>).kompendiumSlug()}"
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package io.bkbn.kompendium.json.schema
|
||||
|
||||
import io.bkbn.kompendium.core.fixtures.ComplexRequest
|
||||
import io.bkbn.kompendium.core.fixtures.FlibbityGibbit
|
||||
import io.bkbn.kompendium.core.fixtures.NestedComplexItem
|
||||
import io.bkbn.kompendium.core.fixtures.ObjectWithEnum
|
||||
import io.bkbn.kompendium.core.fixtures.SerialNameObject
|
||||
import io.bkbn.kompendium.core.fixtures.SimpleEnum
|
||||
@ -11,12 +12,14 @@ import io.bkbn.kompendium.core.fixtures.TestResponse
|
||||
import io.bkbn.kompendium.core.fixtures.TestSimpleRequest
|
||||
import io.bkbn.kompendium.core.fixtures.TransientObject
|
||||
import io.bkbn.kompendium.core.fixtures.UnbackedObject
|
||||
import io.bkbn.kompendium.enrichment.TypeEnrichment
|
||||
import io.bkbn.kompendium.json.schema.definition.JsonSchema
|
||||
import io.kotest.assertions.json.shouldEqualJson
|
||||
import io.kotest.assertions.throwables.shouldThrow
|
||||
import io.kotest.core.spec.style.DescribeSpec
|
||||
import kotlinx.serialization.json.Json
|
||||
import java.util.UUID
|
||||
import kotlin.reflect.typeOf
|
||||
|
||||
class SchemaGeneratorTest : DescribeSpec({
|
||||
describe("Scalars") {
|
||||
@ -88,7 +91,13 @@ class SchemaGeneratorTest : DescribeSpec({
|
||||
jsonSchemaTest<Map<String, Int>>("T0012__scalar_map.json")
|
||||
}
|
||||
it("Throws an error when map keys are not strings") {
|
||||
shouldThrow<IllegalArgumentException> { SchemaGenerator.fromTypeToSchema<Map<Int, Int>>() }
|
||||
shouldThrow<IllegalArgumentException> {
|
||||
SchemaGenerator.fromTypeToSchema(
|
||||
typeOf<Map<Int, Int>>(),
|
||||
cache = mutableMapOf(),
|
||||
schemaConfigurator = KotlinXSchemaConfigurator()
|
||||
)
|
||||
}
|
||||
}
|
||||
it("Can generate the schema for a map of objects") {
|
||||
jsonSchemaTest<Map<String, TestResponse>>("T0013__object_map.json")
|
||||
@ -97,6 +106,36 @@ class SchemaGeneratorTest : DescribeSpec({
|
||||
jsonSchemaTest<Map<String, Int>?>("T0014__nullable_map.json")
|
||||
}
|
||||
}
|
||||
describe("Enrichment") {
|
||||
it("Can attach an enrichment to a simple type") {
|
||||
jsonSchemaTest<TestSimpleRequest>(
|
||||
snapshotName = "T0022__enriched_simple_object.json",
|
||||
enrichment = TypeEnrichment("simple") {
|
||||
TestSimpleRequest::a {
|
||||
description = "This is a simple description"
|
||||
}
|
||||
TestSimpleRequest::b {
|
||||
deprecated = true
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
it("Can properly assign a reference to a nested enrichment") {
|
||||
jsonSchemaTest<ComplexRequest>(
|
||||
snapshotName = "T0023__enriched_nested_reference.json",
|
||||
enrichment = TypeEnrichment("example") {
|
||||
ComplexRequest::tables {
|
||||
description = "Collection of important items"
|
||||
typeEnrichment = TypeEnrichment("table") {
|
||||
NestedComplexItem::name {
|
||||
description = "The name of the table"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}) {
|
||||
companion object {
|
||||
private val json = Json {
|
||||
@ -107,11 +146,14 @@ class SchemaGeneratorTest : DescribeSpec({
|
||||
|
||||
private fun JsonSchema.serialize() = json.encodeToString(JsonSchema.serializer(), this)
|
||||
|
||||
private inline fun <reified T> jsonSchemaTest(snapshotName: String) {
|
||||
private inline fun <reified T> jsonSchemaTest(snapshotName: String, enrichment: TypeEnrichment<*>? = null) {
|
||||
// act
|
||||
val schema = SchemaGenerator.fromTypeToSchema<T>(schemaConfigurator = KotlinXSchemaConfigurator())
|
||||
|
||||
// todo add cache assertions!!!
|
||||
val schema = SchemaGenerator.fromTypeToSchema(
|
||||
type = typeOf<T>(),
|
||||
cache = mutableMapOf(),
|
||||
schemaConfigurator = KotlinXSchemaConfigurator(),
|
||||
enrichment = enrichment,
|
||||
)
|
||||
|
||||
// assert
|
||||
schema.serialize() shouldEqualJson getFileSnapshot(snapshotName)
|
||||
|
@ -0,0 +1,18 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"a": {
|
||||
"type": "string",
|
||||
"description": "This is a simple description"
|
||||
},
|
||||
"b": {
|
||||
"type": "number",
|
||||
"format": "int32",
|
||||
"deprecated": true
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"a",
|
||||
"b"
|
||||
]
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"amazingField": {
|
||||
"type": "string"
|
||||
},
|
||||
"org": {
|
||||
"type": "string"
|
||||
},
|
||||
"tables": {
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/NestedComplexItem-table"
|
||||
},
|
||||
"description": "Collection of important items",
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"amazingField",
|
||||
"org",
|
||||
"tables"
|
||||
]
|
||||
}
|
@ -51,17 +51,17 @@ object NotarizedLocations {
|
||||
val spec = application.attributes[KompendiumAttributes.openApiSpec]
|
||||
val serializableReader = application.attributes[KompendiumAttributes.schemaConfigurator]
|
||||
pluginConfig.locations.forEach { (k, v) ->
|
||||
val path = Path()
|
||||
path.parameters = v.parameters
|
||||
v.get?.addToSpec(path, spec, v, serializableReader)
|
||||
v.delete?.addToSpec(path, spec, v, serializableReader)
|
||||
v.head?.addToSpec(path, spec, v, serializableReader)
|
||||
v.options?.addToSpec(path, spec, v, serializableReader)
|
||||
v.post?.addToSpec(path, spec, v, serializableReader)
|
||||
v.put?.addToSpec(path, spec, v, serializableReader)
|
||||
v.patch?.addToSpec(path, spec, v, serializableReader)
|
||||
|
||||
val location = k.getLocationFromClass()
|
||||
val path = spec.paths[location] ?: Path()
|
||||
path.parameters = path.parameters?.plus(v.parameters) ?: v.parameters
|
||||
v.get?.addToSpec(path, spec, v, serializableReader, location)
|
||||
v.delete?.addToSpec(path, spec, v, serializableReader, location)
|
||||
v.head?.addToSpec(path, spec, v, serializableReader, location)
|
||||
v.options?.addToSpec(path, spec, v, serializableReader, location)
|
||||
v.post?.addToSpec(path, spec, v, serializableReader, location)
|
||||
v.put?.addToSpec(path, spec, v, serializableReader, location)
|
||||
v.patch?.addToSpec(path, spec, v, serializableReader, location)
|
||||
|
||||
spec.paths[location] = path
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ dependencies {
|
||||
val detektVersion: String by project
|
||||
|
||||
api(projects.kompendiumJsonSchema)
|
||||
api(projects.kompendiumEnrichment)
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1")
|
||||
|
||||
// Formatting
|
||||
|
@ -15,6 +15,7 @@ dependencies {
|
||||
implementation(projects.kompendiumCore)
|
||||
implementation(projects.kompendiumLocations)
|
||||
implementation(projects.kompendiumResources)
|
||||
implementation(projects.kompendiumProtobufJavaConverter)
|
||||
|
||||
// Ktor
|
||||
val ktorVersion: String by project
|
||||
@ -36,12 +37,12 @@ dependencies {
|
||||
implementation("org.apache.logging.log4j:log4j-api-kotlin:1.2.0")
|
||||
implementation("org.apache.logging.log4j:log4j-api:2.19.0")
|
||||
implementation("org.apache.logging.log4j:log4j-core:2.19.0")
|
||||
implementation("org.slf4j:slf4j-api:2.0.3")
|
||||
implementation("org.slf4j:slf4j-simple:2.0.3")
|
||||
implementation("org.slf4j:slf4j-api:2.0.6")
|
||||
implementation("org.slf4j:slf4j-simple:2.0.6")
|
||||
|
||||
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0")
|
||||
|
||||
implementation("joda-time:joda-time:2.12.1")
|
||||
implementation("joda-time:joda-time:2.12.2")
|
||||
}
|
||||
|
@ -50,7 +50,6 @@ private fun Application.mainModule() {
|
||||
}
|
||||
routing {
|
||||
redoc(pageTitle = "Simple API Docs")
|
||||
|
||||
route("/{id}") {
|
||||
idDocumentation()
|
||||
get {
|
||||
|
@ -0,0 +1,154 @@
|
||||
package io.bkbn.kompendium.playground
|
||||
|
||||
import io.bkbn.kompendium.core.metadata.GetInfo
|
||||
import io.bkbn.kompendium.core.metadata.PostInfo
|
||||
import io.bkbn.kompendium.core.plugin.NotarizedApplication
|
||||
import io.bkbn.kompendium.core.plugin.NotarizedRoute
|
||||
import io.bkbn.kompendium.core.routes.redoc
|
||||
import io.bkbn.kompendium.enrichment.TypeEnrichment
|
||||
import io.bkbn.kompendium.json.schema.KotlinXSchemaConfigurator
|
||||
import io.bkbn.kompendium.json.schema.definition.TypeDefinition
|
||||
import io.bkbn.kompendium.oas.payload.Parameter
|
||||
import io.bkbn.kompendium.oas.serialization.KompendiumSerializersModule
|
||||
import io.bkbn.kompendium.playground.util.ExampleRequest
|
||||
import io.bkbn.kompendium.playground.util.ExampleResponse
|
||||
import io.bkbn.kompendium.playground.util.ExceptionResponse
|
||||
import io.bkbn.kompendium.playground.util.InnerRequest
|
||||
import io.bkbn.kompendium.playground.util.Util.baseSpec
|
||||
import io.ktor.http.HttpStatusCode
|
||||
import io.ktor.serialization.kotlinx.json.json
|
||||
import io.ktor.server.application.Application
|
||||
import io.ktor.server.application.call
|
||||
import io.ktor.server.application.install
|
||||
import io.ktor.server.cio.CIO
|
||||
import io.ktor.server.engine.embeddedServer
|
||||
import io.ktor.server.plugins.contentnegotiation.ContentNegotiation
|
||||
import io.ktor.server.response.respond
|
||||
import io.ktor.server.routing.*
|
||||
import kotlinx.serialization.json.Json
|
||||
|
||||
fun main() {
|
||||
embeddedServer(
|
||||
CIO,
|
||||
port = 8081,
|
||||
module = Application::mainModule
|
||||
).start(wait = true)
|
||||
}
|
||||
|
||||
private fun Application.mainModule() {
|
||||
install(ContentNegotiation) {
|
||||
json(Json {
|
||||
serializersModule = KompendiumSerializersModule.module
|
||||
encodeDefaults = true
|
||||
explicitNulls = false
|
||||
})
|
||||
}
|
||||
install(NotarizedApplication()) {
|
||||
spec = baseSpec
|
||||
// Adds support for @Transient and @SerialName
|
||||
// If you are not using them this is not required.
|
||||
schemaConfigurator = KotlinXSchemaConfigurator()
|
||||
}
|
||||
routing {
|
||||
redoc(pageTitle = "Simple API Docs")
|
||||
enrichedDocumentation()
|
||||
post {
|
||||
call.respond(HttpStatusCode.OK, ExampleResponse(false))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val testEnrichment = TypeEnrichment("testerino") {
|
||||
ExampleRequest::thingA {
|
||||
description = "This is a thing"
|
||||
}
|
||||
ExampleRequest::thingB {
|
||||
description = "This is another thing"
|
||||
}
|
||||
ExampleRequest::thingC {
|
||||
deprecated = true
|
||||
description = "A good but old field"
|
||||
typeEnrichment = TypeEnrichment("big-tings") {
|
||||
InnerRequest::d {
|
||||
description = "THE BIG D"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val testResponseEnrichment = TypeEnrichment("testerino") {
|
||||
ExampleResponse::isReal {
|
||||
description = "Is this thing real or not?"
|
||||
}
|
||||
}
|
||||
|
||||
private fun Route.enrichedDocumentation() {
|
||||
install(NotarizedRoute()) {
|
||||
post = PostInfo.builder {
|
||||
summary("Do a thing")
|
||||
description("This is a thing")
|
||||
request {
|
||||
requestType(enrichment = testEnrichment)
|
||||
description("This is the request")
|
||||
}
|
||||
response {
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType(enrichment = testResponseEnrichment)
|
||||
description("This is the response")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun Route.idDocumentation() {
|
||||
install(NotarizedRoute()) {
|
||||
parameters = listOf(
|
||||
Parameter(
|
||||
name = "id",
|
||||
`in` = Parameter.Location.path,
|
||||
schema = TypeDefinition.STRING
|
||||
)
|
||||
)
|
||||
get = GetInfo.builder {
|
||||
summary("Get user by id")
|
||||
description("A very neat endpoint!")
|
||||
response {
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<ExampleResponse>()
|
||||
description("Will return whether or not the user is real 😱")
|
||||
}
|
||||
|
||||
canRespond {
|
||||
responseType<ExceptionResponse>()
|
||||
responseCode(HttpStatusCode.NotFound)
|
||||
description("Indicates that a user with this id does not exist")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun Route.profileDocumentation() {
|
||||
install(NotarizedRoute()) {
|
||||
parameters = listOf(
|
||||
Parameter(
|
||||
name = "id",
|
||||
`in` = Parameter.Location.path,
|
||||
schema = TypeDefinition.STRING
|
||||
)
|
||||
)
|
||||
get = GetInfo.builder {
|
||||
summary("Get a users profile")
|
||||
description("A cool endpoint!")
|
||||
response {
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<ExampleResponse>()
|
||||
description("Returns user profile information")
|
||||
}
|
||||
canRespond {
|
||||
responseType<ExceptionResponse>()
|
||||
responseCode(HttpStatusCode.NotFound)
|
||||
description("Indicates that a user with this id does not exist")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -5,6 +5,19 @@ import io.ktor.server.locations.Location
|
||||
import kotlinx.datetime.Instant
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class ExampleRequest(
|
||||
val thingA: String,
|
||||
val thingB: Int,
|
||||
val thingC: InnerRequest,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class InnerRequest(
|
||||
val d: Float,
|
||||
val e: Boolean,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class ExampleResponse(val isReal: Boolean)
|
||||
|
||||
|
43
protobuf-java-converter/build.gradle.kts
Normal file
43
protobuf-java-converter/build.gradle.kts
Normal file
@ -0,0 +1,43 @@
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
kotlin("plugin.serialization")
|
||||
id("io.bkbn.sourdough.library.jvm")
|
||||
id("io.gitlab.arturbosch.detekt")
|
||||
id("com.adarshr.test-logger")
|
||||
id("maven-publish")
|
||||
id("java-library")
|
||||
id("signing")
|
||||
id("org.jetbrains.kotlinx.kover")
|
||||
}
|
||||
|
||||
sourdoughLibrary {
|
||||
libraryName.set("Kompendium Protobuf java converter")
|
||||
libraryDescription.set("Converts Java protobuf generated classes to custom type maps")
|
||||
compilerArgs.set(listOf("-opt-in=kotlin.RequiresOptIn"))
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Versions
|
||||
val detektVersion: String by project
|
||||
|
||||
|
||||
implementation(projects.kompendiumJsonSchema)
|
||||
implementation("com.google.protobuf:protobuf-java:3.21.12")
|
||||
implementation("org.jetbrains.kotlin:kotlin-reflect:1.8.0")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1")
|
||||
|
||||
// Formatting
|
||||
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:$detektVersion")
|
||||
testImplementation(testFixtures(projects.kompendiumCore))
|
||||
}
|
||||
|
||||
|
||||
testing {
|
||||
|
||||
suites {
|
||||
named("test", JvmTestSuite::class) {
|
||||
useJUnitJupiter()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,177 @@
|
||||
package io.bkbn.kompendium.protobufjavaconverter.converters
|
||||
|
||||
import com.google.protobuf.Descriptors
|
||||
import com.google.protobuf.GeneratedMessageV3
|
||||
import io.bkbn.kompendium.json.schema.definition.ArrayDefinition
|
||||
import io.bkbn.kompendium.json.schema.definition.EnumDefinition
|
||||
import io.bkbn.kompendium.json.schema.definition.JsonSchema
|
||||
import io.bkbn.kompendium.json.schema.definition.MapDefinition
|
||||
import io.bkbn.kompendium.json.schema.definition.NullableDefinition
|
||||
import io.bkbn.kompendium.json.schema.definition.ReferenceDefinition
|
||||
import io.bkbn.kompendium.json.schema.definition.TypeDefinition
|
||||
import kotlin.reflect.KType
|
||||
import kotlin.reflect.full.createType
|
||||
|
||||
/**
|
||||
* Extension function to generate all custom TypeDefinitions for.
|
||||
*
|
||||
* Traverses all fields and subfields of the message it also generates references for nested messages.
|
||||
*
|
||||
* @property GeneratedMessageV3 the protobuf message to generate all the custom definitions for
|
||||
* @param snakeCase whether to convert the names to snake case or not
|
||||
* @return a [Map] of ([KType], [TypeDefinition]) to be used in `customTypes` in [NoterizedApplication]
|
||||
*
|
||||
*/
|
||||
fun GeneratedMessageV3.createCustomTypesForTypeAndSubTypes(snakeCase: Boolean = false): Map<KType, JsonSchema> {
|
||||
val cache: MutableMap<String, JsonSchema> = mutableMapOf()
|
||||
return mapOf(
|
||||
this::class.createType() to TypeDefinition(
|
||||
type = "object",
|
||||
properties = toJsonSchemaMap(this.descriptorForType, cache, snakeCase)
|
||||
)
|
||||
)
|
||||
// Dont forget to add the definitions for our references
|
||||
.plus(
|
||||
cache.map {
|
||||
// Get the class from the respective key (which should be a fullname of the class
|
||||
val clazz = Class.forName(it.key)
|
||||
clazz.kotlin.createType() to it.value
|
||||
}.toMap()
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Loops over all fields of the provided Descriptor to discover the field types
|
||||
*
|
||||
* @param protoDescriptor the [Descriptors.FieldDescriptor] to convert
|
||||
* @param cache map of cached definitions
|
||||
* @param snakeCase whether to convert the names to snake case or not
|
||||
* @return a [Map] of ([String], [JsonSchema])
|
||||
*
|
||||
*/
|
||||
fun toJsonSchemaMap(
|
||||
protoDescriptor: Descriptors.Descriptor,
|
||||
cache: MutableMap<String, JsonSchema> = mutableMapOf(),
|
||||
snakeCase: Boolean = false
|
||||
): Map<String, JsonSchema> =
|
||||
protoDescriptor.fields.map {
|
||||
val key = if (snakeCase) it.jsonName.toSnakeCase() else it.jsonName
|
||||
key to fromNestedTypeToSchema(it, cache)
|
||||
}.toMap()
|
||||
|
||||
/**
|
||||
* Very simple snake case conversion
|
||||
*/
|
||||
fun String.toSnakeCase() =
|
||||
this.map {
|
||||
if (it.isUpperCase()) "_${it.lowercase()}" else it.toString()
|
||||
}.reduce { acc, s -> acc + s }
|
||||
|
||||
/**
|
||||
* Converts a field from a proto message to a JsonSchema
|
||||
*
|
||||
* @param javaProtoField the [Descriptors.FieldDescriptor] to convert
|
||||
* @param cache map of cached definitions
|
||||
* @return the resulting [JsonSchema]
|
||||
*
|
||||
*/
|
||||
fun fromNestedTypeToSchema(
|
||||
javaProtoField: Descriptors.FieldDescriptor,
|
||||
cache: MutableMap<String, JsonSchema> = mutableMapOf()
|
||||
): JsonSchema =
|
||||
when {
|
||||
javaProtoField.isRepeated && !javaProtoField.isMapField -> ArrayDefinition(fromTypeToSchema(javaProtoField, cache))
|
||||
javaProtoField.isMapField -> handleMapField(javaProtoField, cache)
|
||||
else -> fromTypeToSchema(javaProtoField, cache)
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a map field descriptor
|
||||
*
|
||||
* It generates some key examples based on the type provided and gets the TypeDefinition of the value.
|
||||
*
|
||||
* @param javaProtoField the field to convert (which should be a mapField)
|
||||
* @param cache map of cached definitions
|
||||
* @return returns the a [MapDefinition] schema with additional properties to describe the key and value
|
||||
*/
|
||||
@Suppress("MagicNumber")
|
||||
fun handleMapField(
|
||||
javaProtoField: Descriptors.FieldDescriptor,
|
||||
cache: MutableMap<String, JsonSchema> = mutableMapOf()
|
||||
): JsonSchema {
|
||||
require(javaProtoField.isMapField) { "Should never be called for a non map type" }
|
||||
|
||||
val keyField = javaProtoField.containingType.nestedTypes.first().findFieldByName("key")
|
||||
val valueField = javaProtoField.containingType.nestedTypes.first().findFieldByName("value")
|
||||
val valueType = fromTypeToSchema(valueField, cache)
|
||||
// Keys can only be string in json but we can still have "0", "0.0" or "true", "ENUM_VALUE" as keys
|
||||
val keys: List<String> = when (keyField.javaType) {
|
||||
Descriptors.FieldDescriptor.JavaType.INT,
|
||||
Descriptors.FieldDescriptor.JavaType.LONG -> (0..1).map { it.toString() }
|
||||
Descriptors.FieldDescriptor.JavaType.FLOAT,
|
||||
Descriptors.FieldDescriptor.JavaType.DOUBLE -> listOf(0.0, 0.1, 0.2).map { it.toString() }
|
||||
Descriptors.FieldDescriptor.JavaType.BOOLEAN -> listOf(true, false).map { it.toString() }
|
||||
Descriptors.FieldDescriptor.JavaType.STRING -> (0..1).map { "myVariable$it" }
|
||||
Descriptors.FieldDescriptor.JavaType.BYTE_STRING -> (0..1).map { "0x$it" }
|
||||
Descriptors.FieldDescriptor.JavaType.ENUM -> (0..1).map { "ENUM_VALUE$it" }
|
||||
null,
|
||||
Descriptors.FieldDescriptor.JavaType.MESSAGE -> throw IllegalArgumentException("Cant use object as key")
|
||||
}
|
||||
return MapDefinition(
|
||||
TypeDefinition(
|
||||
type = "object",
|
||||
properties = keys.map { it to valueType }.toMap()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts scalar, enum and message type descriptors to TypeDefinitions
|
||||
*
|
||||
* @param javaProtoField the field to convert
|
||||
* @param cache map of cached definitions
|
||||
* @return returns a matching [JsonSchema]
|
||||
*/
|
||||
fun fromTypeToSchema(
|
||||
javaProtoField: Descriptors.FieldDescriptor,
|
||||
cache: MutableMap<String, JsonSchema> = mutableMapOf()
|
||||
): JsonSchema {
|
||||
checkTypeCache(javaProtoField, cache)?.let { return it }
|
||||
return when (javaProtoField.javaType) {
|
||||
Descriptors.FieldDescriptor.JavaType.INT -> TypeDefinition.INT
|
||||
Descriptors.FieldDescriptor.JavaType.LONG -> TypeDefinition.LONG
|
||||
Descriptors.FieldDescriptor.JavaType.FLOAT -> TypeDefinition.FLOAT
|
||||
Descriptors.FieldDescriptor.JavaType.DOUBLE -> TypeDefinition.DOUBLE
|
||||
Descriptors.FieldDescriptor.JavaType.BOOLEAN -> TypeDefinition.BOOLEAN
|
||||
Descriptors.FieldDescriptor.JavaType.STRING -> TypeDefinition.STRING
|
||||
Descriptors.FieldDescriptor.JavaType.BYTE_STRING -> TypeDefinition.STRING
|
||||
Descriptors.FieldDescriptor.JavaType.ENUM -> {
|
||||
cache[javaProtoField.enumType.fullName] = EnumDefinition(
|
||||
type = "string",
|
||||
enum = javaProtoField.enumType.values.map { it.name }.toSet()
|
||||
)
|
||||
ReferenceDefinition(javaProtoField.enumType.name)
|
||||
}
|
||||
Descriptors.FieldDescriptor.JavaType.MESSAGE -> {
|
||||
// Traverse through possible nested messages
|
||||
cache[javaProtoField.messageType.fullName] = TypeDefinition(
|
||||
type = "object",
|
||||
properties = javaProtoField.messageType.fields.map {
|
||||
it.jsonName to fromNestedTypeToSchema(it, cache)
|
||||
}.toMap()
|
||||
)
|
||||
ReferenceDefinition(javaProtoField.messageType.name)
|
||||
}
|
||||
null -> NullableDefinition()
|
||||
}
|
||||
}
|
||||
|
||||
fun checkTypeCache(
|
||||
javaProtoField: Descriptors.FieldDescriptor,
|
||||
cache: MutableMap<String, JsonSchema>
|
||||
): JsonSchema? =
|
||||
when (javaProtoField.javaType) {
|
||||
Descriptors.FieldDescriptor.JavaType.ENUM -> cache[javaProtoField.enumType.name]
|
||||
Descriptors.FieldDescriptor.JavaType.MESSAGE -> cache[javaProtoField.messageType.name]
|
||||
else -> null
|
||||
}
|
@ -0,0 +1,167 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: io/bkbn/kompendium/protobufjavaconverter/converters/test.proto
|
||||
|
||||
package io.bkbn.kompendium.protobufjavaconverter;
|
||||
|
||||
/**
|
||||
* Protobuf enum {@code io.bkbn.kompendium.protobufjavaconverter.Corpus}
|
||||
*/
|
||||
public enum Corpus
|
||||
implements com.google.protobuf.ProtocolMessageEnum {
|
||||
/**
|
||||
* <code>CORPUS_UNSPECIFIED = 0;</code>
|
||||
*/
|
||||
CORPUS_UNSPECIFIED(0),
|
||||
/**
|
||||
* <code>CORPUS_UNIVERSAL = 1;</code>
|
||||
*/
|
||||
CORPUS_UNIVERSAL(1),
|
||||
/**
|
||||
* <code>CORPUS_WEB = 2;</code>
|
||||
*/
|
||||
CORPUS_WEB(2),
|
||||
/**
|
||||
* <code>CORPUS_IMAGES = 3;</code>
|
||||
*/
|
||||
CORPUS_IMAGES(3),
|
||||
/**
|
||||
* <code>CORPUS_LOCAL = 4;</code>
|
||||
*/
|
||||
CORPUS_LOCAL(4),
|
||||
/**
|
||||
* <code>CORPUS_NEWS = 5;</code>
|
||||
*/
|
||||
CORPUS_NEWS(5),
|
||||
/**
|
||||
* <code>CORPUS_PRODUCTS = 6;</code>
|
||||
*/
|
||||
CORPUS_PRODUCTS(6),
|
||||
/**
|
||||
* <code>CORPUS_VIDEO = 7;</code>
|
||||
*/
|
||||
CORPUS_VIDEO(7),
|
||||
UNRECOGNIZED(-1),
|
||||
;
|
||||
|
||||
/**
|
||||
* <code>CORPUS_UNSPECIFIED = 0;</code>
|
||||
*/
|
||||
public static final int CORPUS_UNSPECIFIED_VALUE = 0;
|
||||
/**
|
||||
* <code>CORPUS_UNIVERSAL = 1;</code>
|
||||
*/
|
||||
public static final int CORPUS_UNIVERSAL_VALUE = 1;
|
||||
/**
|
||||
* <code>CORPUS_WEB = 2;</code>
|
||||
*/
|
||||
public static final int CORPUS_WEB_VALUE = 2;
|
||||
/**
|
||||
* <code>CORPUS_IMAGES = 3;</code>
|
||||
*/
|
||||
public static final int CORPUS_IMAGES_VALUE = 3;
|
||||
/**
|
||||
* <code>CORPUS_LOCAL = 4;</code>
|
||||
*/
|
||||
public static final int CORPUS_LOCAL_VALUE = 4;
|
||||
/**
|
||||
* <code>CORPUS_NEWS = 5;</code>
|
||||
*/
|
||||
public static final int CORPUS_NEWS_VALUE = 5;
|
||||
/**
|
||||
* <code>CORPUS_PRODUCTS = 6;</code>
|
||||
*/
|
||||
public static final int CORPUS_PRODUCTS_VALUE = 6;
|
||||
/**
|
||||
* <code>CORPUS_VIDEO = 7;</code>
|
||||
*/
|
||||
public static final int CORPUS_VIDEO_VALUE = 7;
|
||||
|
||||
|
||||
public final int getNumber() {
|
||||
if (this == UNRECOGNIZED) {
|
||||
throw new java.lang.IllegalArgumentException(
|
||||
"Can't get the number of an unknown enum value.");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value The numeric wire value of the corresponding enum entry.
|
||||
* @return The enum associated with the given numeric wire value.
|
||||
* @deprecated Use {@link #forNumber(int)} instead.
|
||||
*/
|
||||
@java.lang.Deprecated
|
||||
public static Corpus valueOf(int value) {
|
||||
return forNumber(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value The numeric wire value of the corresponding enum entry.
|
||||
* @return The enum associated with the given numeric wire value.
|
||||
*/
|
||||
public static Corpus forNumber(int value) {
|
||||
switch (value) {
|
||||
case 0: return CORPUS_UNSPECIFIED;
|
||||
case 1: return CORPUS_UNIVERSAL;
|
||||
case 2: return CORPUS_WEB;
|
||||
case 3: return CORPUS_IMAGES;
|
||||
case 4: return CORPUS_LOCAL;
|
||||
case 5: return CORPUS_NEWS;
|
||||
case 6: return CORPUS_PRODUCTS;
|
||||
case 7: return CORPUS_VIDEO;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static com.google.protobuf.Internal.EnumLiteMap<Corpus>
|
||||
internalGetValueMap() {
|
||||
return internalValueMap;
|
||||
}
|
||||
private static final com.google.protobuf.Internal.EnumLiteMap<
|
||||
Corpus> internalValueMap =
|
||||
new com.google.protobuf.Internal.EnumLiteMap<Corpus>() {
|
||||
public Corpus findValueByNumber(int number) {
|
||||
return Corpus.forNumber(number);
|
||||
}
|
||||
};
|
||||
|
||||
public final com.google.protobuf.Descriptors.EnumValueDescriptor
|
||||
getValueDescriptor() {
|
||||
if (this == UNRECOGNIZED) {
|
||||
throw new java.lang.IllegalStateException(
|
||||
"Can't get the descriptor of an unrecognized enum value.");
|
||||
}
|
||||
return getDescriptor().getValues().get(ordinal());
|
||||
}
|
||||
public final com.google.protobuf.Descriptors.EnumDescriptor
|
||||
getDescriptorForType() {
|
||||
return getDescriptor();
|
||||
}
|
||||
public static final com.google.protobuf.Descriptors.EnumDescriptor
|
||||
getDescriptor() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.getDescriptor().getEnumTypes().get(0);
|
||||
}
|
||||
|
||||
private static final Corpus[] VALUES = values();
|
||||
|
||||
public static Corpus valueOf(
|
||||
com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
|
||||
if (desc.getType() != getDescriptor()) {
|
||||
throw new java.lang.IllegalArgumentException(
|
||||
"EnumValueDescriptor is not for this type.");
|
||||
}
|
||||
if (desc.getIndex() == -1) {
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
return VALUES[desc.getIndex()];
|
||||
}
|
||||
|
||||
private final int value;
|
||||
|
||||
private Corpus(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(enum_scope:io.bkbn.kompendium.protobufjavaconverter.Corpus)
|
||||
}
|
||||
|
@ -0,0 +1,607 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: io/bkbn/kompendium/protobufjavaconverter/converters/test.proto
|
||||
|
||||
package io.bkbn.kompendium.protobufjavaconverter;
|
||||
|
||||
/**
|
||||
* Protobuf type {@code io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage}
|
||||
*/
|
||||
public final class DoubleNestedMessage extends
|
||||
com.google.protobuf.GeneratedMessageV3 implements
|
||||
// @@protoc_insertion_point(message_implements:io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage)
|
||||
DoubleNestedMessageOrBuilder {
|
||||
private static final long serialVersionUID = 0L;
|
||||
// Use DoubleNestedMessage.newBuilder() to construct.
|
||||
private DoubleNestedMessage(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
|
||||
super(builder);
|
||||
}
|
||||
private DoubleNestedMessage() {
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
@SuppressWarnings({"unused"})
|
||||
protected java.lang.Object newInstance(
|
||||
UnusedPrivateParameter unused) {
|
||||
return new DoubleNestedMessage();
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public final com.google.protobuf.UnknownFieldSet
|
||||
getUnknownFields() {
|
||||
return this.unknownFields;
|
||||
}
|
||||
private DoubleNestedMessage(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
this();
|
||||
if (extensionRegistry == null) {
|
||||
throw new java.lang.NullPointerException();
|
||||
}
|
||||
com.google.protobuf.UnknownFieldSet.Builder unknownFields =
|
||||
com.google.protobuf.UnknownFieldSet.newBuilder();
|
||||
try {
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
int tag = input.readTag();
|
||||
switch (tag) {
|
||||
case 0:
|
||||
done = true;
|
||||
break;
|
||||
case 10: {
|
||||
io.bkbn.kompendium.protobufjavaconverter.NestedMessage.Builder subBuilder = null;
|
||||
if (nestedField_ != null) {
|
||||
subBuilder = nestedField_.toBuilder();
|
||||
}
|
||||
nestedField_ = input.readMessage(io.bkbn.kompendium.protobufjavaconverter.NestedMessage.parser(), extensionRegistry);
|
||||
if (subBuilder != null) {
|
||||
subBuilder.mergeFrom(nestedField_);
|
||||
nestedField_ = subBuilder.buildPartial();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
if (!parseUnknownField(
|
||||
input, unknownFields, extensionRegistry, tag)) {
|
||||
done = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
||||
throw e.setUnfinishedMessage(this);
|
||||
} catch (java.io.IOException e) {
|
||||
throw new com.google.protobuf.InvalidProtocolBufferException(
|
||||
e).setUnfinishedMessage(this);
|
||||
} finally {
|
||||
this.unknownFields = unknownFields.build();
|
||||
makeExtensionsImmutable();
|
||||
}
|
||||
}
|
||||
public static final com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptor() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_DoubleNestedMessage_descriptor;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internalGetFieldAccessorTable() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_DoubleNestedMessage_fieldAccessorTable
|
||||
.ensureFieldAccessorsInitialized(
|
||||
io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage.class, io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage.Builder.class);
|
||||
}
|
||||
|
||||
public static final int NESTED_FIELD_FIELD_NUMBER = 1;
|
||||
private io.bkbn.kompendium.protobufjavaconverter.NestedMessage nestedField_;
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.NestedMessage nested_field = 1;</code>
|
||||
* @return Whether the nestedField field is set.
|
||||
*/
|
||||
@java.lang.Override
|
||||
public boolean hasNestedField() {
|
||||
return nestedField_ != null;
|
||||
}
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.NestedMessage nested_field = 1;</code>
|
||||
* @return The nestedField.
|
||||
*/
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.NestedMessage getNestedField() {
|
||||
return nestedField_ == null ? io.bkbn.kompendium.protobufjavaconverter.NestedMessage.getDefaultInstance() : nestedField_;
|
||||
}
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.NestedMessage nested_field = 1;</code>
|
||||
*/
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.NestedMessageOrBuilder getNestedFieldOrBuilder() {
|
||||
return getNestedField();
|
||||
}
|
||||
|
||||
private byte memoizedIsInitialized = -1;
|
||||
@java.lang.Override
|
||||
public final boolean isInitialized() {
|
||||
byte isInitialized = memoizedIsInitialized;
|
||||
if (isInitialized == 1) return true;
|
||||
if (isInitialized == 0) return false;
|
||||
|
||||
memoizedIsInitialized = 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public void writeTo(com.google.protobuf.CodedOutputStream output)
|
||||
throws java.io.IOException {
|
||||
if (nestedField_ != null) {
|
||||
output.writeMessage(1, getNestedField());
|
||||
}
|
||||
unknownFields.writeTo(output);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public int getSerializedSize() {
|
||||
int size = memoizedSize;
|
||||
if (size != -1) return size;
|
||||
|
||||
size = 0;
|
||||
if (nestedField_ != null) {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeMessageSize(1, getNestedField());
|
||||
}
|
||||
size += unknownFields.getSerializedSize();
|
||||
memoizedSize = size;
|
||||
return size;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public boolean equals(final java.lang.Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage)) {
|
||||
return super.equals(obj);
|
||||
}
|
||||
io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage other = (io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage) obj;
|
||||
|
||||
if (hasNestedField() != other.hasNestedField()) return false;
|
||||
if (hasNestedField()) {
|
||||
if (!getNestedField()
|
||||
.equals(other.getNestedField())) return false;
|
||||
}
|
||||
if (!unknownFields.equals(other.unknownFields)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public int hashCode() {
|
||||
if (memoizedHashCode != 0) {
|
||||
return memoizedHashCode;
|
||||
}
|
||||
int hash = 41;
|
||||
hash = (19 * hash) + getDescriptor().hashCode();
|
||||
if (hasNestedField()) {
|
||||
hash = (37 * hash) + NESTED_FIELD_FIELD_NUMBER;
|
||||
hash = (53 * hash) + getNestedField().hashCode();
|
||||
}
|
||||
hash = (29 * hash) + unknownFields.hashCode();
|
||||
memoizedHashCode = hash;
|
||||
return hash;
|
||||
}
|
||||
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage parseFrom(
|
||||
java.nio.ByteBuffer data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage parseFrom(
|
||||
java.nio.ByteBuffer data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage parseFrom(
|
||||
com.google.protobuf.ByteString data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage parseFrom(
|
||||
com.google.protobuf.ByteString data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage parseFrom(byte[] data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage parseFrom(
|
||||
byte[] data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage parseFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage parseFrom(
|
||||
java.io.InputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage parseDelimitedFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseDelimitedWithIOException(PARSER, input);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage parseDelimitedFrom(
|
||||
java.io.InputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseDelimitedWithIOException(PARSER, input, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage parseFrom(
|
||||
com.google.protobuf.CodedInputStream input)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage parseFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input, extensionRegistry);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder newBuilderForType() { return newBuilder(); }
|
||||
public static Builder newBuilder() {
|
||||
return DEFAULT_INSTANCE.toBuilder();
|
||||
}
|
||||
public static Builder newBuilder(io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage prototype) {
|
||||
return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder toBuilder() {
|
||||
return this == DEFAULT_INSTANCE
|
||||
? new Builder() : new Builder().mergeFrom(this);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected Builder newBuilderForType(
|
||||
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
|
||||
Builder builder = new Builder(parent);
|
||||
return builder;
|
||||
}
|
||||
/**
|
||||
* Protobuf type {@code io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage}
|
||||
*/
|
||||
public static final class Builder extends
|
||||
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
|
||||
// @@protoc_insertion_point(builder_implements:io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage)
|
||||
io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessageOrBuilder {
|
||||
public static final com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptor() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_DoubleNestedMessage_descriptor;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internalGetFieldAccessorTable() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_DoubleNestedMessage_fieldAccessorTable
|
||||
.ensureFieldAccessorsInitialized(
|
||||
io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage.class, io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage.Builder.class);
|
||||
}
|
||||
|
||||
// Construct using io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage.newBuilder()
|
||||
private Builder() {
|
||||
maybeForceBuilderInitialization();
|
||||
}
|
||||
|
||||
private Builder(
|
||||
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
|
||||
super(parent);
|
||||
maybeForceBuilderInitialization();
|
||||
}
|
||||
private void maybeForceBuilderInitialization() {
|
||||
if (com.google.protobuf.GeneratedMessageV3
|
||||
.alwaysUseFieldBuilders) {
|
||||
}
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder clear() {
|
||||
super.clear();
|
||||
if (nestedFieldBuilder_ == null) {
|
||||
nestedField_ = null;
|
||||
} else {
|
||||
nestedField_ = null;
|
||||
nestedFieldBuilder_ = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptorForType() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_DoubleNestedMessage_descriptor;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage getDefaultInstanceForType() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage.getDefaultInstance();
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage build() {
|
||||
io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage result = buildPartial();
|
||||
if (!result.isInitialized()) {
|
||||
throw newUninitializedMessageException(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage buildPartial() {
|
||||
io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage result = new io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage(this);
|
||||
if (nestedFieldBuilder_ == null) {
|
||||
result.nestedField_ = nestedField_;
|
||||
} else {
|
||||
result.nestedField_ = nestedFieldBuilder_.build();
|
||||
}
|
||||
onBuilt();
|
||||
return result;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder clone() {
|
||||
return super.clone();
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder setField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field,
|
||||
java.lang.Object value) {
|
||||
return super.setField(field, value);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder clearField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field) {
|
||||
return super.clearField(field);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder clearOneof(
|
||||
com.google.protobuf.Descriptors.OneofDescriptor oneof) {
|
||||
return super.clearOneof(oneof);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder setRepeatedField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field,
|
||||
int index, java.lang.Object value) {
|
||||
return super.setRepeatedField(field, index, value);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder addRepeatedField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field,
|
||||
java.lang.Object value) {
|
||||
return super.addRepeatedField(field, value);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder mergeFrom(com.google.protobuf.Message other) {
|
||||
if (other instanceof io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage) {
|
||||
return mergeFrom((io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage)other);
|
||||
} else {
|
||||
super.mergeFrom(other);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public Builder mergeFrom(io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage other) {
|
||||
if (other == io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage.getDefaultInstance()) return this;
|
||||
if (other.hasNestedField()) {
|
||||
mergeNestedField(other.getNestedField());
|
||||
}
|
||||
this.mergeUnknownFields(other.unknownFields);
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public final boolean isInitialized() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder mergeFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage parsedMessage = null;
|
||||
try {
|
||||
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
|
||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
||||
parsedMessage = (io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage) e.getUnfinishedMessage();
|
||||
throw e.unwrapIOException();
|
||||
} finally {
|
||||
if (parsedMessage != null) {
|
||||
mergeFrom(parsedMessage);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
private io.bkbn.kompendium.protobufjavaconverter.NestedMessage nestedField_;
|
||||
private com.google.protobuf.SingleFieldBuilderV3<
|
||||
io.bkbn.kompendium.protobufjavaconverter.NestedMessage, io.bkbn.kompendium.protobufjavaconverter.NestedMessage.Builder, io.bkbn.kompendium.protobufjavaconverter.NestedMessageOrBuilder> nestedFieldBuilder_;
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.NestedMessage nested_field = 1;</code>
|
||||
* @return Whether the nestedField field is set.
|
||||
*/
|
||||
public boolean hasNestedField() {
|
||||
return nestedFieldBuilder_ != null || nestedField_ != null;
|
||||
}
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.NestedMessage nested_field = 1;</code>
|
||||
* @return The nestedField.
|
||||
*/
|
||||
public io.bkbn.kompendium.protobufjavaconverter.NestedMessage getNestedField() {
|
||||
if (nestedFieldBuilder_ == null) {
|
||||
return nestedField_ == null ? io.bkbn.kompendium.protobufjavaconverter.NestedMessage.getDefaultInstance() : nestedField_;
|
||||
} else {
|
||||
return nestedFieldBuilder_.getMessage();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.NestedMessage nested_field = 1;</code>
|
||||
*/
|
||||
public Builder setNestedField(io.bkbn.kompendium.protobufjavaconverter.NestedMessage value) {
|
||||
if (nestedFieldBuilder_ == null) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
nestedField_ = value;
|
||||
onChanged();
|
||||
} else {
|
||||
nestedFieldBuilder_.setMessage(value);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.NestedMessage nested_field = 1;</code>
|
||||
*/
|
||||
public Builder setNestedField(
|
||||
io.bkbn.kompendium.protobufjavaconverter.NestedMessage.Builder builderForValue) {
|
||||
if (nestedFieldBuilder_ == null) {
|
||||
nestedField_ = builderForValue.build();
|
||||
onChanged();
|
||||
} else {
|
||||
nestedFieldBuilder_.setMessage(builderForValue.build());
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.NestedMessage nested_field = 1;</code>
|
||||
*/
|
||||
public Builder mergeNestedField(io.bkbn.kompendium.protobufjavaconverter.NestedMessage value) {
|
||||
if (nestedFieldBuilder_ == null) {
|
||||
if (nestedField_ != null) {
|
||||
nestedField_ =
|
||||
io.bkbn.kompendium.protobufjavaconverter.NestedMessage.newBuilder(nestedField_).mergeFrom(value).buildPartial();
|
||||
} else {
|
||||
nestedField_ = value;
|
||||
}
|
||||
onChanged();
|
||||
} else {
|
||||
nestedFieldBuilder_.mergeFrom(value);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.NestedMessage nested_field = 1;</code>
|
||||
*/
|
||||
public Builder clearNestedField() {
|
||||
if (nestedFieldBuilder_ == null) {
|
||||
nestedField_ = null;
|
||||
onChanged();
|
||||
} else {
|
||||
nestedField_ = null;
|
||||
nestedFieldBuilder_ = null;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.NestedMessage nested_field = 1;</code>
|
||||
*/
|
||||
public io.bkbn.kompendium.protobufjavaconverter.NestedMessage.Builder getNestedFieldBuilder() {
|
||||
|
||||
onChanged();
|
||||
return getNestedFieldFieldBuilder().getBuilder();
|
||||
}
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.NestedMessage nested_field = 1;</code>
|
||||
*/
|
||||
public io.bkbn.kompendium.protobufjavaconverter.NestedMessageOrBuilder getNestedFieldOrBuilder() {
|
||||
if (nestedFieldBuilder_ != null) {
|
||||
return nestedFieldBuilder_.getMessageOrBuilder();
|
||||
} else {
|
||||
return nestedField_ == null ?
|
||||
io.bkbn.kompendium.protobufjavaconverter.NestedMessage.getDefaultInstance() : nestedField_;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.NestedMessage nested_field = 1;</code>
|
||||
*/
|
||||
private com.google.protobuf.SingleFieldBuilderV3<
|
||||
io.bkbn.kompendium.protobufjavaconverter.NestedMessage, io.bkbn.kompendium.protobufjavaconverter.NestedMessage.Builder, io.bkbn.kompendium.protobufjavaconverter.NestedMessageOrBuilder>
|
||||
getNestedFieldFieldBuilder() {
|
||||
if (nestedFieldBuilder_ == null) {
|
||||
nestedFieldBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
|
||||
io.bkbn.kompendium.protobufjavaconverter.NestedMessage, io.bkbn.kompendium.protobufjavaconverter.NestedMessage.Builder, io.bkbn.kompendium.protobufjavaconverter.NestedMessageOrBuilder>(
|
||||
getNestedField(),
|
||||
getParentForChildren(),
|
||||
isClean());
|
||||
nestedField_ = null;
|
||||
}
|
||||
return nestedFieldBuilder_;
|
||||
}
|
||||
@java.lang.Override
|
||||
public final Builder setUnknownFields(
|
||||
final com.google.protobuf.UnknownFieldSet unknownFields) {
|
||||
return super.setUnknownFields(unknownFields);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public final Builder mergeUnknownFields(
|
||||
final com.google.protobuf.UnknownFieldSet unknownFields) {
|
||||
return super.mergeUnknownFields(unknownFields);
|
||||
}
|
||||
|
||||
|
||||
// @@protoc_insertion_point(builder_scope:io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage)
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(class_scope:io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage)
|
||||
private static final io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage DEFAULT_INSTANCE;
|
||||
static {
|
||||
DEFAULT_INSTANCE = new io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage();
|
||||
}
|
||||
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage getDefaultInstance() {
|
||||
return DEFAULT_INSTANCE;
|
||||
}
|
||||
|
||||
private static final com.google.protobuf.Parser<DoubleNestedMessage>
|
||||
PARSER = new com.google.protobuf.AbstractParser<DoubleNestedMessage>() {
|
||||
@java.lang.Override
|
||||
public DoubleNestedMessage parsePartialFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return new DoubleNestedMessage(input, extensionRegistry);
|
||||
}
|
||||
};
|
||||
|
||||
public static com.google.protobuf.Parser<DoubleNestedMessage> parser() {
|
||||
return PARSER;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.Parser<DoubleNestedMessage> getParserForType() {
|
||||
return PARSER;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage getDefaultInstanceForType() {
|
||||
return DEFAULT_INSTANCE;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: io/bkbn/kompendium/protobufjavaconverter/converters/test.proto
|
||||
|
||||
package io.bkbn.kompendium.protobufjavaconverter;
|
||||
|
||||
public interface DoubleNestedMessageOrBuilder extends
|
||||
// @@protoc_insertion_point(interface_extends:io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage)
|
||||
com.google.protobuf.MessageOrBuilder {
|
||||
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.NestedMessage nested_field = 1;</code>
|
||||
* @return Whether the nestedField field is set.
|
||||
*/
|
||||
boolean hasNestedField();
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.NestedMessage nested_field = 1;</code>
|
||||
* @return The nestedField.
|
||||
*/
|
||||
io.bkbn.kompendium.protobufjavaconverter.NestedMessage getNestedField();
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.NestedMessage nested_field = 1;</code>
|
||||
*/
|
||||
io.bkbn.kompendium.protobufjavaconverter.NestedMessageOrBuilder getNestedFieldOrBuilder();
|
||||
}
|
@ -0,0 +1,515 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: io/bkbn/kompendium/protobufjavaconverter/converters/test.proto
|
||||
|
||||
package io.bkbn.kompendium.protobufjavaconverter;
|
||||
|
||||
/**
|
||||
* Protobuf type {@code io.bkbn.kompendium.protobufjavaconverter.EnumMessage}
|
||||
*/
|
||||
public final class EnumMessage extends
|
||||
com.google.protobuf.GeneratedMessageV3 implements
|
||||
// @@protoc_insertion_point(message_implements:io.bkbn.kompendium.protobufjavaconverter.EnumMessage)
|
||||
EnumMessageOrBuilder {
|
||||
private static final long serialVersionUID = 0L;
|
||||
// Use EnumMessage.newBuilder() to construct.
|
||||
private EnumMessage(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
|
||||
super(builder);
|
||||
}
|
||||
private EnumMessage() {
|
||||
corpus_ = 0;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
@SuppressWarnings({"unused"})
|
||||
protected java.lang.Object newInstance(
|
||||
UnusedPrivateParameter unused) {
|
||||
return new EnumMessage();
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public final com.google.protobuf.UnknownFieldSet
|
||||
getUnknownFields() {
|
||||
return this.unknownFields;
|
||||
}
|
||||
private EnumMessage(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
this();
|
||||
if (extensionRegistry == null) {
|
||||
throw new java.lang.NullPointerException();
|
||||
}
|
||||
com.google.protobuf.UnknownFieldSet.Builder unknownFields =
|
||||
com.google.protobuf.UnknownFieldSet.newBuilder();
|
||||
try {
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
int tag = input.readTag();
|
||||
switch (tag) {
|
||||
case 0:
|
||||
done = true;
|
||||
break;
|
||||
case 8: {
|
||||
int rawValue = input.readEnum();
|
||||
|
||||
corpus_ = rawValue;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
if (!parseUnknownField(
|
||||
input, unknownFields, extensionRegistry, tag)) {
|
||||
done = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
||||
throw e.setUnfinishedMessage(this);
|
||||
} catch (java.io.IOException e) {
|
||||
throw new com.google.protobuf.InvalidProtocolBufferException(
|
||||
e).setUnfinishedMessage(this);
|
||||
} finally {
|
||||
this.unknownFields = unknownFields.build();
|
||||
makeExtensionsImmutable();
|
||||
}
|
||||
}
|
||||
public static final com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptor() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_EnumMessage_descriptor;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internalGetFieldAccessorTable() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_EnumMessage_fieldAccessorTable
|
||||
.ensureFieldAccessorsInitialized(
|
||||
io.bkbn.kompendium.protobufjavaconverter.EnumMessage.class, io.bkbn.kompendium.protobufjavaconverter.EnumMessage.Builder.class);
|
||||
}
|
||||
|
||||
public static final int CORPUS_FIELD_NUMBER = 1;
|
||||
private int corpus_;
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.Corpus corpus = 1;</code>
|
||||
* @return The enum numeric value on the wire for corpus.
|
||||
*/
|
||||
@java.lang.Override public int getCorpusValue() {
|
||||
return corpus_;
|
||||
}
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.Corpus corpus = 1;</code>
|
||||
* @return The corpus.
|
||||
*/
|
||||
@java.lang.Override public io.bkbn.kompendium.protobufjavaconverter.Corpus getCorpus() {
|
||||
@SuppressWarnings("deprecation")
|
||||
io.bkbn.kompendium.protobufjavaconverter.Corpus result = io.bkbn.kompendium.protobufjavaconverter.Corpus.valueOf(corpus_);
|
||||
return result == null ? io.bkbn.kompendium.protobufjavaconverter.Corpus.UNRECOGNIZED : result;
|
||||
}
|
||||
|
||||
private byte memoizedIsInitialized = -1;
|
||||
@java.lang.Override
|
||||
public final boolean isInitialized() {
|
||||
byte isInitialized = memoizedIsInitialized;
|
||||
if (isInitialized == 1) return true;
|
||||
if (isInitialized == 0) return false;
|
||||
|
||||
memoizedIsInitialized = 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public void writeTo(com.google.protobuf.CodedOutputStream output)
|
||||
throws java.io.IOException {
|
||||
if (corpus_ != io.bkbn.kompendium.protobufjavaconverter.Corpus.CORPUS_UNSPECIFIED.getNumber()) {
|
||||
output.writeEnum(1, corpus_);
|
||||
}
|
||||
unknownFields.writeTo(output);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public int getSerializedSize() {
|
||||
int size = memoizedSize;
|
||||
if (size != -1) return size;
|
||||
|
||||
size = 0;
|
||||
if (corpus_ != io.bkbn.kompendium.protobufjavaconverter.Corpus.CORPUS_UNSPECIFIED.getNumber()) {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeEnumSize(1, corpus_);
|
||||
}
|
||||
size += unknownFields.getSerializedSize();
|
||||
memoizedSize = size;
|
||||
return size;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public boolean equals(final java.lang.Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof io.bkbn.kompendium.protobufjavaconverter.EnumMessage)) {
|
||||
return super.equals(obj);
|
||||
}
|
||||
io.bkbn.kompendium.protobufjavaconverter.EnumMessage other = (io.bkbn.kompendium.protobufjavaconverter.EnumMessage) obj;
|
||||
|
||||
if (corpus_ != other.corpus_) return false;
|
||||
if (!unknownFields.equals(other.unknownFields)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public int hashCode() {
|
||||
if (memoizedHashCode != 0) {
|
||||
return memoizedHashCode;
|
||||
}
|
||||
int hash = 41;
|
||||
hash = (19 * hash) + getDescriptor().hashCode();
|
||||
hash = (37 * hash) + CORPUS_FIELD_NUMBER;
|
||||
hash = (53 * hash) + corpus_;
|
||||
hash = (29 * hash) + unknownFields.hashCode();
|
||||
memoizedHashCode = hash;
|
||||
return hash;
|
||||
}
|
||||
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.EnumMessage parseFrom(
|
||||
java.nio.ByteBuffer data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.EnumMessage parseFrom(
|
||||
java.nio.ByteBuffer data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.EnumMessage parseFrom(
|
||||
com.google.protobuf.ByteString data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.EnumMessage parseFrom(
|
||||
com.google.protobuf.ByteString data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.EnumMessage parseFrom(byte[] data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.EnumMessage parseFrom(
|
||||
byte[] data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.EnumMessage parseFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.EnumMessage parseFrom(
|
||||
java.io.InputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.EnumMessage parseDelimitedFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseDelimitedWithIOException(PARSER, input);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.EnumMessage parseDelimitedFrom(
|
||||
java.io.InputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseDelimitedWithIOException(PARSER, input, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.EnumMessage parseFrom(
|
||||
com.google.protobuf.CodedInputStream input)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.EnumMessage parseFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input, extensionRegistry);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder newBuilderForType() { return newBuilder(); }
|
||||
public static Builder newBuilder() {
|
||||
return DEFAULT_INSTANCE.toBuilder();
|
||||
}
|
||||
public static Builder newBuilder(io.bkbn.kompendium.protobufjavaconverter.EnumMessage prototype) {
|
||||
return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder toBuilder() {
|
||||
return this == DEFAULT_INSTANCE
|
||||
? new Builder() : new Builder().mergeFrom(this);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected Builder newBuilderForType(
|
||||
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
|
||||
Builder builder = new Builder(parent);
|
||||
return builder;
|
||||
}
|
||||
/**
|
||||
* Protobuf type {@code io.bkbn.kompendium.protobufjavaconverter.EnumMessage}
|
||||
*/
|
||||
public static final class Builder extends
|
||||
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
|
||||
// @@protoc_insertion_point(builder_implements:io.bkbn.kompendium.protobufjavaconverter.EnumMessage)
|
||||
io.bkbn.kompendium.protobufjavaconverter.EnumMessageOrBuilder {
|
||||
public static final com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptor() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_EnumMessage_descriptor;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internalGetFieldAccessorTable() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_EnumMessage_fieldAccessorTable
|
||||
.ensureFieldAccessorsInitialized(
|
||||
io.bkbn.kompendium.protobufjavaconverter.EnumMessage.class, io.bkbn.kompendium.protobufjavaconverter.EnumMessage.Builder.class);
|
||||
}
|
||||
|
||||
// Construct using io.bkbn.kompendium.protobufjavaconverter.EnumMessage.newBuilder()
|
||||
private Builder() {
|
||||
maybeForceBuilderInitialization();
|
||||
}
|
||||
|
||||
private Builder(
|
||||
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
|
||||
super(parent);
|
||||
maybeForceBuilderInitialization();
|
||||
}
|
||||
private void maybeForceBuilderInitialization() {
|
||||
if (com.google.protobuf.GeneratedMessageV3
|
||||
.alwaysUseFieldBuilders) {
|
||||
}
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder clear() {
|
||||
super.clear();
|
||||
corpus_ = 0;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptorForType() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_EnumMessage_descriptor;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.EnumMessage getDefaultInstanceForType() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.EnumMessage.getDefaultInstance();
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.EnumMessage build() {
|
||||
io.bkbn.kompendium.protobufjavaconverter.EnumMessage result = buildPartial();
|
||||
if (!result.isInitialized()) {
|
||||
throw newUninitializedMessageException(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.EnumMessage buildPartial() {
|
||||
io.bkbn.kompendium.protobufjavaconverter.EnumMessage result = new io.bkbn.kompendium.protobufjavaconverter.EnumMessage(this);
|
||||
result.corpus_ = corpus_;
|
||||
onBuilt();
|
||||
return result;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder clone() {
|
||||
return super.clone();
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder setField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field,
|
||||
java.lang.Object value) {
|
||||
return super.setField(field, value);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder clearField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field) {
|
||||
return super.clearField(field);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder clearOneof(
|
||||
com.google.protobuf.Descriptors.OneofDescriptor oneof) {
|
||||
return super.clearOneof(oneof);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder setRepeatedField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field,
|
||||
int index, java.lang.Object value) {
|
||||
return super.setRepeatedField(field, index, value);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder addRepeatedField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field,
|
||||
java.lang.Object value) {
|
||||
return super.addRepeatedField(field, value);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder mergeFrom(com.google.protobuf.Message other) {
|
||||
if (other instanceof io.bkbn.kompendium.protobufjavaconverter.EnumMessage) {
|
||||
return mergeFrom((io.bkbn.kompendium.protobufjavaconverter.EnumMessage)other);
|
||||
} else {
|
||||
super.mergeFrom(other);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public Builder mergeFrom(io.bkbn.kompendium.protobufjavaconverter.EnumMessage other) {
|
||||
if (other == io.bkbn.kompendium.protobufjavaconverter.EnumMessage.getDefaultInstance()) return this;
|
||||
if (other.corpus_ != 0) {
|
||||
setCorpusValue(other.getCorpusValue());
|
||||
}
|
||||
this.mergeUnknownFields(other.unknownFields);
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public final boolean isInitialized() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder mergeFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
io.bkbn.kompendium.protobufjavaconverter.EnumMessage parsedMessage = null;
|
||||
try {
|
||||
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
|
||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
||||
parsedMessage = (io.bkbn.kompendium.protobufjavaconverter.EnumMessage) e.getUnfinishedMessage();
|
||||
throw e.unwrapIOException();
|
||||
} finally {
|
||||
if (parsedMessage != null) {
|
||||
mergeFrom(parsedMessage);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
private int corpus_ = 0;
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.Corpus corpus = 1;</code>
|
||||
* @return The enum numeric value on the wire for corpus.
|
||||
*/
|
||||
@java.lang.Override public int getCorpusValue() {
|
||||
return corpus_;
|
||||
}
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.Corpus corpus = 1;</code>
|
||||
* @param value The enum numeric value on the wire for corpus to set.
|
||||
* @return This builder for chaining.
|
||||
*/
|
||||
public Builder setCorpusValue(int value) {
|
||||
|
||||
corpus_ = value;
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.Corpus corpus = 1;</code>
|
||||
* @return The corpus.
|
||||
*/
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.Corpus getCorpus() {
|
||||
@SuppressWarnings("deprecation")
|
||||
io.bkbn.kompendium.protobufjavaconverter.Corpus result = io.bkbn.kompendium.protobufjavaconverter.Corpus.valueOf(corpus_);
|
||||
return result == null ? io.bkbn.kompendium.protobufjavaconverter.Corpus.UNRECOGNIZED : result;
|
||||
}
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.Corpus corpus = 1;</code>
|
||||
* @param value The corpus to set.
|
||||
* @return This builder for chaining.
|
||||
*/
|
||||
public Builder setCorpus(io.bkbn.kompendium.protobufjavaconverter.Corpus value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
corpus_ = value.getNumber();
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.Corpus corpus = 1;</code>
|
||||
* @return This builder for chaining.
|
||||
*/
|
||||
public Builder clearCorpus() {
|
||||
|
||||
corpus_ = 0;
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
@java.lang.Override
|
||||
public final Builder setUnknownFields(
|
||||
final com.google.protobuf.UnknownFieldSet unknownFields) {
|
||||
return super.setUnknownFields(unknownFields);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public final Builder mergeUnknownFields(
|
||||
final com.google.protobuf.UnknownFieldSet unknownFields) {
|
||||
return super.mergeUnknownFields(unknownFields);
|
||||
}
|
||||
|
||||
|
||||
// @@protoc_insertion_point(builder_scope:io.bkbn.kompendium.protobufjavaconverter.EnumMessage)
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(class_scope:io.bkbn.kompendium.protobufjavaconverter.EnumMessage)
|
||||
private static final io.bkbn.kompendium.protobufjavaconverter.EnumMessage DEFAULT_INSTANCE;
|
||||
static {
|
||||
DEFAULT_INSTANCE = new io.bkbn.kompendium.protobufjavaconverter.EnumMessage();
|
||||
}
|
||||
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.EnumMessage getDefaultInstance() {
|
||||
return DEFAULT_INSTANCE;
|
||||
}
|
||||
|
||||
private static final com.google.protobuf.Parser<EnumMessage>
|
||||
PARSER = new com.google.protobuf.AbstractParser<EnumMessage>() {
|
||||
@java.lang.Override
|
||||
public EnumMessage parsePartialFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return new EnumMessage(input, extensionRegistry);
|
||||
}
|
||||
};
|
||||
|
||||
public static com.google.protobuf.Parser<EnumMessage> parser() {
|
||||
return PARSER;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.Parser<EnumMessage> getParserForType() {
|
||||
return PARSER;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.EnumMessage getDefaultInstanceForType() {
|
||||
return DEFAULT_INSTANCE;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,20 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: io/bkbn/kompendium/protobufjavaconverter/converters/test.proto
|
||||
|
||||
package io.bkbn.kompendium.protobufjavaconverter;
|
||||
|
||||
public interface EnumMessageOrBuilder extends
|
||||
// @@protoc_insertion_point(interface_extends:io.bkbn.kompendium.protobufjavaconverter.EnumMessage)
|
||||
com.google.protobuf.MessageOrBuilder {
|
||||
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.Corpus corpus = 1;</code>
|
||||
* @return The enum numeric value on the wire for corpus.
|
||||
*/
|
||||
int getCorpusValue();
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.Corpus corpus = 1;</code>
|
||||
* @return The corpus.
|
||||
*/
|
||||
io.bkbn.kompendium.protobufjavaconverter.Corpus getCorpus();
|
||||
}
|
@ -0,0 +1,843 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: io/bkbn/kompendium/protobufjavaconverter/converters/test.proto
|
||||
|
||||
package io.bkbn.kompendium.protobufjavaconverter;
|
||||
|
||||
/**
|
||||
* Protobuf type {@code io.bkbn.kompendium.protobufjavaconverter.GoogleTypes}
|
||||
*/
|
||||
public final class GoogleTypes extends
|
||||
com.google.protobuf.GeneratedMessageV3 implements
|
||||
// @@protoc_insertion_point(message_implements:io.bkbn.kompendium.protobufjavaconverter.GoogleTypes)
|
||||
GoogleTypesOrBuilder {
|
||||
private static final long serialVersionUID = 0L;
|
||||
// Use GoogleTypes.newBuilder() to construct.
|
||||
private GoogleTypes(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
|
||||
super(builder);
|
||||
}
|
||||
private GoogleTypes() {
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
@SuppressWarnings({"unused"})
|
||||
protected java.lang.Object newInstance(
|
||||
UnusedPrivateParameter unused) {
|
||||
return new GoogleTypes();
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public final com.google.protobuf.UnknownFieldSet
|
||||
getUnknownFields() {
|
||||
return this.unknownFields;
|
||||
}
|
||||
private GoogleTypes(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
this();
|
||||
if (extensionRegistry == null) {
|
||||
throw new java.lang.NullPointerException();
|
||||
}
|
||||
com.google.protobuf.UnknownFieldSet.Builder unknownFields =
|
||||
com.google.protobuf.UnknownFieldSet.newBuilder();
|
||||
try {
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
int tag = input.readTag();
|
||||
switch (tag) {
|
||||
case 0:
|
||||
done = true;
|
||||
break;
|
||||
case 10: {
|
||||
com.google.protobuf.Timestamp.Builder subBuilder = null;
|
||||
if (timestampField_ != null) {
|
||||
subBuilder = timestampField_.toBuilder();
|
||||
}
|
||||
timestampField_ = input.readMessage(com.google.protobuf.Timestamp.parser(), extensionRegistry);
|
||||
if (subBuilder != null) {
|
||||
subBuilder.mergeFrom(timestampField_);
|
||||
timestampField_ = subBuilder.buildPartial();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 18: {
|
||||
com.google.protobuf.Duration.Builder subBuilder = null;
|
||||
if (durationField_ != null) {
|
||||
subBuilder = durationField_.toBuilder();
|
||||
}
|
||||
durationField_ = input.readMessage(com.google.protobuf.Duration.parser(), extensionRegistry);
|
||||
if (subBuilder != null) {
|
||||
subBuilder.mergeFrom(durationField_);
|
||||
durationField_ = subBuilder.buildPartial();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
if (!parseUnknownField(
|
||||
input, unknownFields, extensionRegistry, tag)) {
|
||||
done = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
||||
throw e.setUnfinishedMessage(this);
|
||||
} catch (java.io.IOException e) {
|
||||
throw new com.google.protobuf.InvalidProtocolBufferException(
|
||||
e).setUnfinishedMessage(this);
|
||||
} finally {
|
||||
this.unknownFields = unknownFields.build();
|
||||
makeExtensionsImmutable();
|
||||
}
|
||||
}
|
||||
public static final com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptor() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_GoogleTypes_descriptor;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internalGetFieldAccessorTable() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_GoogleTypes_fieldAccessorTable
|
||||
.ensureFieldAccessorsInitialized(
|
||||
io.bkbn.kompendium.protobufjavaconverter.GoogleTypes.class, io.bkbn.kompendium.protobufjavaconverter.GoogleTypes.Builder.class);
|
||||
}
|
||||
|
||||
public static final int TIMESTAMP_FIELD_FIELD_NUMBER = 1;
|
||||
private com.google.protobuf.Timestamp timestampField_;
|
||||
/**
|
||||
* <code>.google.protobuf.Timestamp timestamp_field = 1;</code>
|
||||
* @return Whether the timestampField field is set.
|
||||
*/
|
||||
@java.lang.Override
|
||||
public boolean hasTimestampField() {
|
||||
return timestampField_ != null;
|
||||
}
|
||||
/**
|
||||
* <code>.google.protobuf.Timestamp timestamp_field = 1;</code>
|
||||
* @return The timestampField.
|
||||
*/
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.Timestamp getTimestampField() {
|
||||
return timestampField_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : timestampField_;
|
||||
}
|
||||
/**
|
||||
* <code>.google.protobuf.Timestamp timestamp_field = 1;</code>
|
||||
*/
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.TimestampOrBuilder getTimestampFieldOrBuilder() {
|
||||
return getTimestampField();
|
||||
}
|
||||
|
||||
public static final int DURATION_FIELD_FIELD_NUMBER = 2;
|
||||
private com.google.protobuf.Duration durationField_;
|
||||
/**
|
||||
* <pre>
|
||||
* TODO value types
|
||||
* </pre>
|
||||
*
|
||||
* <code>.google.protobuf.Duration duration_field = 2;</code>
|
||||
* @return Whether the durationField field is set.
|
||||
*/
|
||||
@java.lang.Override
|
||||
public boolean hasDurationField() {
|
||||
return durationField_ != null;
|
||||
}
|
||||
/**
|
||||
* <pre>
|
||||
* TODO value types
|
||||
* </pre>
|
||||
*
|
||||
* <code>.google.protobuf.Duration duration_field = 2;</code>
|
||||
* @return The durationField.
|
||||
*/
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.Duration getDurationField() {
|
||||
return durationField_ == null ? com.google.protobuf.Duration.getDefaultInstance() : durationField_;
|
||||
}
|
||||
/**
|
||||
* <pre>
|
||||
* TODO value types
|
||||
* </pre>
|
||||
*
|
||||
* <code>.google.protobuf.Duration duration_field = 2;</code>
|
||||
*/
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.DurationOrBuilder getDurationFieldOrBuilder() {
|
||||
return getDurationField();
|
||||
}
|
||||
|
||||
private byte memoizedIsInitialized = -1;
|
||||
@java.lang.Override
|
||||
public final boolean isInitialized() {
|
||||
byte isInitialized = memoizedIsInitialized;
|
||||
if (isInitialized == 1) return true;
|
||||
if (isInitialized == 0) return false;
|
||||
|
||||
memoizedIsInitialized = 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public void writeTo(com.google.protobuf.CodedOutputStream output)
|
||||
throws java.io.IOException {
|
||||
if (timestampField_ != null) {
|
||||
output.writeMessage(1, getTimestampField());
|
||||
}
|
||||
if (durationField_ != null) {
|
||||
output.writeMessage(2, getDurationField());
|
||||
}
|
||||
unknownFields.writeTo(output);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public int getSerializedSize() {
|
||||
int size = memoizedSize;
|
||||
if (size != -1) return size;
|
||||
|
||||
size = 0;
|
||||
if (timestampField_ != null) {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeMessageSize(1, getTimestampField());
|
||||
}
|
||||
if (durationField_ != null) {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeMessageSize(2, getDurationField());
|
||||
}
|
||||
size += unknownFields.getSerializedSize();
|
||||
memoizedSize = size;
|
||||
return size;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public boolean equals(final java.lang.Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof io.bkbn.kompendium.protobufjavaconverter.GoogleTypes)) {
|
||||
return super.equals(obj);
|
||||
}
|
||||
io.bkbn.kompendium.protobufjavaconverter.GoogleTypes other = (io.bkbn.kompendium.protobufjavaconverter.GoogleTypes) obj;
|
||||
|
||||
if (hasTimestampField() != other.hasTimestampField()) return false;
|
||||
if (hasTimestampField()) {
|
||||
if (!getTimestampField()
|
||||
.equals(other.getTimestampField())) return false;
|
||||
}
|
||||
if (hasDurationField() != other.hasDurationField()) return false;
|
||||
if (hasDurationField()) {
|
||||
if (!getDurationField()
|
||||
.equals(other.getDurationField())) return false;
|
||||
}
|
||||
if (!unknownFields.equals(other.unknownFields)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public int hashCode() {
|
||||
if (memoizedHashCode != 0) {
|
||||
return memoizedHashCode;
|
||||
}
|
||||
int hash = 41;
|
||||
hash = (19 * hash) + getDescriptor().hashCode();
|
||||
if (hasTimestampField()) {
|
||||
hash = (37 * hash) + TIMESTAMP_FIELD_FIELD_NUMBER;
|
||||
hash = (53 * hash) + getTimestampField().hashCode();
|
||||
}
|
||||
if (hasDurationField()) {
|
||||
hash = (37 * hash) + DURATION_FIELD_FIELD_NUMBER;
|
||||
hash = (53 * hash) + getDurationField().hashCode();
|
||||
}
|
||||
hash = (29 * hash) + unknownFields.hashCode();
|
||||
memoizedHashCode = hash;
|
||||
return hash;
|
||||
}
|
||||
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.GoogleTypes parseFrom(
|
||||
java.nio.ByteBuffer data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.GoogleTypes parseFrom(
|
||||
java.nio.ByteBuffer data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.GoogleTypes parseFrom(
|
||||
com.google.protobuf.ByteString data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.GoogleTypes parseFrom(
|
||||
com.google.protobuf.ByteString data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.GoogleTypes parseFrom(byte[] data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.GoogleTypes parseFrom(
|
||||
byte[] data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.GoogleTypes parseFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.GoogleTypes parseFrom(
|
||||
java.io.InputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.GoogleTypes parseDelimitedFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseDelimitedWithIOException(PARSER, input);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.GoogleTypes parseDelimitedFrom(
|
||||
java.io.InputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseDelimitedWithIOException(PARSER, input, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.GoogleTypes parseFrom(
|
||||
com.google.protobuf.CodedInputStream input)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.GoogleTypes parseFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input, extensionRegistry);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder newBuilderForType() { return newBuilder(); }
|
||||
public static Builder newBuilder() {
|
||||
return DEFAULT_INSTANCE.toBuilder();
|
||||
}
|
||||
public static Builder newBuilder(io.bkbn.kompendium.protobufjavaconverter.GoogleTypes prototype) {
|
||||
return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder toBuilder() {
|
||||
return this == DEFAULT_INSTANCE
|
||||
? new Builder() : new Builder().mergeFrom(this);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected Builder newBuilderForType(
|
||||
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
|
||||
Builder builder = new Builder(parent);
|
||||
return builder;
|
||||
}
|
||||
/**
|
||||
* Protobuf type {@code io.bkbn.kompendium.protobufjavaconverter.GoogleTypes}
|
||||
*/
|
||||
public static final class Builder extends
|
||||
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
|
||||
// @@protoc_insertion_point(builder_implements:io.bkbn.kompendium.protobufjavaconverter.GoogleTypes)
|
||||
io.bkbn.kompendium.protobufjavaconverter.GoogleTypesOrBuilder {
|
||||
public static final com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptor() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_GoogleTypes_descriptor;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internalGetFieldAccessorTable() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_GoogleTypes_fieldAccessorTable
|
||||
.ensureFieldAccessorsInitialized(
|
||||
io.bkbn.kompendium.protobufjavaconverter.GoogleTypes.class, io.bkbn.kompendium.protobufjavaconverter.GoogleTypes.Builder.class);
|
||||
}
|
||||
|
||||
// Construct using io.bkbn.kompendium.protobufjavaconverter.GoogleTypes.newBuilder()
|
||||
private Builder() {
|
||||
maybeForceBuilderInitialization();
|
||||
}
|
||||
|
||||
private Builder(
|
||||
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
|
||||
super(parent);
|
||||
maybeForceBuilderInitialization();
|
||||
}
|
||||
private void maybeForceBuilderInitialization() {
|
||||
if (com.google.protobuf.GeneratedMessageV3
|
||||
.alwaysUseFieldBuilders) {
|
||||
}
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder clear() {
|
||||
super.clear();
|
||||
if (timestampFieldBuilder_ == null) {
|
||||
timestampField_ = null;
|
||||
} else {
|
||||
timestampField_ = null;
|
||||
timestampFieldBuilder_ = null;
|
||||
}
|
||||
if (durationFieldBuilder_ == null) {
|
||||
durationField_ = null;
|
||||
} else {
|
||||
durationField_ = null;
|
||||
durationFieldBuilder_ = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptorForType() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_GoogleTypes_descriptor;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.GoogleTypes getDefaultInstanceForType() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.GoogleTypes.getDefaultInstance();
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.GoogleTypes build() {
|
||||
io.bkbn.kompendium.protobufjavaconverter.GoogleTypes result = buildPartial();
|
||||
if (!result.isInitialized()) {
|
||||
throw newUninitializedMessageException(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.GoogleTypes buildPartial() {
|
||||
io.bkbn.kompendium.protobufjavaconverter.GoogleTypes result = new io.bkbn.kompendium.protobufjavaconverter.GoogleTypes(this);
|
||||
if (timestampFieldBuilder_ == null) {
|
||||
result.timestampField_ = timestampField_;
|
||||
} else {
|
||||
result.timestampField_ = timestampFieldBuilder_.build();
|
||||
}
|
||||
if (durationFieldBuilder_ == null) {
|
||||
result.durationField_ = durationField_;
|
||||
} else {
|
||||
result.durationField_ = durationFieldBuilder_.build();
|
||||
}
|
||||
onBuilt();
|
||||
return result;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder clone() {
|
||||
return super.clone();
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder setField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field,
|
||||
java.lang.Object value) {
|
||||
return super.setField(field, value);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder clearField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field) {
|
||||
return super.clearField(field);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder clearOneof(
|
||||
com.google.protobuf.Descriptors.OneofDescriptor oneof) {
|
||||
return super.clearOneof(oneof);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder setRepeatedField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field,
|
||||
int index, java.lang.Object value) {
|
||||
return super.setRepeatedField(field, index, value);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder addRepeatedField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field,
|
||||
java.lang.Object value) {
|
||||
return super.addRepeatedField(field, value);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder mergeFrom(com.google.protobuf.Message other) {
|
||||
if (other instanceof io.bkbn.kompendium.protobufjavaconverter.GoogleTypes) {
|
||||
return mergeFrom((io.bkbn.kompendium.protobufjavaconverter.GoogleTypes)other);
|
||||
} else {
|
||||
super.mergeFrom(other);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public Builder mergeFrom(io.bkbn.kompendium.protobufjavaconverter.GoogleTypes other) {
|
||||
if (other == io.bkbn.kompendium.protobufjavaconverter.GoogleTypes.getDefaultInstance()) return this;
|
||||
if (other.hasTimestampField()) {
|
||||
mergeTimestampField(other.getTimestampField());
|
||||
}
|
||||
if (other.hasDurationField()) {
|
||||
mergeDurationField(other.getDurationField());
|
||||
}
|
||||
this.mergeUnknownFields(other.unknownFields);
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public final boolean isInitialized() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder mergeFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
io.bkbn.kompendium.protobufjavaconverter.GoogleTypes parsedMessage = null;
|
||||
try {
|
||||
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
|
||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
||||
parsedMessage = (io.bkbn.kompendium.protobufjavaconverter.GoogleTypes) e.getUnfinishedMessage();
|
||||
throw e.unwrapIOException();
|
||||
} finally {
|
||||
if (parsedMessage != null) {
|
||||
mergeFrom(parsedMessage);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
private com.google.protobuf.Timestamp timestampField_;
|
||||
private com.google.protobuf.SingleFieldBuilderV3<
|
||||
com.google.protobuf.Timestamp, com.google.protobuf.Timestamp.Builder, com.google.protobuf.TimestampOrBuilder> timestampFieldBuilder_;
|
||||
/**
|
||||
* <code>.google.protobuf.Timestamp timestamp_field = 1;</code>
|
||||
* @return Whether the timestampField field is set.
|
||||
*/
|
||||
public boolean hasTimestampField() {
|
||||
return timestampFieldBuilder_ != null || timestampField_ != null;
|
||||
}
|
||||
/**
|
||||
* <code>.google.protobuf.Timestamp timestamp_field = 1;</code>
|
||||
* @return The timestampField.
|
||||
*/
|
||||
public com.google.protobuf.Timestamp getTimestampField() {
|
||||
if (timestampFieldBuilder_ == null) {
|
||||
return timestampField_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : timestampField_;
|
||||
} else {
|
||||
return timestampFieldBuilder_.getMessage();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <code>.google.protobuf.Timestamp timestamp_field = 1;</code>
|
||||
*/
|
||||
public Builder setTimestampField(com.google.protobuf.Timestamp value) {
|
||||
if (timestampFieldBuilder_ == null) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
timestampField_ = value;
|
||||
onChanged();
|
||||
} else {
|
||||
timestampFieldBuilder_.setMessage(value);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>.google.protobuf.Timestamp timestamp_field = 1;</code>
|
||||
*/
|
||||
public Builder setTimestampField(
|
||||
com.google.protobuf.Timestamp.Builder builderForValue) {
|
||||
if (timestampFieldBuilder_ == null) {
|
||||
timestampField_ = builderForValue.build();
|
||||
onChanged();
|
||||
} else {
|
||||
timestampFieldBuilder_.setMessage(builderForValue.build());
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>.google.protobuf.Timestamp timestamp_field = 1;</code>
|
||||
*/
|
||||
public Builder mergeTimestampField(com.google.protobuf.Timestamp value) {
|
||||
if (timestampFieldBuilder_ == null) {
|
||||
if (timestampField_ != null) {
|
||||
timestampField_ =
|
||||
com.google.protobuf.Timestamp.newBuilder(timestampField_).mergeFrom(value).buildPartial();
|
||||
} else {
|
||||
timestampField_ = value;
|
||||
}
|
||||
onChanged();
|
||||
} else {
|
||||
timestampFieldBuilder_.mergeFrom(value);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>.google.protobuf.Timestamp timestamp_field = 1;</code>
|
||||
*/
|
||||
public Builder clearTimestampField() {
|
||||
if (timestampFieldBuilder_ == null) {
|
||||
timestampField_ = null;
|
||||
onChanged();
|
||||
} else {
|
||||
timestampField_ = null;
|
||||
timestampFieldBuilder_ = null;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>.google.protobuf.Timestamp timestamp_field = 1;</code>
|
||||
*/
|
||||
public com.google.protobuf.Timestamp.Builder getTimestampFieldBuilder() {
|
||||
|
||||
onChanged();
|
||||
return getTimestampFieldFieldBuilder().getBuilder();
|
||||
}
|
||||
/**
|
||||
* <code>.google.protobuf.Timestamp timestamp_field = 1;</code>
|
||||
*/
|
||||
public com.google.protobuf.TimestampOrBuilder getTimestampFieldOrBuilder() {
|
||||
if (timestampFieldBuilder_ != null) {
|
||||
return timestampFieldBuilder_.getMessageOrBuilder();
|
||||
} else {
|
||||
return timestampField_ == null ?
|
||||
com.google.protobuf.Timestamp.getDefaultInstance() : timestampField_;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <code>.google.protobuf.Timestamp timestamp_field = 1;</code>
|
||||
*/
|
||||
private com.google.protobuf.SingleFieldBuilderV3<
|
||||
com.google.protobuf.Timestamp, com.google.protobuf.Timestamp.Builder, com.google.protobuf.TimestampOrBuilder>
|
||||
getTimestampFieldFieldBuilder() {
|
||||
if (timestampFieldBuilder_ == null) {
|
||||
timestampFieldBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
|
||||
com.google.protobuf.Timestamp, com.google.protobuf.Timestamp.Builder, com.google.protobuf.TimestampOrBuilder>(
|
||||
getTimestampField(),
|
||||
getParentForChildren(),
|
||||
isClean());
|
||||
timestampField_ = null;
|
||||
}
|
||||
return timestampFieldBuilder_;
|
||||
}
|
||||
|
||||
private com.google.protobuf.Duration durationField_;
|
||||
private com.google.protobuf.SingleFieldBuilderV3<
|
||||
com.google.protobuf.Duration, com.google.protobuf.Duration.Builder, com.google.protobuf.DurationOrBuilder> durationFieldBuilder_;
|
||||
/**
|
||||
* <pre>
|
||||
* TODO value types
|
||||
* </pre>
|
||||
*
|
||||
* <code>.google.protobuf.Duration duration_field = 2;</code>
|
||||
* @return Whether the durationField field is set.
|
||||
*/
|
||||
public boolean hasDurationField() {
|
||||
return durationFieldBuilder_ != null || durationField_ != null;
|
||||
}
|
||||
/**
|
||||
* <pre>
|
||||
* TODO value types
|
||||
* </pre>
|
||||
*
|
||||
* <code>.google.protobuf.Duration duration_field = 2;</code>
|
||||
* @return The durationField.
|
||||
*/
|
||||
public com.google.protobuf.Duration getDurationField() {
|
||||
if (durationFieldBuilder_ == null) {
|
||||
return durationField_ == null ? com.google.protobuf.Duration.getDefaultInstance() : durationField_;
|
||||
} else {
|
||||
return durationFieldBuilder_.getMessage();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <pre>
|
||||
* TODO value types
|
||||
* </pre>
|
||||
*
|
||||
* <code>.google.protobuf.Duration duration_field = 2;</code>
|
||||
*/
|
||||
public Builder setDurationField(com.google.protobuf.Duration value) {
|
||||
if (durationFieldBuilder_ == null) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
durationField_ = value;
|
||||
onChanged();
|
||||
} else {
|
||||
durationFieldBuilder_.setMessage(value);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <pre>
|
||||
* TODO value types
|
||||
* </pre>
|
||||
*
|
||||
* <code>.google.protobuf.Duration duration_field = 2;</code>
|
||||
*/
|
||||
public Builder setDurationField(
|
||||
com.google.protobuf.Duration.Builder builderForValue) {
|
||||
if (durationFieldBuilder_ == null) {
|
||||
durationField_ = builderForValue.build();
|
||||
onChanged();
|
||||
} else {
|
||||
durationFieldBuilder_.setMessage(builderForValue.build());
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <pre>
|
||||
* TODO value types
|
||||
* </pre>
|
||||
*
|
||||
* <code>.google.protobuf.Duration duration_field = 2;</code>
|
||||
*/
|
||||
public Builder mergeDurationField(com.google.protobuf.Duration value) {
|
||||
if (durationFieldBuilder_ == null) {
|
||||
if (durationField_ != null) {
|
||||
durationField_ =
|
||||
com.google.protobuf.Duration.newBuilder(durationField_).mergeFrom(value).buildPartial();
|
||||
} else {
|
||||
durationField_ = value;
|
||||
}
|
||||
onChanged();
|
||||
} else {
|
||||
durationFieldBuilder_.mergeFrom(value);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <pre>
|
||||
* TODO value types
|
||||
* </pre>
|
||||
*
|
||||
* <code>.google.protobuf.Duration duration_field = 2;</code>
|
||||
*/
|
||||
public Builder clearDurationField() {
|
||||
if (durationFieldBuilder_ == null) {
|
||||
durationField_ = null;
|
||||
onChanged();
|
||||
} else {
|
||||
durationField_ = null;
|
||||
durationFieldBuilder_ = null;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <pre>
|
||||
* TODO value types
|
||||
* </pre>
|
||||
*
|
||||
* <code>.google.protobuf.Duration duration_field = 2;</code>
|
||||
*/
|
||||
public com.google.protobuf.Duration.Builder getDurationFieldBuilder() {
|
||||
|
||||
onChanged();
|
||||
return getDurationFieldFieldBuilder().getBuilder();
|
||||
}
|
||||
/**
|
||||
* <pre>
|
||||
* TODO value types
|
||||
* </pre>
|
||||
*
|
||||
* <code>.google.protobuf.Duration duration_field = 2;</code>
|
||||
*/
|
||||
public com.google.protobuf.DurationOrBuilder getDurationFieldOrBuilder() {
|
||||
if (durationFieldBuilder_ != null) {
|
||||
return durationFieldBuilder_.getMessageOrBuilder();
|
||||
} else {
|
||||
return durationField_ == null ?
|
||||
com.google.protobuf.Duration.getDefaultInstance() : durationField_;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <pre>
|
||||
* TODO value types
|
||||
* </pre>
|
||||
*
|
||||
* <code>.google.protobuf.Duration duration_field = 2;</code>
|
||||
*/
|
||||
private com.google.protobuf.SingleFieldBuilderV3<
|
||||
com.google.protobuf.Duration, com.google.protobuf.Duration.Builder, com.google.protobuf.DurationOrBuilder>
|
||||
getDurationFieldFieldBuilder() {
|
||||
if (durationFieldBuilder_ == null) {
|
||||
durationFieldBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
|
||||
com.google.protobuf.Duration, com.google.protobuf.Duration.Builder, com.google.protobuf.DurationOrBuilder>(
|
||||
getDurationField(),
|
||||
getParentForChildren(),
|
||||
isClean());
|
||||
durationField_ = null;
|
||||
}
|
||||
return durationFieldBuilder_;
|
||||
}
|
||||
@java.lang.Override
|
||||
public final Builder setUnknownFields(
|
||||
final com.google.protobuf.UnknownFieldSet unknownFields) {
|
||||
return super.setUnknownFields(unknownFields);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public final Builder mergeUnknownFields(
|
||||
final com.google.protobuf.UnknownFieldSet unknownFields) {
|
||||
return super.mergeUnknownFields(unknownFields);
|
||||
}
|
||||
|
||||
|
||||
// @@protoc_insertion_point(builder_scope:io.bkbn.kompendium.protobufjavaconverter.GoogleTypes)
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(class_scope:io.bkbn.kompendium.protobufjavaconverter.GoogleTypes)
|
||||
private static final io.bkbn.kompendium.protobufjavaconverter.GoogleTypes DEFAULT_INSTANCE;
|
||||
static {
|
||||
DEFAULT_INSTANCE = new io.bkbn.kompendium.protobufjavaconverter.GoogleTypes();
|
||||
}
|
||||
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.GoogleTypes getDefaultInstance() {
|
||||
return DEFAULT_INSTANCE;
|
||||
}
|
||||
|
||||
private static final com.google.protobuf.Parser<GoogleTypes>
|
||||
PARSER = new com.google.protobuf.AbstractParser<GoogleTypes>() {
|
||||
@java.lang.Override
|
||||
public GoogleTypes parsePartialFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return new GoogleTypes(input, extensionRegistry);
|
||||
}
|
||||
};
|
||||
|
||||
public static com.google.protobuf.Parser<GoogleTypes> parser() {
|
||||
return PARSER;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.Parser<GoogleTypes> getParserForType() {
|
||||
return PARSER;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.GoogleTypes getDefaultInstanceForType() {
|
||||
return DEFAULT_INSTANCE;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,51 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: io/bkbn/kompendium/protobufjavaconverter/converters/test.proto
|
||||
|
||||
package io.bkbn.kompendium.protobufjavaconverter;
|
||||
|
||||
public interface GoogleTypesOrBuilder extends
|
||||
// @@protoc_insertion_point(interface_extends:io.bkbn.kompendium.protobufjavaconverter.GoogleTypes)
|
||||
com.google.protobuf.MessageOrBuilder {
|
||||
|
||||
/**
|
||||
* <code>.google.protobuf.Timestamp timestamp_field = 1;</code>
|
||||
* @return Whether the timestampField field is set.
|
||||
*/
|
||||
boolean hasTimestampField();
|
||||
/**
|
||||
* <code>.google.protobuf.Timestamp timestamp_field = 1;</code>
|
||||
* @return The timestampField.
|
||||
*/
|
||||
com.google.protobuf.Timestamp getTimestampField();
|
||||
/**
|
||||
* <code>.google.protobuf.Timestamp timestamp_field = 1;</code>
|
||||
*/
|
||||
com.google.protobuf.TimestampOrBuilder getTimestampFieldOrBuilder();
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* TODO value types
|
||||
* </pre>
|
||||
*
|
||||
* <code>.google.protobuf.Duration duration_field = 2;</code>
|
||||
* @return Whether the durationField field is set.
|
||||
*/
|
||||
boolean hasDurationField();
|
||||
/**
|
||||
* <pre>
|
||||
* TODO value types
|
||||
* </pre>
|
||||
*
|
||||
* <code>.google.protobuf.Duration duration_field = 2;</code>
|
||||
* @return The durationField.
|
||||
*/
|
||||
com.google.protobuf.Duration getDurationField();
|
||||
/**
|
||||
* <pre>
|
||||
* TODO value types
|
||||
* </pre>
|
||||
*
|
||||
* <code>.google.protobuf.Duration duration_field = 2;</code>
|
||||
*/
|
||||
com.google.protobuf.DurationOrBuilder getDurationFieldOrBuilder();
|
||||
}
|
@ -0,0 +1,705 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: io/bkbn/kompendium/protobufjavaconverter/converters/test.proto
|
||||
|
||||
package io.bkbn.kompendium.protobufjavaconverter;
|
||||
|
||||
/**
|
||||
* Protobuf type {@code io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage}
|
||||
*/
|
||||
public final class NestedMapMessage extends
|
||||
com.google.protobuf.GeneratedMessageV3 implements
|
||||
// @@protoc_insertion_point(message_implements:io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage)
|
||||
NestedMapMessageOrBuilder {
|
||||
private static final long serialVersionUID = 0L;
|
||||
// Use NestedMapMessage.newBuilder() to construct.
|
||||
private NestedMapMessage(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
|
||||
super(builder);
|
||||
}
|
||||
private NestedMapMessage() {
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
@SuppressWarnings({"unused"})
|
||||
protected java.lang.Object newInstance(
|
||||
UnusedPrivateParameter unused) {
|
||||
return new NestedMapMessage();
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public final com.google.protobuf.UnknownFieldSet
|
||||
getUnknownFields() {
|
||||
return this.unknownFields;
|
||||
}
|
||||
private NestedMapMessage(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
this();
|
||||
if (extensionRegistry == null) {
|
||||
throw new java.lang.NullPointerException();
|
||||
}
|
||||
int mutable_bitField0_ = 0;
|
||||
com.google.protobuf.UnknownFieldSet.Builder unknownFields =
|
||||
com.google.protobuf.UnknownFieldSet.newBuilder();
|
||||
try {
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
int tag = input.readTag();
|
||||
switch (tag) {
|
||||
case 0:
|
||||
done = true;
|
||||
break;
|
||||
case 10: {
|
||||
if (!((mutable_bitField0_ & 0x00000001) != 0)) {
|
||||
mapField_ = com.google.protobuf.MapField.newMapField(
|
||||
MapFieldDefaultEntryHolder.defaultEntry);
|
||||
mutable_bitField0_ |= 0x00000001;
|
||||
}
|
||||
com.google.protobuf.MapEntry<java.lang.String, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage>
|
||||
mapField__ = input.readMessage(
|
||||
MapFieldDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry);
|
||||
mapField_.getMutableMap().put(
|
||||
mapField__.getKey(), mapField__.getValue());
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
if (!parseUnknownField(
|
||||
input, unknownFields, extensionRegistry, tag)) {
|
||||
done = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
||||
throw e.setUnfinishedMessage(this);
|
||||
} catch (java.io.IOException e) {
|
||||
throw new com.google.protobuf.InvalidProtocolBufferException(
|
||||
e).setUnfinishedMessage(this);
|
||||
} finally {
|
||||
this.unknownFields = unknownFields.build();
|
||||
makeExtensionsImmutable();
|
||||
}
|
||||
}
|
||||
public static final com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptor() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_NestedMapMessage_descriptor;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"rawtypes"})
|
||||
@java.lang.Override
|
||||
protected com.google.protobuf.MapField internalGetMapField(
|
||||
int number) {
|
||||
switch (number) {
|
||||
case 1:
|
||||
return internalGetMapField();
|
||||
default:
|
||||
throw new RuntimeException(
|
||||
"Invalid map field number: " + number);
|
||||
}
|
||||
}
|
||||
@java.lang.Override
|
||||
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internalGetFieldAccessorTable() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_NestedMapMessage_fieldAccessorTable
|
||||
.ensureFieldAccessorsInitialized(
|
||||
io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage.class, io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage.Builder.class);
|
||||
}
|
||||
|
||||
public static final int MAP_FIELD_FIELD_NUMBER = 1;
|
||||
private static final class MapFieldDefaultEntryHolder {
|
||||
static final com.google.protobuf.MapEntry<
|
||||
java.lang.String, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> defaultEntry =
|
||||
com.google.protobuf.MapEntry
|
||||
.<java.lang.String, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage>newDefaultInstance(
|
||||
io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_NestedMapMessage_MapFieldEntry_descriptor,
|
||||
com.google.protobuf.WireFormat.FieldType.STRING,
|
||||
"",
|
||||
com.google.protobuf.WireFormat.FieldType.MESSAGE,
|
||||
io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage.getDefaultInstance());
|
||||
}
|
||||
private com.google.protobuf.MapField<
|
||||
java.lang.String, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> mapField_;
|
||||
private com.google.protobuf.MapField<java.lang.String, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage>
|
||||
internalGetMapField() {
|
||||
if (mapField_ == null) {
|
||||
return com.google.protobuf.MapField.emptyMapField(
|
||||
MapFieldDefaultEntryHolder.defaultEntry);
|
||||
}
|
||||
return mapField_;
|
||||
}
|
||||
|
||||
public int getMapFieldCount() {
|
||||
return internalGetMapField().getMap().size();
|
||||
}
|
||||
/**
|
||||
* <code>map<string, .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> map_field = 1;</code>
|
||||
*/
|
||||
|
||||
@java.lang.Override
|
||||
public boolean containsMapField(
|
||||
java.lang.String key) {
|
||||
if (key == null) { throw new java.lang.NullPointerException(); }
|
||||
return internalGetMapField().getMap().containsKey(key);
|
||||
}
|
||||
/**
|
||||
* Use {@link #getMapFieldMap()} instead.
|
||||
*/
|
||||
@java.lang.Override
|
||||
@java.lang.Deprecated
|
||||
public java.util.Map<java.lang.String, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> getMapField() {
|
||||
return getMapFieldMap();
|
||||
}
|
||||
/**
|
||||
* <code>map<string, .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> map_field = 1;</code>
|
||||
*/
|
||||
@java.lang.Override
|
||||
|
||||
public java.util.Map<java.lang.String, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> getMapFieldMap() {
|
||||
return internalGetMapField().getMap();
|
||||
}
|
||||
/**
|
||||
* <code>map<string, .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> map_field = 1;</code>
|
||||
*/
|
||||
@java.lang.Override
|
||||
|
||||
public io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage getMapFieldOrDefault(
|
||||
java.lang.String key,
|
||||
io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage defaultValue) {
|
||||
if (key == null) { throw new java.lang.NullPointerException(); }
|
||||
java.util.Map<java.lang.String, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> map =
|
||||
internalGetMapField().getMap();
|
||||
return map.containsKey(key) ? map.get(key) : defaultValue;
|
||||
}
|
||||
/**
|
||||
* <code>map<string, .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> map_field = 1;</code>
|
||||
*/
|
||||
@java.lang.Override
|
||||
|
||||
public io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage getMapFieldOrThrow(
|
||||
java.lang.String key) {
|
||||
if (key == null) { throw new java.lang.NullPointerException(); }
|
||||
java.util.Map<java.lang.String, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> map =
|
||||
internalGetMapField().getMap();
|
||||
if (!map.containsKey(key)) {
|
||||
throw new java.lang.IllegalArgumentException();
|
||||
}
|
||||
return map.get(key);
|
||||
}
|
||||
|
||||
private byte memoizedIsInitialized = -1;
|
||||
@java.lang.Override
|
||||
public final boolean isInitialized() {
|
||||
byte isInitialized = memoizedIsInitialized;
|
||||
if (isInitialized == 1) return true;
|
||||
if (isInitialized == 0) return false;
|
||||
|
||||
memoizedIsInitialized = 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public void writeTo(com.google.protobuf.CodedOutputStream output)
|
||||
throws java.io.IOException {
|
||||
com.google.protobuf.GeneratedMessageV3
|
||||
.serializeStringMapTo(
|
||||
output,
|
||||
internalGetMapField(),
|
||||
MapFieldDefaultEntryHolder.defaultEntry,
|
||||
1);
|
||||
unknownFields.writeTo(output);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public int getSerializedSize() {
|
||||
int size = memoizedSize;
|
||||
if (size != -1) return size;
|
||||
|
||||
size = 0;
|
||||
for (java.util.Map.Entry<java.lang.String, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> entry
|
||||
: internalGetMapField().getMap().entrySet()) {
|
||||
com.google.protobuf.MapEntry<java.lang.String, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage>
|
||||
mapField__ = MapFieldDefaultEntryHolder.defaultEntry.newBuilderForType()
|
||||
.setKey(entry.getKey())
|
||||
.setValue(entry.getValue())
|
||||
.build();
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeMessageSize(1, mapField__);
|
||||
}
|
||||
size += unknownFields.getSerializedSize();
|
||||
memoizedSize = size;
|
||||
return size;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public boolean equals(final java.lang.Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage)) {
|
||||
return super.equals(obj);
|
||||
}
|
||||
io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage other = (io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage) obj;
|
||||
|
||||
if (!internalGetMapField().equals(
|
||||
other.internalGetMapField())) return false;
|
||||
if (!unknownFields.equals(other.unknownFields)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public int hashCode() {
|
||||
if (memoizedHashCode != 0) {
|
||||
return memoizedHashCode;
|
||||
}
|
||||
int hash = 41;
|
||||
hash = (19 * hash) + getDescriptor().hashCode();
|
||||
if (!internalGetMapField().getMap().isEmpty()) {
|
||||
hash = (37 * hash) + MAP_FIELD_FIELD_NUMBER;
|
||||
hash = (53 * hash) + internalGetMapField().hashCode();
|
||||
}
|
||||
hash = (29 * hash) + unknownFields.hashCode();
|
||||
memoizedHashCode = hash;
|
||||
return hash;
|
||||
}
|
||||
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage parseFrom(
|
||||
java.nio.ByteBuffer data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage parseFrom(
|
||||
java.nio.ByteBuffer data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage parseFrom(
|
||||
com.google.protobuf.ByteString data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage parseFrom(
|
||||
com.google.protobuf.ByteString data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage parseFrom(byte[] data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage parseFrom(
|
||||
byte[] data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage parseFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage parseFrom(
|
||||
java.io.InputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage parseDelimitedFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseDelimitedWithIOException(PARSER, input);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage parseDelimitedFrom(
|
||||
java.io.InputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseDelimitedWithIOException(PARSER, input, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage parseFrom(
|
||||
com.google.protobuf.CodedInputStream input)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage parseFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input, extensionRegistry);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder newBuilderForType() { return newBuilder(); }
|
||||
public static Builder newBuilder() {
|
||||
return DEFAULT_INSTANCE.toBuilder();
|
||||
}
|
||||
public static Builder newBuilder(io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage prototype) {
|
||||
return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder toBuilder() {
|
||||
return this == DEFAULT_INSTANCE
|
||||
? new Builder() : new Builder().mergeFrom(this);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected Builder newBuilderForType(
|
||||
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
|
||||
Builder builder = new Builder(parent);
|
||||
return builder;
|
||||
}
|
||||
/**
|
||||
* Protobuf type {@code io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage}
|
||||
*/
|
||||
public static final class Builder extends
|
||||
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
|
||||
// @@protoc_insertion_point(builder_implements:io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage)
|
||||
io.bkbn.kompendium.protobufjavaconverter.NestedMapMessageOrBuilder {
|
||||
public static final com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptor() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_NestedMapMessage_descriptor;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"rawtypes"})
|
||||
protected com.google.protobuf.MapField internalGetMapField(
|
||||
int number) {
|
||||
switch (number) {
|
||||
case 1:
|
||||
return internalGetMapField();
|
||||
default:
|
||||
throw new RuntimeException(
|
||||
"Invalid map field number: " + number);
|
||||
}
|
||||
}
|
||||
@SuppressWarnings({"rawtypes"})
|
||||
protected com.google.protobuf.MapField internalGetMutableMapField(
|
||||
int number) {
|
||||
switch (number) {
|
||||
case 1:
|
||||
return internalGetMutableMapField();
|
||||
default:
|
||||
throw new RuntimeException(
|
||||
"Invalid map field number: " + number);
|
||||
}
|
||||
}
|
||||
@java.lang.Override
|
||||
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internalGetFieldAccessorTable() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_NestedMapMessage_fieldAccessorTable
|
||||
.ensureFieldAccessorsInitialized(
|
||||
io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage.class, io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage.Builder.class);
|
||||
}
|
||||
|
||||
// Construct using io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage.newBuilder()
|
||||
private Builder() {
|
||||
maybeForceBuilderInitialization();
|
||||
}
|
||||
|
||||
private Builder(
|
||||
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
|
||||
super(parent);
|
||||
maybeForceBuilderInitialization();
|
||||
}
|
||||
private void maybeForceBuilderInitialization() {
|
||||
if (com.google.protobuf.GeneratedMessageV3
|
||||
.alwaysUseFieldBuilders) {
|
||||
}
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder clear() {
|
||||
super.clear();
|
||||
internalGetMutableMapField().clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptorForType() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_NestedMapMessage_descriptor;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage getDefaultInstanceForType() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage.getDefaultInstance();
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage build() {
|
||||
io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage result = buildPartial();
|
||||
if (!result.isInitialized()) {
|
||||
throw newUninitializedMessageException(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage buildPartial() {
|
||||
io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage result = new io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage(this);
|
||||
int from_bitField0_ = bitField0_;
|
||||
result.mapField_ = internalGetMapField();
|
||||
result.mapField_.makeImmutable();
|
||||
onBuilt();
|
||||
return result;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder clone() {
|
||||
return super.clone();
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder setField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field,
|
||||
java.lang.Object value) {
|
||||
return super.setField(field, value);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder clearField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field) {
|
||||
return super.clearField(field);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder clearOneof(
|
||||
com.google.protobuf.Descriptors.OneofDescriptor oneof) {
|
||||
return super.clearOneof(oneof);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder setRepeatedField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field,
|
||||
int index, java.lang.Object value) {
|
||||
return super.setRepeatedField(field, index, value);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder addRepeatedField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field,
|
||||
java.lang.Object value) {
|
||||
return super.addRepeatedField(field, value);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder mergeFrom(com.google.protobuf.Message other) {
|
||||
if (other instanceof io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage) {
|
||||
return mergeFrom((io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage)other);
|
||||
} else {
|
||||
super.mergeFrom(other);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public Builder mergeFrom(io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage other) {
|
||||
if (other == io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage.getDefaultInstance()) return this;
|
||||
internalGetMutableMapField().mergeFrom(
|
||||
other.internalGetMapField());
|
||||
this.mergeUnknownFields(other.unknownFields);
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public final boolean isInitialized() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder mergeFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage parsedMessage = null;
|
||||
try {
|
||||
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
|
||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
||||
parsedMessage = (io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage) e.getUnfinishedMessage();
|
||||
throw e.unwrapIOException();
|
||||
} finally {
|
||||
if (parsedMessage != null) {
|
||||
mergeFrom(parsedMessage);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
private int bitField0_;
|
||||
|
||||
private com.google.protobuf.MapField<
|
||||
java.lang.String, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> mapField_;
|
||||
private com.google.protobuf.MapField<java.lang.String, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage>
|
||||
internalGetMapField() {
|
||||
if (mapField_ == null) {
|
||||
return com.google.protobuf.MapField.emptyMapField(
|
||||
MapFieldDefaultEntryHolder.defaultEntry);
|
||||
}
|
||||
return mapField_;
|
||||
}
|
||||
private com.google.protobuf.MapField<java.lang.String, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage>
|
||||
internalGetMutableMapField() {
|
||||
onChanged();;
|
||||
if (mapField_ == null) {
|
||||
mapField_ = com.google.protobuf.MapField.newMapField(
|
||||
MapFieldDefaultEntryHolder.defaultEntry);
|
||||
}
|
||||
if (!mapField_.isMutable()) {
|
||||
mapField_ = mapField_.copy();
|
||||
}
|
||||
return mapField_;
|
||||
}
|
||||
|
||||
public int getMapFieldCount() {
|
||||
return internalGetMapField().getMap().size();
|
||||
}
|
||||
/**
|
||||
* <code>map<string, .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> map_field = 1;</code>
|
||||
*/
|
||||
|
||||
@java.lang.Override
|
||||
public boolean containsMapField(
|
||||
java.lang.String key) {
|
||||
if (key == null) { throw new java.lang.NullPointerException(); }
|
||||
return internalGetMapField().getMap().containsKey(key);
|
||||
}
|
||||
/**
|
||||
* Use {@link #getMapFieldMap()} instead.
|
||||
*/
|
||||
@java.lang.Override
|
||||
@java.lang.Deprecated
|
||||
public java.util.Map<java.lang.String, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> getMapField() {
|
||||
return getMapFieldMap();
|
||||
}
|
||||
/**
|
||||
* <code>map<string, .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> map_field = 1;</code>
|
||||
*/
|
||||
@java.lang.Override
|
||||
|
||||
public java.util.Map<java.lang.String, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> getMapFieldMap() {
|
||||
return internalGetMapField().getMap();
|
||||
}
|
||||
/**
|
||||
* <code>map<string, .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> map_field = 1;</code>
|
||||
*/
|
||||
@java.lang.Override
|
||||
|
||||
public io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage getMapFieldOrDefault(
|
||||
java.lang.String key,
|
||||
io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage defaultValue) {
|
||||
if (key == null) { throw new java.lang.NullPointerException(); }
|
||||
java.util.Map<java.lang.String, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> map =
|
||||
internalGetMapField().getMap();
|
||||
return map.containsKey(key) ? map.get(key) : defaultValue;
|
||||
}
|
||||
/**
|
||||
* <code>map<string, .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> map_field = 1;</code>
|
||||
*/
|
||||
@java.lang.Override
|
||||
|
||||
public io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage getMapFieldOrThrow(
|
||||
java.lang.String key) {
|
||||
if (key == null) { throw new java.lang.NullPointerException(); }
|
||||
java.util.Map<java.lang.String, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> map =
|
||||
internalGetMapField().getMap();
|
||||
if (!map.containsKey(key)) {
|
||||
throw new java.lang.IllegalArgumentException();
|
||||
}
|
||||
return map.get(key);
|
||||
}
|
||||
|
||||
public Builder clearMapField() {
|
||||
internalGetMutableMapField().getMutableMap()
|
||||
.clear();
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>map<string, .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> map_field = 1;</code>
|
||||
*/
|
||||
|
||||
public Builder removeMapField(
|
||||
java.lang.String key) {
|
||||
if (key == null) { throw new java.lang.NullPointerException(); }
|
||||
internalGetMutableMapField().getMutableMap()
|
||||
.remove(key);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Use alternate mutation accessors instead.
|
||||
*/
|
||||
@java.lang.Deprecated
|
||||
public java.util.Map<java.lang.String, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage>
|
||||
getMutableMapField() {
|
||||
return internalGetMutableMapField().getMutableMap();
|
||||
}
|
||||
/**
|
||||
* <code>map<string, .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> map_field = 1;</code>
|
||||
*/
|
||||
public Builder putMapField(
|
||||
java.lang.String key,
|
||||
io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage value) {
|
||||
if (key == null) { throw new java.lang.NullPointerException(); }
|
||||
if (value == null) { throw new java.lang.NullPointerException(); }
|
||||
internalGetMutableMapField().getMutableMap()
|
||||
.put(key, value);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>map<string, .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> map_field = 1;</code>
|
||||
*/
|
||||
|
||||
public Builder putAllMapField(
|
||||
java.util.Map<java.lang.String, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> values) {
|
||||
internalGetMutableMapField().getMutableMap()
|
||||
.putAll(values);
|
||||
return this;
|
||||
}
|
||||
@java.lang.Override
|
||||
public final Builder setUnknownFields(
|
||||
final com.google.protobuf.UnknownFieldSet unknownFields) {
|
||||
return super.setUnknownFields(unknownFields);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public final Builder mergeUnknownFields(
|
||||
final com.google.protobuf.UnknownFieldSet unknownFields) {
|
||||
return super.mergeUnknownFields(unknownFields);
|
||||
}
|
||||
|
||||
|
||||
// @@protoc_insertion_point(builder_scope:io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage)
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(class_scope:io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage)
|
||||
private static final io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage DEFAULT_INSTANCE;
|
||||
static {
|
||||
DEFAULT_INSTANCE = new io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage();
|
||||
}
|
||||
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage getDefaultInstance() {
|
||||
return DEFAULT_INSTANCE;
|
||||
}
|
||||
|
||||
private static final com.google.protobuf.Parser<NestedMapMessage>
|
||||
PARSER = new com.google.protobuf.AbstractParser<NestedMapMessage>() {
|
||||
@java.lang.Override
|
||||
public NestedMapMessage parsePartialFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return new NestedMapMessage(input, extensionRegistry);
|
||||
}
|
||||
};
|
||||
|
||||
public static com.google.protobuf.Parser<NestedMapMessage> parser() {
|
||||
return PARSER;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.Parser<NestedMapMessage> getParserForType() {
|
||||
return PARSER;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage getDefaultInstanceForType() {
|
||||
return DEFAULT_INSTANCE;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,43 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: io/bkbn/kompendium/protobufjavaconverter/converters/test.proto
|
||||
|
||||
package io.bkbn.kompendium.protobufjavaconverter;
|
||||
|
||||
public interface NestedMapMessageOrBuilder extends
|
||||
// @@protoc_insertion_point(interface_extends:io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage)
|
||||
com.google.protobuf.MessageOrBuilder {
|
||||
|
||||
/**
|
||||
* <code>map<string, .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> map_field = 1;</code>
|
||||
*/
|
||||
int getMapFieldCount();
|
||||
/**
|
||||
* <code>map<string, .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> map_field = 1;</code>
|
||||
*/
|
||||
boolean containsMapField(
|
||||
java.lang.String key);
|
||||
/**
|
||||
* Use {@link #getMapFieldMap()} instead.
|
||||
*/
|
||||
@java.lang.Deprecated
|
||||
java.util.Map<java.lang.String, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage>
|
||||
getMapField();
|
||||
/**
|
||||
* <code>map<string, .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> map_field = 1;</code>
|
||||
*/
|
||||
java.util.Map<java.lang.String, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage>
|
||||
getMapFieldMap();
|
||||
/**
|
||||
* <code>map<string, .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> map_field = 1;</code>
|
||||
*/
|
||||
|
||||
io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage getMapFieldOrDefault(
|
||||
java.lang.String key,
|
||||
io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage defaultValue);
|
||||
/**
|
||||
* <code>map<string, .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> map_field = 1;</code>
|
||||
*/
|
||||
|
||||
io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage getMapFieldOrThrow(
|
||||
java.lang.String key);
|
||||
}
|
@ -0,0 +1,607 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: io/bkbn/kompendium/protobufjavaconverter/converters/test.proto
|
||||
|
||||
package io.bkbn.kompendium.protobufjavaconverter;
|
||||
|
||||
/**
|
||||
* Protobuf type {@code io.bkbn.kompendium.protobufjavaconverter.NestedMessage}
|
||||
*/
|
||||
public final class NestedMessage extends
|
||||
com.google.protobuf.GeneratedMessageV3 implements
|
||||
// @@protoc_insertion_point(message_implements:io.bkbn.kompendium.protobufjavaconverter.NestedMessage)
|
||||
NestedMessageOrBuilder {
|
||||
private static final long serialVersionUID = 0L;
|
||||
// Use NestedMessage.newBuilder() to construct.
|
||||
private NestedMessage(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
|
||||
super(builder);
|
||||
}
|
||||
private NestedMessage() {
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
@SuppressWarnings({"unused"})
|
||||
protected java.lang.Object newInstance(
|
||||
UnusedPrivateParameter unused) {
|
||||
return new NestedMessage();
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public final com.google.protobuf.UnknownFieldSet
|
||||
getUnknownFields() {
|
||||
return this.unknownFields;
|
||||
}
|
||||
private NestedMessage(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
this();
|
||||
if (extensionRegistry == null) {
|
||||
throw new java.lang.NullPointerException();
|
||||
}
|
||||
com.google.protobuf.UnknownFieldSet.Builder unknownFields =
|
||||
com.google.protobuf.UnknownFieldSet.newBuilder();
|
||||
try {
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
int tag = input.readTag();
|
||||
switch (tag) {
|
||||
case 0:
|
||||
done = true;
|
||||
break;
|
||||
case 10: {
|
||||
io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage.Builder subBuilder = null;
|
||||
if (nestedField_ != null) {
|
||||
subBuilder = nestedField_.toBuilder();
|
||||
}
|
||||
nestedField_ = input.readMessage(io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage.parser(), extensionRegistry);
|
||||
if (subBuilder != null) {
|
||||
subBuilder.mergeFrom(nestedField_);
|
||||
nestedField_ = subBuilder.buildPartial();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
if (!parseUnknownField(
|
||||
input, unknownFields, extensionRegistry, tag)) {
|
||||
done = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
||||
throw e.setUnfinishedMessage(this);
|
||||
} catch (java.io.IOException e) {
|
||||
throw new com.google.protobuf.InvalidProtocolBufferException(
|
||||
e).setUnfinishedMessage(this);
|
||||
} finally {
|
||||
this.unknownFields = unknownFields.build();
|
||||
makeExtensionsImmutable();
|
||||
}
|
||||
}
|
||||
public static final com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptor() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_NestedMessage_descriptor;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internalGetFieldAccessorTable() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_NestedMessage_fieldAccessorTable
|
||||
.ensureFieldAccessorsInitialized(
|
||||
io.bkbn.kompendium.protobufjavaconverter.NestedMessage.class, io.bkbn.kompendium.protobufjavaconverter.NestedMessage.Builder.class);
|
||||
}
|
||||
|
||||
public static final int NESTED_FIELD_FIELD_NUMBER = 1;
|
||||
private io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage nestedField_;
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage nested_field = 1;</code>
|
||||
* @return Whether the nestedField field is set.
|
||||
*/
|
||||
@java.lang.Override
|
||||
public boolean hasNestedField() {
|
||||
return nestedField_ != null;
|
||||
}
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage nested_field = 1;</code>
|
||||
* @return The nestedField.
|
||||
*/
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage getNestedField() {
|
||||
return nestedField_ == null ? io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage.getDefaultInstance() : nestedField_;
|
||||
}
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage nested_field = 1;</code>
|
||||
*/
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessageOrBuilder getNestedFieldOrBuilder() {
|
||||
return getNestedField();
|
||||
}
|
||||
|
||||
private byte memoizedIsInitialized = -1;
|
||||
@java.lang.Override
|
||||
public final boolean isInitialized() {
|
||||
byte isInitialized = memoizedIsInitialized;
|
||||
if (isInitialized == 1) return true;
|
||||
if (isInitialized == 0) return false;
|
||||
|
||||
memoizedIsInitialized = 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public void writeTo(com.google.protobuf.CodedOutputStream output)
|
||||
throws java.io.IOException {
|
||||
if (nestedField_ != null) {
|
||||
output.writeMessage(1, getNestedField());
|
||||
}
|
||||
unknownFields.writeTo(output);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public int getSerializedSize() {
|
||||
int size = memoizedSize;
|
||||
if (size != -1) return size;
|
||||
|
||||
size = 0;
|
||||
if (nestedField_ != null) {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeMessageSize(1, getNestedField());
|
||||
}
|
||||
size += unknownFields.getSerializedSize();
|
||||
memoizedSize = size;
|
||||
return size;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public boolean equals(final java.lang.Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof io.bkbn.kompendium.protobufjavaconverter.NestedMessage)) {
|
||||
return super.equals(obj);
|
||||
}
|
||||
io.bkbn.kompendium.protobufjavaconverter.NestedMessage other = (io.bkbn.kompendium.protobufjavaconverter.NestedMessage) obj;
|
||||
|
||||
if (hasNestedField() != other.hasNestedField()) return false;
|
||||
if (hasNestedField()) {
|
||||
if (!getNestedField()
|
||||
.equals(other.getNestedField())) return false;
|
||||
}
|
||||
if (!unknownFields.equals(other.unknownFields)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public int hashCode() {
|
||||
if (memoizedHashCode != 0) {
|
||||
return memoizedHashCode;
|
||||
}
|
||||
int hash = 41;
|
||||
hash = (19 * hash) + getDescriptor().hashCode();
|
||||
if (hasNestedField()) {
|
||||
hash = (37 * hash) + NESTED_FIELD_FIELD_NUMBER;
|
||||
hash = (53 * hash) + getNestedField().hashCode();
|
||||
}
|
||||
hash = (29 * hash) + unknownFields.hashCode();
|
||||
memoizedHashCode = hash;
|
||||
return hash;
|
||||
}
|
||||
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.NestedMessage parseFrom(
|
||||
java.nio.ByteBuffer data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.NestedMessage parseFrom(
|
||||
java.nio.ByteBuffer data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.NestedMessage parseFrom(
|
||||
com.google.protobuf.ByteString data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.NestedMessage parseFrom(
|
||||
com.google.protobuf.ByteString data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.NestedMessage parseFrom(byte[] data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.NestedMessage parseFrom(
|
||||
byte[] data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.NestedMessage parseFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.NestedMessage parseFrom(
|
||||
java.io.InputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.NestedMessage parseDelimitedFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseDelimitedWithIOException(PARSER, input);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.NestedMessage parseDelimitedFrom(
|
||||
java.io.InputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseDelimitedWithIOException(PARSER, input, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.NestedMessage parseFrom(
|
||||
com.google.protobuf.CodedInputStream input)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.NestedMessage parseFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input, extensionRegistry);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder newBuilderForType() { return newBuilder(); }
|
||||
public static Builder newBuilder() {
|
||||
return DEFAULT_INSTANCE.toBuilder();
|
||||
}
|
||||
public static Builder newBuilder(io.bkbn.kompendium.protobufjavaconverter.NestedMessage prototype) {
|
||||
return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder toBuilder() {
|
||||
return this == DEFAULT_INSTANCE
|
||||
? new Builder() : new Builder().mergeFrom(this);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected Builder newBuilderForType(
|
||||
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
|
||||
Builder builder = new Builder(parent);
|
||||
return builder;
|
||||
}
|
||||
/**
|
||||
* Protobuf type {@code io.bkbn.kompendium.protobufjavaconverter.NestedMessage}
|
||||
*/
|
||||
public static final class Builder extends
|
||||
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
|
||||
// @@protoc_insertion_point(builder_implements:io.bkbn.kompendium.protobufjavaconverter.NestedMessage)
|
||||
io.bkbn.kompendium.protobufjavaconverter.NestedMessageOrBuilder {
|
||||
public static final com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptor() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_NestedMessage_descriptor;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internalGetFieldAccessorTable() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_NestedMessage_fieldAccessorTable
|
||||
.ensureFieldAccessorsInitialized(
|
||||
io.bkbn.kompendium.protobufjavaconverter.NestedMessage.class, io.bkbn.kompendium.protobufjavaconverter.NestedMessage.Builder.class);
|
||||
}
|
||||
|
||||
// Construct using io.bkbn.kompendium.protobufjavaconverter.NestedMessage.newBuilder()
|
||||
private Builder() {
|
||||
maybeForceBuilderInitialization();
|
||||
}
|
||||
|
||||
private Builder(
|
||||
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
|
||||
super(parent);
|
||||
maybeForceBuilderInitialization();
|
||||
}
|
||||
private void maybeForceBuilderInitialization() {
|
||||
if (com.google.protobuf.GeneratedMessageV3
|
||||
.alwaysUseFieldBuilders) {
|
||||
}
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder clear() {
|
||||
super.clear();
|
||||
if (nestedFieldBuilder_ == null) {
|
||||
nestedField_ = null;
|
||||
} else {
|
||||
nestedField_ = null;
|
||||
nestedFieldBuilder_ = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptorForType() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_NestedMessage_descriptor;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.NestedMessage getDefaultInstanceForType() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.NestedMessage.getDefaultInstance();
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.NestedMessage build() {
|
||||
io.bkbn.kompendium.protobufjavaconverter.NestedMessage result = buildPartial();
|
||||
if (!result.isInitialized()) {
|
||||
throw newUninitializedMessageException(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.NestedMessage buildPartial() {
|
||||
io.bkbn.kompendium.protobufjavaconverter.NestedMessage result = new io.bkbn.kompendium.protobufjavaconverter.NestedMessage(this);
|
||||
if (nestedFieldBuilder_ == null) {
|
||||
result.nestedField_ = nestedField_;
|
||||
} else {
|
||||
result.nestedField_ = nestedFieldBuilder_.build();
|
||||
}
|
||||
onBuilt();
|
||||
return result;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder clone() {
|
||||
return super.clone();
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder setField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field,
|
||||
java.lang.Object value) {
|
||||
return super.setField(field, value);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder clearField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field) {
|
||||
return super.clearField(field);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder clearOneof(
|
||||
com.google.protobuf.Descriptors.OneofDescriptor oneof) {
|
||||
return super.clearOneof(oneof);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder setRepeatedField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field,
|
||||
int index, java.lang.Object value) {
|
||||
return super.setRepeatedField(field, index, value);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder addRepeatedField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field,
|
||||
java.lang.Object value) {
|
||||
return super.addRepeatedField(field, value);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder mergeFrom(com.google.protobuf.Message other) {
|
||||
if (other instanceof io.bkbn.kompendium.protobufjavaconverter.NestedMessage) {
|
||||
return mergeFrom((io.bkbn.kompendium.protobufjavaconverter.NestedMessage)other);
|
||||
} else {
|
||||
super.mergeFrom(other);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public Builder mergeFrom(io.bkbn.kompendium.protobufjavaconverter.NestedMessage other) {
|
||||
if (other == io.bkbn.kompendium.protobufjavaconverter.NestedMessage.getDefaultInstance()) return this;
|
||||
if (other.hasNestedField()) {
|
||||
mergeNestedField(other.getNestedField());
|
||||
}
|
||||
this.mergeUnknownFields(other.unknownFields);
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public final boolean isInitialized() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder mergeFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
io.bkbn.kompendium.protobufjavaconverter.NestedMessage parsedMessage = null;
|
||||
try {
|
||||
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
|
||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
||||
parsedMessage = (io.bkbn.kompendium.protobufjavaconverter.NestedMessage) e.getUnfinishedMessage();
|
||||
throw e.unwrapIOException();
|
||||
} finally {
|
||||
if (parsedMessage != null) {
|
||||
mergeFrom(parsedMessage);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
private io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage nestedField_;
|
||||
private com.google.protobuf.SingleFieldBuilderV3<
|
||||
io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage.Builder, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessageOrBuilder> nestedFieldBuilder_;
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage nested_field = 1;</code>
|
||||
* @return Whether the nestedField field is set.
|
||||
*/
|
||||
public boolean hasNestedField() {
|
||||
return nestedFieldBuilder_ != null || nestedField_ != null;
|
||||
}
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage nested_field = 1;</code>
|
||||
* @return The nestedField.
|
||||
*/
|
||||
public io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage getNestedField() {
|
||||
if (nestedFieldBuilder_ == null) {
|
||||
return nestedField_ == null ? io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage.getDefaultInstance() : nestedField_;
|
||||
} else {
|
||||
return nestedFieldBuilder_.getMessage();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage nested_field = 1;</code>
|
||||
*/
|
||||
public Builder setNestedField(io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage value) {
|
||||
if (nestedFieldBuilder_ == null) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
nestedField_ = value;
|
||||
onChanged();
|
||||
} else {
|
||||
nestedFieldBuilder_.setMessage(value);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage nested_field = 1;</code>
|
||||
*/
|
||||
public Builder setNestedField(
|
||||
io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage.Builder builderForValue) {
|
||||
if (nestedFieldBuilder_ == null) {
|
||||
nestedField_ = builderForValue.build();
|
||||
onChanged();
|
||||
} else {
|
||||
nestedFieldBuilder_.setMessage(builderForValue.build());
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage nested_field = 1;</code>
|
||||
*/
|
||||
public Builder mergeNestedField(io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage value) {
|
||||
if (nestedFieldBuilder_ == null) {
|
||||
if (nestedField_ != null) {
|
||||
nestedField_ =
|
||||
io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage.newBuilder(nestedField_).mergeFrom(value).buildPartial();
|
||||
} else {
|
||||
nestedField_ = value;
|
||||
}
|
||||
onChanged();
|
||||
} else {
|
||||
nestedFieldBuilder_.mergeFrom(value);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage nested_field = 1;</code>
|
||||
*/
|
||||
public Builder clearNestedField() {
|
||||
if (nestedFieldBuilder_ == null) {
|
||||
nestedField_ = null;
|
||||
onChanged();
|
||||
} else {
|
||||
nestedField_ = null;
|
||||
nestedFieldBuilder_ = null;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage nested_field = 1;</code>
|
||||
*/
|
||||
public io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage.Builder getNestedFieldBuilder() {
|
||||
|
||||
onChanged();
|
||||
return getNestedFieldFieldBuilder().getBuilder();
|
||||
}
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage nested_field = 1;</code>
|
||||
*/
|
||||
public io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessageOrBuilder getNestedFieldOrBuilder() {
|
||||
if (nestedFieldBuilder_ != null) {
|
||||
return nestedFieldBuilder_.getMessageOrBuilder();
|
||||
} else {
|
||||
return nestedField_ == null ?
|
||||
io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage.getDefaultInstance() : nestedField_;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage nested_field = 1;</code>
|
||||
*/
|
||||
private com.google.protobuf.SingleFieldBuilderV3<
|
||||
io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage.Builder, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessageOrBuilder>
|
||||
getNestedFieldFieldBuilder() {
|
||||
if (nestedFieldBuilder_ == null) {
|
||||
nestedFieldBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
|
||||
io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage.Builder, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessageOrBuilder>(
|
||||
getNestedField(),
|
||||
getParentForChildren(),
|
||||
isClean());
|
||||
nestedField_ = null;
|
||||
}
|
||||
return nestedFieldBuilder_;
|
||||
}
|
||||
@java.lang.Override
|
||||
public final Builder setUnknownFields(
|
||||
final com.google.protobuf.UnknownFieldSet unknownFields) {
|
||||
return super.setUnknownFields(unknownFields);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public final Builder mergeUnknownFields(
|
||||
final com.google.protobuf.UnknownFieldSet unknownFields) {
|
||||
return super.mergeUnknownFields(unknownFields);
|
||||
}
|
||||
|
||||
|
||||
// @@protoc_insertion_point(builder_scope:io.bkbn.kompendium.protobufjavaconverter.NestedMessage)
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(class_scope:io.bkbn.kompendium.protobufjavaconverter.NestedMessage)
|
||||
private static final io.bkbn.kompendium.protobufjavaconverter.NestedMessage DEFAULT_INSTANCE;
|
||||
static {
|
||||
DEFAULT_INSTANCE = new io.bkbn.kompendium.protobufjavaconverter.NestedMessage();
|
||||
}
|
||||
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.NestedMessage getDefaultInstance() {
|
||||
return DEFAULT_INSTANCE;
|
||||
}
|
||||
|
||||
private static final com.google.protobuf.Parser<NestedMessage>
|
||||
PARSER = new com.google.protobuf.AbstractParser<NestedMessage>() {
|
||||
@java.lang.Override
|
||||
public NestedMessage parsePartialFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return new NestedMessage(input, extensionRegistry);
|
||||
}
|
||||
};
|
||||
|
||||
public static com.google.protobuf.Parser<NestedMessage> parser() {
|
||||
return PARSER;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.Parser<NestedMessage> getParserForType() {
|
||||
return PARSER;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.NestedMessage getDefaultInstanceForType() {
|
||||
return DEFAULT_INSTANCE;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: io/bkbn/kompendium/protobufjavaconverter/converters/test.proto
|
||||
|
||||
package io.bkbn.kompendium.protobufjavaconverter;
|
||||
|
||||
public interface NestedMessageOrBuilder extends
|
||||
// @@protoc_insertion_point(interface_extends:io.bkbn.kompendium.protobufjavaconverter.NestedMessage)
|
||||
com.google.protobuf.MessageOrBuilder {
|
||||
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage nested_field = 1;</code>
|
||||
* @return Whether the nestedField field is set.
|
||||
*/
|
||||
boolean hasNestedField();
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage nested_field = 1;</code>
|
||||
* @return The nestedField.
|
||||
*/
|
||||
io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage getNestedField();
|
||||
/**
|
||||
* <code>.io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage nested_field = 1;</code>
|
||||
*/
|
||||
io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessageOrBuilder getNestedFieldOrBuilder();
|
||||
}
|
@ -0,0 +1,689 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: io/bkbn/kompendium/protobufjavaconverter/converters/test.proto
|
||||
|
||||
package io.bkbn.kompendium.protobufjavaconverter;
|
||||
|
||||
/**
|
||||
* Protobuf type {@code io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage}
|
||||
*/
|
||||
public final class RepeatedEnumMessage extends
|
||||
com.google.protobuf.GeneratedMessageV3 implements
|
||||
// @@protoc_insertion_point(message_implements:io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage)
|
||||
RepeatedEnumMessageOrBuilder {
|
||||
private static final long serialVersionUID = 0L;
|
||||
// Use RepeatedEnumMessage.newBuilder() to construct.
|
||||
private RepeatedEnumMessage(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
|
||||
super(builder);
|
||||
}
|
||||
private RepeatedEnumMessage() {
|
||||
repeatedField_ = java.util.Collections.emptyList();
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
@SuppressWarnings({"unused"})
|
||||
protected java.lang.Object newInstance(
|
||||
UnusedPrivateParameter unused) {
|
||||
return new RepeatedEnumMessage();
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public final com.google.protobuf.UnknownFieldSet
|
||||
getUnknownFields() {
|
||||
return this.unknownFields;
|
||||
}
|
||||
private RepeatedEnumMessage(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
this();
|
||||
if (extensionRegistry == null) {
|
||||
throw new java.lang.NullPointerException();
|
||||
}
|
||||
int mutable_bitField0_ = 0;
|
||||
com.google.protobuf.UnknownFieldSet.Builder unknownFields =
|
||||
com.google.protobuf.UnknownFieldSet.newBuilder();
|
||||
try {
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
int tag = input.readTag();
|
||||
switch (tag) {
|
||||
case 0:
|
||||
done = true;
|
||||
break;
|
||||
case 8: {
|
||||
int rawValue = input.readEnum();
|
||||
if (!((mutable_bitField0_ & 0x00000001) != 0)) {
|
||||
repeatedField_ = new java.util.ArrayList<java.lang.Integer>();
|
||||
mutable_bitField0_ |= 0x00000001;
|
||||
}
|
||||
repeatedField_.add(rawValue);
|
||||
break;
|
||||
}
|
||||
case 10: {
|
||||
int length = input.readRawVarint32();
|
||||
int oldLimit = input.pushLimit(length);
|
||||
while(input.getBytesUntilLimit() > 0) {
|
||||
int rawValue = input.readEnum();
|
||||
if (!((mutable_bitField0_ & 0x00000001) != 0)) {
|
||||
repeatedField_ = new java.util.ArrayList<java.lang.Integer>();
|
||||
mutable_bitField0_ |= 0x00000001;
|
||||
}
|
||||
repeatedField_.add(rawValue);
|
||||
}
|
||||
input.popLimit(oldLimit);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
if (!parseUnknownField(
|
||||
input, unknownFields, extensionRegistry, tag)) {
|
||||
done = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
||||
throw e.setUnfinishedMessage(this);
|
||||
} catch (java.io.IOException e) {
|
||||
throw new com.google.protobuf.InvalidProtocolBufferException(
|
||||
e).setUnfinishedMessage(this);
|
||||
} finally {
|
||||
if (((mutable_bitField0_ & 0x00000001) != 0)) {
|
||||
repeatedField_ = java.util.Collections.unmodifiableList(repeatedField_);
|
||||
}
|
||||
this.unknownFields = unknownFields.build();
|
||||
makeExtensionsImmutable();
|
||||
}
|
||||
}
|
||||
public static final com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptor() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_RepeatedEnumMessage_descriptor;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internalGetFieldAccessorTable() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_RepeatedEnumMessage_fieldAccessorTable
|
||||
.ensureFieldAccessorsInitialized(
|
||||
io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage.class, io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage.Builder.class);
|
||||
}
|
||||
|
||||
public static final int REPEATED_FIELD_FIELD_NUMBER = 1;
|
||||
private java.util.List<java.lang.Integer> repeatedField_;
|
||||
private static final com.google.protobuf.Internal.ListAdapter.Converter<
|
||||
java.lang.Integer, io.bkbn.kompendium.protobufjavaconverter.Corpus> repeatedField_converter_ =
|
||||
new com.google.protobuf.Internal.ListAdapter.Converter<
|
||||
java.lang.Integer, io.bkbn.kompendium.protobufjavaconverter.Corpus>() {
|
||||
public io.bkbn.kompendium.protobufjavaconverter.Corpus convert(java.lang.Integer from) {
|
||||
@SuppressWarnings("deprecation")
|
||||
io.bkbn.kompendium.protobufjavaconverter.Corpus result = io.bkbn.kompendium.protobufjavaconverter.Corpus.valueOf(from);
|
||||
return result == null ? io.bkbn.kompendium.protobufjavaconverter.Corpus.UNRECOGNIZED : result;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.Corpus repeated_field = 1;</code>
|
||||
* @return A list containing the repeatedField.
|
||||
*/
|
||||
@java.lang.Override
|
||||
public java.util.List<io.bkbn.kompendium.protobufjavaconverter.Corpus> getRepeatedFieldList() {
|
||||
return new com.google.protobuf.Internal.ListAdapter<
|
||||
java.lang.Integer, io.bkbn.kompendium.protobufjavaconverter.Corpus>(repeatedField_, repeatedField_converter_);
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.Corpus repeated_field = 1;</code>
|
||||
* @return The count of repeatedField.
|
||||
*/
|
||||
@java.lang.Override
|
||||
public int getRepeatedFieldCount() {
|
||||
return repeatedField_.size();
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.Corpus repeated_field = 1;</code>
|
||||
* @param index The index of the element to return.
|
||||
* @return The repeatedField at the given index.
|
||||
*/
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.Corpus getRepeatedField(int index) {
|
||||
return repeatedField_converter_.convert(repeatedField_.get(index));
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.Corpus repeated_field = 1;</code>
|
||||
* @return A list containing the enum numeric values on the wire for repeatedField.
|
||||
*/
|
||||
@java.lang.Override
|
||||
public java.util.List<java.lang.Integer>
|
||||
getRepeatedFieldValueList() {
|
||||
return repeatedField_;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.Corpus repeated_field = 1;</code>
|
||||
* @param index The index of the value to return.
|
||||
* @return The enum numeric value on the wire of repeatedField at the given index.
|
||||
*/
|
||||
@java.lang.Override
|
||||
public int getRepeatedFieldValue(int index) {
|
||||
return repeatedField_.get(index);
|
||||
}
|
||||
private int repeatedFieldMemoizedSerializedSize;
|
||||
|
||||
private byte memoizedIsInitialized = -1;
|
||||
@java.lang.Override
|
||||
public final boolean isInitialized() {
|
||||
byte isInitialized = memoizedIsInitialized;
|
||||
if (isInitialized == 1) return true;
|
||||
if (isInitialized == 0) return false;
|
||||
|
||||
memoizedIsInitialized = 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public void writeTo(com.google.protobuf.CodedOutputStream output)
|
||||
throws java.io.IOException {
|
||||
getSerializedSize();
|
||||
if (getRepeatedFieldList().size() > 0) {
|
||||
output.writeUInt32NoTag(10);
|
||||
output.writeUInt32NoTag(repeatedFieldMemoizedSerializedSize);
|
||||
}
|
||||
for (int i = 0; i < repeatedField_.size(); i++) {
|
||||
output.writeEnumNoTag(repeatedField_.get(i));
|
||||
}
|
||||
unknownFields.writeTo(output);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public int getSerializedSize() {
|
||||
int size = memoizedSize;
|
||||
if (size != -1) return size;
|
||||
|
||||
size = 0;
|
||||
{
|
||||
int dataSize = 0;
|
||||
for (int i = 0; i < repeatedField_.size(); i++) {
|
||||
dataSize += com.google.protobuf.CodedOutputStream
|
||||
.computeEnumSizeNoTag(repeatedField_.get(i));
|
||||
}
|
||||
size += dataSize;
|
||||
if (!getRepeatedFieldList().isEmpty()) { size += 1;
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeUInt32SizeNoTag(dataSize);
|
||||
}repeatedFieldMemoizedSerializedSize = dataSize;
|
||||
}
|
||||
size += unknownFields.getSerializedSize();
|
||||
memoizedSize = size;
|
||||
return size;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public boolean equals(final java.lang.Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage)) {
|
||||
return super.equals(obj);
|
||||
}
|
||||
io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage other = (io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage) obj;
|
||||
|
||||
if (!repeatedField_.equals(other.repeatedField_)) return false;
|
||||
if (!unknownFields.equals(other.unknownFields)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public int hashCode() {
|
||||
if (memoizedHashCode != 0) {
|
||||
return memoizedHashCode;
|
||||
}
|
||||
int hash = 41;
|
||||
hash = (19 * hash) + getDescriptor().hashCode();
|
||||
if (getRepeatedFieldCount() > 0) {
|
||||
hash = (37 * hash) + REPEATED_FIELD_FIELD_NUMBER;
|
||||
hash = (53 * hash) + repeatedField_.hashCode();
|
||||
}
|
||||
hash = (29 * hash) + unknownFields.hashCode();
|
||||
memoizedHashCode = hash;
|
||||
return hash;
|
||||
}
|
||||
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage parseFrom(
|
||||
java.nio.ByteBuffer data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage parseFrom(
|
||||
java.nio.ByteBuffer data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage parseFrom(
|
||||
com.google.protobuf.ByteString data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage parseFrom(
|
||||
com.google.protobuf.ByteString data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage parseFrom(byte[] data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage parseFrom(
|
||||
byte[] data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage parseFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage parseFrom(
|
||||
java.io.InputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage parseDelimitedFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseDelimitedWithIOException(PARSER, input);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage parseDelimitedFrom(
|
||||
java.io.InputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseDelimitedWithIOException(PARSER, input, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage parseFrom(
|
||||
com.google.protobuf.CodedInputStream input)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage parseFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input, extensionRegistry);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder newBuilderForType() { return newBuilder(); }
|
||||
public static Builder newBuilder() {
|
||||
return DEFAULT_INSTANCE.toBuilder();
|
||||
}
|
||||
public static Builder newBuilder(io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage prototype) {
|
||||
return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder toBuilder() {
|
||||
return this == DEFAULT_INSTANCE
|
||||
? new Builder() : new Builder().mergeFrom(this);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected Builder newBuilderForType(
|
||||
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
|
||||
Builder builder = new Builder(parent);
|
||||
return builder;
|
||||
}
|
||||
/**
|
||||
* Protobuf type {@code io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage}
|
||||
*/
|
||||
public static final class Builder extends
|
||||
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
|
||||
// @@protoc_insertion_point(builder_implements:io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage)
|
||||
io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessageOrBuilder {
|
||||
public static final com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptor() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_RepeatedEnumMessage_descriptor;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internalGetFieldAccessorTable() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_RepeatedEnumMessage_fieldAccessorTable
|
||||
.ensureFieldAccessorsInitialized(
|
||||
io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage.class, io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage.Builder.class);
|
||||
}
|
||||
|
||||
// Construct using io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage.newBuilder()
|
||||
private Builder() {
|
||||
maybeForceBuilderInitialization();
|
||||
}
|
||||
|
||||
private Builder(
|
||||
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
|
||||
super(parent);
|
||||
maybeForceBuilderInitialization();
|
||||
}
|
||||
private void maybeForceBuilderInitialization() {
|
||||
if (com.google.protobuf.GeneratedMessageV3
|
||||
.alwaysUseFieldBuilders) {
|
||||
}
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder clear() {
|
||||
super.clear();
|
||||
repeatedField_ = java.util.Collections.emptyList();
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
return this;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptorForType() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_RepeatedEnumMessage_descriptor;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage getDefaultInstanceForType() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage.getDefaultInstance();
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage build() {
|
||||
io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage result = buildPartial();
|
||||
if (!result.isInitialized()) {
|
||||
throw newUninitializedMessageException(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage buildPartial() {
|
||||
io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage result = new io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage(this);
|
||||
int from_bitField0_ = bitField0_;
|
||||
if (((bitField0_ & 0x00000001) != 0)) {
|
||||
repeatedField_ = java.util.Collections.unmodifiableList(repeatedField_);
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
}
|
||||
result.repeatedField_ = repeatedField_;
|
||||
onBuilt();
|
||||
return result;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder clone() {
|
||||
return super.clone();
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder setField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field,
|
||||
java.lang.Object value) {
|
||||
return super.setField(field, value);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder clearField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field) {
|
||||
return super.clearField(field);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder clearOneof(
|
||||
com.google.protobuf.Descriptors.OneofDescriptor oneof) {
|
||||
return super.clearOneof(oneof);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder setRepeatedField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field,
|
||||
int index, java.lang.Object value) {
|
||||
return super.setRepeatedField(field, index, value);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder addRepeatedField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field,
|
||||
java.lang.Object value) {
|
||||
return super.addRepeatedField(field, value);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder mergeFrom(com.google.protobuf.Message other) {
|
||||
if (other instanceof io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage) {
|
||||
return mergeFrom((io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage)other);
|
||||
} else {
|
||||
super.mergeFrom(other);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public Builder mergeFrom(io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage other) {
|
||||
if (other == io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage.getDefaultInstance()) return this;
|
||||
if (!other.repeatedField_.isEmpty()) {
|
||||
if (repeatedField_.isEmpty()) {
|
||||
repeatedField_ = other.repeatedField_;
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
} else {
|
||||
ensureRepeatedFieldIsMutable();
|
||||
repeatedField_.addAll(other.repeatedField_);
|
||||
}
|
||||
onChanged();
|
||||
}
|
||||
this.mergeUnknownFields(other.unknownFields);
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public final boolean isInitialized() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder mergeFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage parsedMessage = null;
|
||||
try {
|
||||
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
|
||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
||||
parsedMessage = (io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage) e.getUnfinishedMessage();
|
||||
throw e.unwrapIOException();
|
||||
} finally {
|
||||
if (parsedMessage != null) {
|
||||
mergeFrom(parsedMessage);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
private int bitField0_;
|
||||
|
||||
private java.util.List<java.lang.Integer> repeatedField_ =
|
||||
java.util.Collections.emptyList();
|
||||
private void ensureRepeatedFieldIsMutable() {
|
||||
if (!((bitField0_ & 0x00000001) != 0)) {
|
||||
repeatedField_ = new java.util.ArrayList<java.lang.Integer>(repeatedField_);
|
||||
bitField0_ |= 0x00000001;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.Corpus repeated_field = 1;</code>
|
||||
* @return A list containing the repeatedField.
|
||||
*/
|
||||
public java.util.List<io.bkbn.kompendium.protobufjavaconverter.Corpus> getRepeatedFieldList() {
|
||||
return new com.google.protobuf.Internal.ListAdapter<
|
||||
java.lang.Integer, io.bkbn.kompendium.protobufjavaconverter.Corpus>(repeatedField_, repeatedField_converter_);
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.Corpus repeated_field = 1;</code>
|
||||
* @return The count of repeatedField.
|
||||
*/
|
||||
public int getRepeatedFieldCount() {
|
||||
return repeatedField_.size();
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.Corpus repeated_field = 1;</code>
|
||||
* @param index The index of the element to return.
|
||||
* @return The repeatedField at the given index.
|
||||
*/
|
||||
public io.bkbn.kompendium.protobufjavaconverter.Corpus getRepeatedField(int index) {
|
||||
return repeatedField_converter_.convert(repeatedField_.get(index));
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.Corpus repeated_field = 1;</code>
|
||||
* @param index The index to set the value at.
|
||||
* @param value The repeatedField to set.
|
||||
* @return This builder for chaining.
|
||||
*/
|
||||
public Builder setRepeatedField(
|
||||
int index, io.bkbn.kompendium.protobufjavaconverter.Corpus value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
ensureRepeatedFieldIsMutable();
|
||||
repeatedField_.set(index, value.getNumber());
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.Corpus repeated_field = 1;</code>
|
||||
* @param value The repeatedField to add.
|
||||
* @return This builder for chaining.
|
||||
*/
|
||||
public Builder addRepeatedField(io.bkbn.kompendium.protobufjavaconverter.Corpus value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
ensureRepeatedFieldIsMutable();
|
||||
repeatedField_.add(value.getNumber());
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.Corpus repeated_field = 1;</code>
|
||||
* @param values The repeatedField to add.
|
||||
* @return This builder for chaining.
|
||||
*/
|
||||
public Builder addAllRepeatedField(
|
||||
java.lang.Iterable<? extends io.bkbn.kompendium.protobufjavaconverter.Corpus> values) {
|
||||
ensureRepeatedFieldIsMutable();
|
||||
for (io.bkbn.kompendium.protobufjavaconverter.Corpus value : values) {
|
||||
repeatedField_.add(value.getNumber());
|
||||
}
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.Corpus repeated_field = 1;</code>
|
||||
* @return This builder for chaining.
|
||||
*/
|
||||
public Builder clearRepeatedField() {
|
||||
repeatedField_ = java.util.Collections.emptyList();
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.Corpus repeated_field = 1;</code>
|
||||
* @return A list containing the enum numeric values on the wire for repeatedField.
|
||||
*/
|
||||
public java.util.List<java.lang.Integer>
|
||||
getRepeatedFieldValueList() {
|
||||
return java.util.Collections.unmodifiableList(repeatedField_);
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.Corpus repeated_field = 1;</code>
|
||||
* @param index The index of the value to return.
|
||||
* @return The enum numeric value on the wire of repeatedField at the given index.
|
||||
*/
|
||||
public int getRepeatedFieldValue(int index) {
|
||||
return repeatedField_.get(index);
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.Corpus repeated_field = 1;</code>
|
||||
* @param index The index of the value to return.
|
||||
* @return The enum numeric value on the wire of repeatedField at the given index.
|
||||
* @return This builder for chaining.
|
||||
*/
|
||||
public Builder setRepeatedFieldValue(
|
||||
int index, int value) {
|
||||
ensureRepeatedFieldIsMutable();
|
||||
repeatedField_.set(index, value);
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.Corpus repeated_field = 1;</code>
|
||||
* @param value The enum numeric value on the wire for repeatedField to add.
|
||||
* @return This builder for chaining.
|
||||
*/
|
||||
public Builder addRepeatedFieldValue(int value) {
|
||||
ensureRepeatedFieldIsMutable();
|
||||
repeatedField_.add(value);
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.Corpus repeated_field = 1;</code>
|
||||
* @param values The enum numeric values on the wire for repeatedField to add.
|
||||
* @return This builder for chaining.
|
||||
*/
|
||||
public Builder addAllRepeatedFieldValue(
|
||||
java.lang.Iterable<java.lang.Integer> values) {
|
||||
ensureRepeatedFieldIsMutable();
|
||||
for (int value : values) {
|
||||
repeatedField_.add(value);
|
||||
}
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
@java.lang.Override
|
||||
public final Builder setUnknownFields(
|
||||
final com.google.protobuf.UnknownFieldSet unknownFields) {
|
||||
return super.setUnknownFields(unknownFields);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public final Builder mergeUnknownFields(
|
||||
final com.google.protobuf.UnknownFieldSet unknownFields) {
|
||||
return super.mergeUnknownFields(unknownFields);
|
||||
}
|
||||
|
||||
|
||||
// @@protoc_insertion_point(builder_scope:io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage)
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(class_scope:io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage)
|
||||
private static final io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage DEFAULT_INSTANCE;
|
||||
static {
|
||||
DEFAULT_INSTANCE = new io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage();
|
||||
}
|
||||
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage getDefaultInstance() {
|
||||
return DEFAULT_INSTANCE;
|
||||
}
|
||||
|
||||
private static final com.google.protobuf.Parser<RepeatedEnumMessage>
|
||||
PARSER = new com.google.protobuf.AbstractParser<RepeatedEnumMessage>() {
|
||||
@java.lang.Override
|
||||
public RepeatedEnumMessage parsePartialFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return new RepeatedEnumMessage(input, extensionRegistry);
|
||||
}
|
||||
};
|
||||
|
||||
public static com.google.protobuf.Parser<RepeatedEnumMessage> parser() {
|
||||
return PARSER;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.Parser<RepeatedEnumMessage> getParserForType() {
|
||||
return PARSER;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage getDefaultInstanceForType() {
|
||||
return DEFAULT_INSTANCE;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,38 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: io/bkbn/kompendium/protobufjavaconverter/converters/test.proto
|
||||
|
||||
package io.bkbn.kompendium.protobufjavaconverter;
|
||||
|
||||
public interface RepeatedEnumMessageOrBuilder extends
|
||||
// @@protoc_insertion_point(interface_extends:io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage)
|
||||
com.google.protobuf.MessageOrBuilder {
|
||||
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.Corpus repeated_field = 1;</code>
|
||||
* @return A list containing the repeatedField.
|
||||
*/
|
||||
java.util.List<io.bkbn.kompendium.protobufjavaconverter.Corpus> getRepeatedFieldList();
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.Corpus repeated_field = 1;</code>
|
||||
* @return The count of repeatedField.
|
||||
*/
|
||||
int getRepeatedFieldCount();
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.Corpus repeated_field = 1;</code>
|
||||
* @param index The index of the element to return.
|
||||
* @return The repeatedField at the given index.
|
||||
*/
|
||||
io.bkbn.kompendium.protobufjavaconverter.Corpus getRepeatedField(int index);
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.Corpus repeated_field = 1;</code>
|
||||
* @return A list containing the enum numeric values on the wire for repeatedField.
|
||||
*/
|
||||
java.util.List<java.lang.Integer>
|
||||
getRepeatedFieldValueList();
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.Corpus repeated_field = 1;</code>
|
||||
* @param index The index of the value to return.
|
||||
* @return The enum numeric value on the wire of repeatedField at the given index.
|
||||
*/
|
||||
int getRepeatedFieldValue(int index);
|
||||
}
|
@ -0,0 +1,770 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: io/bkbn/kompendium/protobufjavaconverter/converters/test.proto
|
||||
|
||||
package io.bkbn.kompendium.protobufjavaconverter;
|
||||
|
||||
/**
|
||||
* Protobuf type {@code io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage}
|
||||
*/
|
||||
public final class RepeatedMessage extends
|
||||
com.google.protobuf.GeneratedMessageV3 implements
|
||||
// @@protoc_insertion_point(message_implements:io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage)
|
||||
RepeatedMessageOrBuilder {
|
||||
private static final long serialVersionUID = 0L;
|
||||
// Use RepeatedMessage.newBuilder() to construct.
|
||||
private RepeatedMessage(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
|
||||
super(builder);
|
||||
}
|
||||
private RepeatedMessage() {
|
||||
repeatedField_ = java.util.Collections.emptyList();
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
@SuppressWarnings({"unused"})
|
||||
protected java.lang.Object newInstance(
|
||||
UnusedPrivateParameter unused) {
|
||||
return new RepeatedMessage();
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public final com.google.protobuf.UnknownFieldSet
|
||||
getUnknownFields() {
|
||||
return this.unknownFields;
|
||||
}
|
||||
private RepeatedMessage(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
this();
|
||||
if (extensionRegistry == null) {
|
||||
throw new java.lang.NullPointerException();
|
||||
}
|
||||
int mutable_bitField0_ = 0;
|
||||
com.google.protobuf.UnknownFieldSet.Builder unknownFields =
|
||||
com.google.protobuf.UnknownFieldSet.newBuilder();
|
||||
try {
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
int tag = input.readTag();
|
||||
switch (tag) {
|
||||
case 0:
|
||||
done = true;
|
||||
break;
|
||||
case 10: {
|
||||
if (!((mutable_bitField0_ & 0x00000001) != 0)) {
|
||||
repeatedField_ = new java.util.ArrayList<io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage>();
|
||||
mutable_bitField0_ |= 0x00000001;
|
||||
}
|
||||
repeatedField_.add(
|
||||
input.readMessage(io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage.parser(), extensionRegistry));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
if (!parseUnknownField(
|
||||
input, unknownFields, extensionRegistry, tag)) {
|
||||
done = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
||||
throw e.setUnfinishedMessage(this);
|
||||
} catch (java.io.IOException e) {
|
||||
throw new com.google.protobuf.InvalidProtocolBufferException(
|
||||
e).setUnfinishedMessage(this);
|
||||
} finally {
|
||||
if (((mutable_bitField0_ & 0x00000001) != 0)) {
|
||||
repeatedField_ = java.util.Collections.unmodifiableList(repeatedField_);
|
||||
}
|
||||
this.unknownFields = unknownFields.build();
|
||||
makeExtensionsImmutable();
|
||||
}
|
||||
}
|
||||
public static final com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptor() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_RepeatedMessage_descriptor;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internalGetFieldAccessorTable() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_RepeatedMessage_fieldAccessorTable
|
||||
.ensureFieldAccessorsInitialized(
|
||||
io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage.class, io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage.Builder.class);
|
||||
}
|
||||
|
||||
public static final int REPEATED_FIELD_FIELD_NUMBER = 1;
|
||||
private java.util.List<io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> repeatedField_;
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage repeated_field = 1;</code>
|
||||
*/
|
||||
@java.lang.Override
|
||||
public java.util.List<io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> getRepeatedFieldList() {
|
||||
return repeatedField_;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage repeated_field = 1;</code>
|
||||
*/
|
||||
@java.lang.Override
|
||||
public java.util.List<? extends io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessageOrBuilder>
|
||||
getRepeatedFieldOrBuilderList() {
|
||||
return repeatedField_;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage repeated_field = 1;</code>
|
||||
*/
|
||||
@java.lang.Override
|
||||
public int getRepeatedFieldCount() {
|
||||
return repeatedField_.size();
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage repeated_field = 1;</code>
|
||||
*/
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage getRepeatedField(int index) {
|
||||
return repeatedField_.get(index);
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage repeated_field = 1;</code>
|
||||
*/
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessageOrBuilder getRepeatedFieldOrBuilder(
|
||||
int index) {
|
||||
return repeatedField_.get(index);
|
||||
}
|
||||
|
||||
private byte memoizedIsInitialized = -1;
|
||||
@java.lang.Override
|
||||
public final boolean isInitialized() {
|
||||
byte isInitialized = memoizedIsInitialized;
|
||||
if (isInitialized == 1) return true;
|
||||
if (isInitialized == 0) return false;
|
||||
|
||||
memoizedIsInitialized = 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public void writeTo(com.google.protobuf.CodedOutputStream output)
|
||||
throws java.io.IOException {
|
||||
for (int i = 0; i < repeatedField_.size(); i++) {
|
||||
output.writeMessage(1, repeatedField_.get(i));
|
||||
}
|
||||
unknownFields.writeTo(output);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public int getSerializedSize() {
|
||||
int size = memoizedSize;
|
||||
if (size != -1) return size;
|
||||
|
||||
size = 0;
|
||||
for (int i = 0; i < repeatedField_.size(); i++) {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeMessageSize(1, repeatedField_.get(i));
|
||||
}
|
||||
size += unknownFields.getSerializedSize();
|
||||
memoizedSize = size;
|
||||
return size;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public boolean equals(final java.lang.Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage)) {
|
||||
return super.equals(obj);
|
||||
}
|
||||
io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage other = (io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage) obj;
|
||||
|
||||
if (!getRepeatedFieldList()
|
||||
.equals(other.getRepeatedFieldList())) return false;
|
||||
if (!unknownFields.equals(other.unknownFields)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public int hashCode() {
|
||||
if (memoizedHashCode != 0) {
|
||||
return memoizedHashCode;
|
||||
}
|
||||
int hash = 41;
|
||||
hash = (19 * hash) + getDescriptor().hashCode();
|
||||
if (getRepeatedFieldCount() > 0) {
|
||||
hash = (37 * hash) + REPEATED_FIELD_FIELD_NUMBER;
|
||||
hash = (53 * hash) + getRepeatedFieldList().hashCode();
|
||||
}
|
||||
hash = (29 * hash) + unknownFields.hashCode();
|
||||
memoizedHashCode = hash;
|
||||
return hash;
|
||||
}
|
||||
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage parseFrom(
|
||||
java.nio.ByteBuffer data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage parseFrom(
|
||||
java.nio.ByteBuffer data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage parseFrom(
|
||||
com.google.protobuf.ByteString data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage parseFrom(
|
||||
com.google.protobuf.ByteString data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage parseFrom(byte[] data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage parseFrom(
|
||||
byte[] data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage parseFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage parseFrom(
|
||||
java.io.InputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage parseDelimitedFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseDelimitedWithIOException(PARSER, input);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage parseDelimitedFrom(
|
||||
java.io.InputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseDelimitedWithIOException(PARSER, input, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage parseFrom(
|
||||
com.google.protobuf.CodedInputStream input)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage parseFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input, extensionRegistry);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder newBuilderForType() { return newBuilder(); }
|
||||
public static Builder newBuilder() {
|
||||
return DEFAULT_INSTANCE.toBuilder();
|
||||
}
|
||||
public static Builder newBuilder(io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage prototype) {
|
||||
return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder toBuilder() {
|
||||
return this == DEFAULT_INSTANCE
|
||||
? new Builder() : new Builder().mergeFrom(this);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected Builder newBuilderForType(
|
||||
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
|
||||
Builder builder = new Builder(parent);
|
||||
return builder;
|
||||
}
|
||||
/**
|
||||
* Protobuf type {@code io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage}
|
||||
*/
|
||||
public static final class Builder extends
|
||||
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
|
||||
// @@protoc_insertion_point(builder_implements:io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage)
|
||||
io.bkbn.kompendium.protobufjavaconverter.RepeatedMessageOrBuilder {
|
||||
public static final com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptor() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_RepeatedMessage_descriptor;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internalGetFieldAccessorTable() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_RepeatedMessage_fieldAccessorTable
|
||||
.ensureFieldAccessorsInitialized(
|
||||
io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage.class, io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage.Builder.class);
|
||||
}
|
||||
|
||||
// Construct using io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage.newBuilder()
|
||||
private Builder() {
|
||||
maybeForceBuilderInitialization();
|
||||
}
|
||||
|
||||
private Builder(
|
||||
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
|
||||
super(parent);
|
||||
maybeForceBuilderInitialization();
|
||||
}
|
||||
private void maybeForceBuilderInitialization() {
|
||||
if (com.google.protobuf.GeneratedMessageV3
|
||||
.alwaysUseFieldBuilders) {
|
||||
getRepeatedFieldFieldBuilder();
|
||||
}
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder clear() {
|
||||
super.clear();
|
||||
if (repeatedFieldBuilder_ == null) {
|
||||
repeatedField_ = java.util.Collections.emptyList();
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
} else {
|
||||
repeatedFieldBuilder_.clear();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptorForType() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_RepeatedMessage_descriptor;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage getDefaultInstanceForType() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage.getDefaultInstance();
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage build() {
|
||||
io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage result = buildPartial();
|
||||
if (!result.isInitialized()) {
|
||||
throw newUninitializedMessageException(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage buildPartial() {
|
||||
io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage result = new io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage(this);
|
||||
int from_bitField0_ = bitField0_;
|
||||
if (repeatedFieldBuilder_ == null) {
|
||||
if (((bitField0_ & 0x00000001) != 0)) {
|
||||
repeatedField_ = java.util.Collections.unmodifiableList(repeatedField_);
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
}
|
||||
result.repeatedField_ = repeatedField_;
|
||||
} else {
|
||||
result.repeatedField_ = repeatedFieldBuilder_.build();
|
||||
}
|
||||
onBuilt();
|
||||
return result;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder clone() {
|
||||
return super.clone();
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder setField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field,
|
||||
java.lang.Object value) {
|
||||
return super.setField(field, value);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder clearField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field) {
|
||||
return super.clearField(field);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder clearOneof(
|
||||
com.google.protobuf.Descriptors.OneofDescriptor oneof) {
|
||||
return super.clearOneof(oneof);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder setRepeatedField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field,
|
||||
int index, java.lang.Object value) {
|
||||
return super.setRepeatedField(field, index, value);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder addRepeatedField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field,
|
||||
java.lang.Object value) {
|
||||
return super.addRepeatedField(field, value);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder mergeFrom(com.google.protobuf.Message other) {
|
||||
if (other instanceof io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage) {
|
||||
return mergeFrom((io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage)other);
|
||||
} else {
|
||||
super.mergeFrom(other);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public Builder mergeFrom(io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage other) {
|
||||
if (other == io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage.getDefaultInstance()) return this;
|
||||
if (repeatedFieldBuilder_ == null) {
|
||||
if (!other.repeatedField_.isEmpty()) {
|
||||
if (repeatedField_.isEmpty()) {
|
||||
repeatedField_ = other.repeatedField_;
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
} else {
|
||||
ensureRepeatedFieldIsMutable();
|
||||
repeatedField_.addAll(other.repeatedField_);
|
||||
}
|
||||
onChanged();
|
||||
}
|
||||
} else {
|
||||
if (!other.repeatedField_.isEmpty()) {
|
||||
if (repeatedFieldBuilder_.isEmpty()) {
|
||||
repeatedFieldBuilder_.dispose();
|
||||
repeatedFieldBuilder_ = null;
|
||||
repeatedField_ = other.repeatedField_;
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
repeatedFieldBuilder_ =
|
||||
com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
|
||||
getRepeatedFieldFieldBuilder() : null;
|
||||
} else {
|
||||
repeatedFieldBuilder_.addAllMessages(other.repeatedField_);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.mergeUnknownFields(other.unknownFields);
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public final boolean isInitialized() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder mergeFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage parsedMessage = null;
|
||||
try {
|
||||
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
|
||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
||||
parsedMessage = (io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage) e.getUnfinishedMessage();
|
||||
throw e.unwrapIOException();
|
||||
} finally {
|
||||
if (parsedMessage != null) {
|
||||
mergeFrom(parsedMessage);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
private int bitField0_;
|
||||
|
||||
private java.util.List<io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> repeatedField_ =
|
||||
java.util.Collections.emptyList();
|
||||
private void ensureRepeatedFieldIsMutable() {
|
||||
if (!((bitField0_ & 0x00000001) != 0)) {
|
||||
repeatedField_ = new java.util.ArrayList<io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage>(repeatedField_);
|
||||
bitField0_ |= 0x00000001;
|
||||
}
|
||||
}
|
||||
|
||||
private com.google.protobuf.RepeatedFieldBuilderV3<
|
||||
io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage.Builder, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessageOrBuilder> repeatedFieldBuilder_;
|
||||
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage repeated_field = 1;</code>
|
||||
*/
|
||||
public java.util.List<io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> getRepeatedFieldList() {
|
||||
if (repeatedFieldBuilder_ == null) {
|
||||
return java.util.Collections.unmodifiableList(repeatedField_);
|
||||
} else {
|
||||
return repeatedFieldBuilder_.getMessageList();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage repeated_field = 1;</code>
|
||||
*/
|
||||
public int getRepeatedFieldCount() {
|
||||
if (repeatedFieldBuilder_ == null) {
|
||||
return repeatedField_.size();
|
||||
} else {
|
||||
return repeatedFieldBuilder_.getCount();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage repeated_field = 1;</code>
|
||||
*/
|
||||
public io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage getRepeatedField(int index) {
|
||||
if (repeatedFieldBuilder_ == null) {
|
||||
return repeatedField_.get(index);
|
||||
} else {
|
||||
return repeatedFieldBuilder_.getMessage(index);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage repeated_field = 1;</code>
|
||||
*/
|
||||
public Builder setRepeatedField(
|
||||
int index, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage value) {
|
||||
if (repeatedFieldBuilder_ == null) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
ensureRepeatedFieldIsMutable();
|
||||
repeatedField_.set(index, value);
|
||||
onChanged();
|
||||
} else {
|
||||
repeatedFieldBuilder_.setMessage(index, value);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage repeated_field = 1;</code>
|
||||
*/
|
||||
public Builder setRepeatedField(
|
||||
int index, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage.Builder builderForValue) {
|
||||
if (repeatedFieldBuilder_ == null) {
|
||||
ensureRepeatedFieldIsMutable();
|
||||
repeatedField_.set(index, builderForValue.build());
|
||||
onChanged();
|
||||
} else {
|
||||
repeatedFieldBuilder_.setMessage(index, builderForValue.build());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage repeated_field = 1;</code>
|
||||
*/
|
||||
public Builder addRepeatedField(io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage value) {
|
||||
if (repeatedFieldBuilder_ == null) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
ensureRepeatedFieldIsMutable();
|
||||
repeatedField_.add(value);
|
||||
onChanged();
|
||||
} else {
|
||||
repeatedFieldBuilder_.addMessage(value);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage repeated_field = 1;</code>
|
||||
*/
|
||||
public Builder addRepeatedField(
|
||||
int index, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage value) {
|
||||
if (repeatedFieldBuilder_ == null) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
ensureRepeatedFieldIsMutable();
|
||||
repeatedField_.add(index, value);
|
||||
onChanged();
|
||||
} else {
|
||||
repeatedFieldBuilder_.addMessage(index, value);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage repeated_field = 1;</code>
|
||||
*/
|
||||
public Builder addRepeatedField(
|
||||
io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage.Builder builderForValue) {
|
||||
if (repeatedFieldBuilder_ == null) {
|
||||
ensureRepeatedFieldIsMutable();
|
||||
repeatedField_.add(builderForValue.build());
|
||||
onChanged();
|
||||
} else {
|
||||
repeatedFieldBuilder_.addMessage(builderForValue.build());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage repeated_field = 1;</code>
|
||||
*/
|
||||
public Builder addRepeatedField(
|
||||
int index, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage.Builder builderForValue) {
|
||||
if (repeatedFieldBuilder_ == null) {
|
||||
ensureRepeatedFieldIsMutable();
|
||||
repeatedField_.add(index, builderForValue.build());
|
||||
onChanged();
|
||||
} else {
|
||||
repeatedFieldBuilder_.addMessage(index, builderForValue.build());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage repeated_field = 1;</code>
|
||||
*/
|
||||
public Builder addAllRepeatedField(
|
||||
java.lang.Iterable<? extends io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage> values) {
|
||||
if (repeatedFieldBuilder_ == null) {
|
||||
ensureRepeatedFieldIsMutable();
|
||||
com.google.protobuf.AbstractMessageLite.Builder.addAll(
|
||||
values, repeatedField_);
|
||||
onChanged();
|
||||
} else {
|
||||
repeatedFieldBuilder_.addAllMessages(values);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage repeated_field = 1;</code>
|
||||
*/
|
||||
public Builder clearRepeatedField() {
|
||||
if (repeatedFieldBuilder_ == null) {
|
||||
repeatedField_ = java.util.Collections.emptyList();
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
onChanged();
|
||||
} else {
|
||||
repeatedFieldBuilder_.clear();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage repeated_field = 1;</code>
|
||||
*/
|
||||
public Builder removeRepeatedField(int index) {
|
||||
if (repeatedFieldBuilder_ == null) {
|
||||
ensureRepeatedFieldIsMutable();
|
||||
repeatedField_.remove(index);
|
||||
onChanged();
|
||||
} else {
|
||||
repeatedFieldBuilder_.remove(index);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage repeated_field = 1;</code>
|
||||
*/
|
||||
public io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage.Builder getRepeatedFieldBuilder(
|
||||
int index) {
|
||||
return getRepeatedFieldFieldBuilder().getBuilder(index);
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage repeated_field = 1;</code>
|
||||
*/
|
||||
public io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessageOrBuilder getRepeatedFieldOrBuilder(
|
||||
int index) {
|
||||
if (repeatedFieldBuilder_ == null) {
|
||||
return repeatedField_.get(index); } else {
|
||||
return repeatedFieldBuilder_.getMessageOrBuilder(index);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage repeated_field = 1;</code>
|
||||
*/
|
||||
public java.util.List<? extends io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessageOrBuilder>
|
||||
getRepeatedFieldOrBuilderList() {
|
||||
if (repeatedFieldBuilder_ != null) {
|
||||
return repeatedFieldBuilder_.getMessageOrBuilderList();
|
||||
} else {
|
||||
return java.util.Collections.unmodifiableList(repeatedField_);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage repeated_field = 1;</code>
|
||||
*/
|
||||
public io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage.Builder addRepeatedFieldBuilder() {
|
||||
return getRepeatedFieldFieldBuilder().addBuilder(
|
||||
io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage.getDefaultInstance());
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage repeated_field = 1;</code>
|
||||
*/
|
||||
public io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage.Builder addRepeatedFieldBuilder(
|
||||
int index) {
|
||||
return getRepeatedFieldFieldBuilder().addBuilder(
|
||||
index, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage.getDefaultInstance());
|
||||
}
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage repeated_field = 1;</code>
|
||||
*/
|
||||
public java.util.List<io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage.Builder>
|
||||
getRepeatedFieldBuilderList() {
|
||||
return getRepeatedFieldFieldBuilder().getBuilderList();
|
||||
}
|
||||
private com.google.protobuf.RepeatedFieldBuilderV3<
|
||||
io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage.Builder, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessageOrBuilder>
|
||||
getRepeatedFieldFieldBuilder() {
|
||||
if (repeatedFieldBuilder_ == null) {
|
||||
repeatedFieldBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
|
||||
io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage.Builder, io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessageOrBuilder>(
|
||||
repeatedField_,
|
||||
((bitField0_ & 0x00000001) != 0),
|
||||
getParentForChildren(),
|
||||
isClean());
|
||||
repeatedField_ = null;
|
||||
}
|
||||
return repeatedFieldBuilder_;
|
||||
}
|
||||
@java.lang.Override
|
||||
public final Builder setUnknownFields(
|
||||
final com.google.protobuf.UnknownFieldSet unknownFields) {
|
||||
return super.setUnknownFields(unknownFields);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public final Builder mergeUnknownFields(
|
||||
final com.google.protobuf.UnknownFieldSet unknownFields) {
|
||||
return super.mergeUnknownFields(unknownFields);
|
||||
}
|
||||
|
||||
|
||||
// @@protoc_insertion_point(builder_scope:io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage)
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(class_scope:io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage)
|
||||
private static final io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage DEFAULT_INSTANCE;
|
||||
static {
|
||||
DEFAULT_INSTANCE = new io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage();
|
||||
}
|
||||
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage getDefaultInstance() {
|
||||
return DEFAULT_INSTANCE;
|
||||
}
|
||||
|
||||
private static final com.google.protobuf.Parser<RepeatedMessage>
|
||||
PARSER = new com.google.protobuf.AbstractParser<RepeatedMessage>() {
|
||||
@java.lang.Override
|
||||
public RepeatedMessage parsePartialFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return new RepeatedMessage(input, extensionRegistry);
|
||||
}
|
||||
};
|
||||
|
||||
public static com.google.protobuf.Parser<RepeatedMessage> parser() {
|
||||
return PARSER;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.Parser<RepeatedMessage> getParserForType() {
|
||||
return PARSER;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage getDefaultInstanceForType() {
|
||||
return DEFAULT_INSTANCE;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,33 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: io/bkbn/kompendium/protobufjavaconverter/converters/test.proto
|
||||
|
||||
package io.bkbn.kompendium.protobufjavaconverter;
|
||||
|
||||
public interface RepeatedMessageOrBuilder extends
|
||||
// @@protoc_insertion_point(interface_extends:io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage)
|
||||
com.google.protobuf.MessageOrBuilder {
|
||||
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage repeated_field = 1;</code>
|
||||
*/
|
||||
java.util.List<io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage>
|
||||
getRepeatedFieldList();
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage repeated_field = 1;</code>
|
||||
*/
|
||||
io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage getRepeatedField(int index);
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage repeated_field = 1;</code>
|
||||
*/
|
||||
int getRepeatedFieldCount();
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage repeated_field = 1;</code>
|
||||
*/
|
||||
java.util.List<? extends io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessageOrBuilder>
|
||||
getRepeatedFieldOrBuilderList();
|
||||
/**
|
||||
* <code>repeated .io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage repeated_field = 1;</code>
|
||||
*/
|
||||
io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessageOrBuilder getRepeatedFieldOrBuilder(
|
||||
int index);
|
||||
}
|
@ -0,0 +1,705 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: io/bkbn/kompendium/protobufjavaconverter/converters/test.proto
|
||||
|
||||
package io.bkbn.kompendium.protobufjavaconverter;
|
||||
|
||||
/**
|
||||
* Protobuf type {@code io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage}
|
||||
*/
|
||||
public final class SimpleMapMessage extends
|
||||
com.google.protobuf.GeneratedMessageV3 implements
|
||||
// @@protoc_insertion_point(message_implements:io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage)
|
||||
SimpleMapMessageOrBuilder {
|
||||
private static final long serialVersionUID = 0L;
|
||||
// Use SimpleMapMessage.newBuilder() to construct.
|
||||
private SimpleMapMessage(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
|
||||
super(builder);
|
||||
}
|
||||
private SimpleMapMessage() {
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
@SuppressWarnings({"unused"})
|
||||
protected java.lang.Object newInstance(
|
||||
UnusedPrivateParameter unused) {
|
||||
return new SimpleMapMessage();
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public final com.google.protobuf.UnknownFieldSet
|
||||
getUnknownFields() {
|
||||
return this.unknownFields;
|
||||
}
|
||||
private SimpleMapMessage(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
this();
|
||||
if (extensionRegistry == null) {
|
||||
throw new java.lang.NullPointerException();
|
||||
}
|
||||
int mutable_bitField0_ = 0;
|
||||
com.google.protobuf.UnknownFieldSet.Builder unknownFields =
|
||||
com.google.protobuf.UnknownFieldSet.newBuilder();
|
||||
try {
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
int tag = input.readTag();
|
||||
switch (tag) {
|
||||
case 0:
|
||||
done = true;
|
||||
break;
|
||||
case 10: {
|
||||
if (!((mutable_bitField0_ & 0x00000001) != 0)) {
|
||||
mapField_ = com.google.protobuf.MapField.newMapField(
|
||||
MapFieldDefaultEntryHolder.defaultEntry);
|
||||
mutable_bitField0_ |= 0x00000001;
|
||||
}
|
||||
com.google.protobuf.MapEntry<java.lang.String, java.lang.Integer>
|
||||
mapField__ = input.readMessage(
|
||||
MapFieldDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry);
|
||||
mapField_.getMutableMap().put(
|
||||
mapField__.getKey(), mapField__.getValue());
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
if (!parseUnknownField(
|
||||
input, unknownFields, extensionRegistry, tag)) {
|
||||
done = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
||||
throw e.setUnfinishedMessage(this);
|
||||
} catch (java.io.IOException e) {
|
||||
throw new com.google.protobuf.InvalidProtocolBufferException(
|
||||
e).setUnfinishedMessage(this);
|
||||
} finally {
|
||||
this.unknownFields = unknownFields.build();
|
||||
makeExtensionsImmutable();
|
||||
}
|
||||
}
|
||||
public static final com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptor() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_SimpleMapMessage_descriptor;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"rawtypes"})
|
||||
@java.lang.Override
|
||||
protected com.google.protobuf.MapField internalGetMapField(
|
||||
int number) {
|
||||
switch (number) {
|
||||
case 1:
|
||||
return internalGetMapField();
|
||||
default:
|
||||
throw new RuntimeException(
|
||||
"Invalid map field number: " + number);
|
||||
}
|
||||
}
|
||||
@java.lang.Override
|
||||
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internalGetFieldAccessorTable() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_SimpleMapMessage_fieldAccessorTable
|
||||
.ensureFieldAccessorsInitialized(
|
||||
io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage.class, io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage.Builder.class);
|
||||
}
|
||||
|
||||
public static final int MAP_FIELD_FIELD_NUMBER = 1;
|
||||
private static final class MapFieldDefaultEntryHolder {
|
||||
static final com.google.protobuf.MapEntry<
|
||||
java.lang.String, java.lang.Integer> defaultEntry =
|
||||
com.google.protobuf.MapEntry
|
||||
.<java.lang.String, java.lang.Integer>newDefaultInstance(
|
||||
io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_SimpleMapMessage_MapFieldEntry_descriptor,
|
||||
com.google.protobuf.WireFormat.FieldType.STRING,
|
||||
"",
|
||||
com.google.protobuf.WireFormat.FieldType.INT32,
|
||||
0);
|
||||
}
|
||||
private com.google.protobuf.MapField<
|
||||
java.lang.String, java.lang.Integer> mapField_;
|
||||
private com.google.protobuf.MapField<java.lang.String, java.lang.Integer>
|
||||
internalGetMapField() {
|
||||
if (mapField_ == null) {
|
||||
return com.google.protobuf.MapField.emptyMapField(
|
||||
MapFieldDefaultEntryHolder.defaultEntry);
|
||||
}
|
||||
return mapField_;
|
||||
}
|
||||
|
||||
public int getMapFieldCount() {
|
||||
return internalGetMapField().getMap().size();
|
||||
}
|
||||
/**
|
||||
* <code>map<string, int32> map_field = 1;</code>
|
||||
*/
|
||||
|
||||
@java.lang.Override
|
||||
public boolean containsMapField(
|
||||
java.lang.String key) {
|
||||
if (key == null) { throw new java.lang.NullPointerException(); }
|
||||
return internalGetMapField().getMap().containsKey(key);
|
||||
}
|
||||
/**
|
||||
* Use {@link #getMapFieldMap()} instead.
|
||||
*/
|
||||
@java.lang.Override
|
||||
@java.lang.Deprecated
|
||||
public java.util.Map<java.lang.String, java.lang.Integer> getMapField() {
|
||||
return getMapFieldMap();
|
||||
}
|
||||
/**
|
||||
* <code>map<string, int32> map_field = 1;</code>
|
||||
*/
|
||||
@java.lang.Override
|
||||
|
||||
public java.util.Map<java.lang.String, java.lang.Integer> getMapFieldMap() {
|
||||
return internalGetMapField().getMap();
|
||||
}
|
||||
/**
|
||||
* <code>map<string, int32> map_field = 1;</code>
|
||||
*/
|
||||
@java.lang.Override
|
||||
|
||||
public int getMapFieldOrDefault(
|
||||
java.lang.String key,
|
||||
int defaultValue) {
|
||||
if (key == null) { throw new java.lang.NullPointerException(); }
|
||||
java.util.Map<java.lang.String, java.lang.Integer> map =
|
||||
internalGetMapField().getMap();
|
||||
return map.containsKey(key) ? map.get(key) : defaultValue;
|
||||
}
|
||||
/**
|
||||
* <code>map<string, int32> map_field = 1;</code>
|
||||
*/
|
||||
@java.lang.Override
|
||||
|
||||
public int getMapFieldOrThrow(
|
||||
java.lang.String key) {
|
||||
if (key == null) { throw new java.lang.NullPointerException(); }
|
||||
java.util.Map<java.lang.String, java.lang.Integer> map =
|
||||
internalGetMapField().getMap();
|
||||
if (!map.containsKey(key)) {
|
||||
throw new java.lang.IllegalArgumentException();
|
||||
}
|
||||
return map.get(key);
|
||||
}
|
||||
|
||||
private byte memoizedIsInitialized = -1;
|
||||
@java.lang.Override
|
||||
public final boolean isInitialized() {
|
||||
byte isInitialized = memoizedIsInitialized;
|
||||
if (isInitialized == 1) return true;
|
||||
if (isInitialized == 0) return false;
|
||||
|
||||
memoizedIsInitialized = 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public void writeTo(com.google.protobuf.CodedOutputStream output)
|
||||
throws java.io.IOException {
|
||||
com.google.protobuf.GeneratedMessageV3
|
||||
.serializeStringMapTo(
|
||||
output,
|
||||
internalGetMapField(),
|
||||
MapFieldDefaultEntryHolder.defaultEntry,
|
||||
1);
|
||||
unknownFields.writeTo(output);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public int getSerializedSize() {
|
||||
int size = memoizedSize;
|
||||
if (size != -1) return size;
|
||||
|
||||
size = 0;
|
||||
for (java.util.Map.Entry<java.lang.String, java.lang.Integer> entry
|
||||
: internalGetMapField().getMap().entrySet()) {
|
||||
com.google.protobuf.MapEntry<java.lang.String, java.lang.Integer>
|
||||
mapField__ = MapFieldDefaultEntryHolder.defaultEntry.newBuilderForType()
|
||||
.setKey(entry.getKey())
|
||||
.setValue(entry.getValue())
|
||||
.build();
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeMessageSize(1, mapField__);
|
||||
}
|
||||
size += unknownFields.getSerializedSize();
|
||||
memoizedSize = size;
|
||||
return size;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public boolean equals(final java.lang.Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage)) {
|
||||
return super.equals(obj);
|
||||
}
|
||||
io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage other = (io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage) obj;
|
||||
|
||||
if (!internalGetMapField().equals(
|
||||
other.internalGetMapField())) return false;
|
||||
if (!unknownFields.equals(other.unknownFields)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public int hashCode() {
|
||||
if (memoizedHashCode != 0) {
|
||||
return memoizedHashCode;
|
||||
}
|
||||
int hash = 41;
|
||||
hash = (19 * hash) + getDescriptor().hashCode();
|
||||
if (!internalGetMapField().getMap().isEmpty()) {
|
||||
hash = (37 * hash) + MAP_FIELD_FIELD_NUMBER;
|
||||
hash = (53 * hash) + internalGetMapField().hashCode();
|
||||
}
|
||||
hash = (29 * hash) + unknownFields.hashCode();
|
||||
memoizedHashCode = hash;
|
||||
return hash;
|
||||
}
|
||||
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage parseFrom(
|
||||
java.nio.ByteBuffer data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage parseFrom(
|
||||
java.nio.ByteBuffer data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage parseFrom(
|
||||
com.google.protobuf.ByteString data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage parseFrom(
|
||||
com.google.protobuf.ByteString data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage parseFrom(byte[] data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage parseFrom(
|
||||
byte[] data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage parseFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage parseFrom(
|
||||
java.io.InputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage parseDelimitedFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseDelimitedWithIOException(PARSER, input);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage parseDelimitedFrom(
|
||||
java.io.InputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseDelimitedWithIOException(PARSER, input, extensionRegistry);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage parseFrom(
|
||||
com.google.protobuf.CodedInputStream input)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input);
|
||||
}
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage parseFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input, extensionRegistry);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder newBuilderForType() { return newBuilder(); }
|
||||
public static Builder newBuilder() {
|
||||
return DEFAULT_INSTANCE.toBuilder();
|
||||
}
|
||||
public static Builder newBuilder(io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage prototype) {
|
||||
return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder toBuilder() {
|
||||
return this == DEFAULT_INSTANCE
|
||||
? new Builder() : new Builder().mergeFrom(this);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected Builder newBuilderForType(
|
||||
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
|
||||
Builder builder = new Builder(parent);
|
||||
return builder;
|
||||
}
|
||||
/**
|
||||
* Protobuf type {@code io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage}
|
||||
*/
|
||||
public static final class Builder extends
|
||||
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
|
||||
// @@protoc_insertion_point(builder_implements:io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage)
|
||||
io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessageOrBuilder {
|
||||
public static final com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptor() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_SimpleMapMessage_descriptor;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"rawtypes"})
|
||||
protected com.google.protobuf.MapField internalGetMapField(
|
||||
int number) {
|
||||
switch (number) {
|
||||
case 1:
|
||||
return internalGetMapField();
|
||||
default:
|
||||
throw new RuntimeException(
|
||||
"Invalid map field number: " + number);
|
||||
}
|
||||
}
|
||||
@SuppressWarnings({"rawtypes"})
|
||||
protected com.google.protobuf.MapField internalGetMutableMapField(
|
||||
int number) {
|
||||
switch (number) {
|
||||
case 1:
|
||||
return internalGetMutableMapField();
|
||||
default:
|
||||
throw new RuntimeException(
|
||||
"Invalid map field number: " + number);
|
||||
}
|
||||
}
|
||||
@java.lang.Override
|
||||
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internalGetFieldAccessorTable() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_SimpleMapMessage_fieldAccessorTable
|
||||
.ensureFieldAccessorsInitialized(
|
||||
io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage.class, io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage.Builder.class);
|
||||
}
|
||||
|
||||
// Construct using io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage.newBuilder()
|
||||
private Builder() {
|
||||
maybeForceBuilderInitialization();
|
||||
}
|
||||
|
||||
private Builder(
|
||||
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
|
||||
super(parent);
|
||||
maybeForceBuilderInitialization();
|
||||
}
|
||||
private void maybeForceBuilderInitialization() {
|
||||
if (com.google.protobuf.GeneratedMessageV3
|
||||
.alwaysUseFieldBuilders) {
|
||||
}
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder clear() {
|
||||
super.clear();
|
||||
internalGetMutableMapField().clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptorForType() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.Test.internal_static_io_bkbn_kompendium_protobufjavaconverter_SimpleMapMessage_descriptor;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage getDefaultInstanceForType() {
|
||||
return io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage.getDefaultInstance();
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage build() {
|
||||
io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage result = buildPartial();
|
||||
if (!result.isInitialized()) {
|
||||
throw newUninitializedMessageException(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage buildPartial() {
|
||||
io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage result = new io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage(this);
|
||||
int from_bitField0_ = bitField0_;
|
||||
result.mapField_ = internalGetMapField();
|
||||
result.mapField_.makeImmutable();
|
||||
onBuilt();
|
||||
return result;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder clone() {
|
||||
return super.clone();
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder setField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field,
|
||||
java.lang.Object value) {
|
||||
return super.setField(field, value);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder clearField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field) {
|
||||
return super.clearField(field);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder clearOneof(
|
||||
com.google.protobuf.Descriptors.OneofDescriptor oneof) {
|
||||
return super.clearOneof(oneof);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder setRepeatedField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field,
|
||||
int index, java.lang.Object value) {
|
||||
return super.setRepeatedField(field, index, value);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder addRepeatedField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field,
|
||||
java.lang.Object value) {
|
||||
return super.addRepeatedField(field, value);
|
||||
}
|
||||
@java.lang.Override
|
||||
public Builder mergeFrom(com.google.protobuf.Message other) {
|
||||
if (other instanceof io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage) {
|
||||
return mergeFrom((io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage)other);
|
||||
} else {
|
||||
super.mergeFrom(other);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public Builder mergeFrom(io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage other) {
|
||||
if (other == io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage.getDefaultInstance()) return this;
|
||||
internalGetMutableMapField().mergeFrom(
|
||||
other.internalGetMapField());
|
||||
this.mergeUnknownFields(other.unknownFields);
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public final boolean isInitialized() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder mergeFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage parsedMessage = null;
|
||||
try {
|
||||
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
|
||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
||||
parsedMessage = (io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage) e.getUnfinishedMessage();
|
||||
throw e.unwrapIOException();
|
||||
} finally {
|
||||
if (parsedMessage != null) {
|
||||
mergeFrom(parsedMessage);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
private int bitField0_;
|
||||
|
||||
private com.google.protobuf.MapField<
|
||||
java.lang.String, java.lang.Integer> mapField_;
|
||||
private com.google.protobuf.MapField<java.lang.String, java.lang.Integer>
|
||||
internalGetMapField() {
|
||||
if (mapField_ == null) {
|
||||
return com.google.protobuf.MapField.emptyMapField(
|
||||
MapFieldDefaultEntryHolder.defaultEntry);
|
||||
}
|
||||
return mapField_;
|
||||
}
|
||||
private com.google.protobuf.MapField<java.lang.String, java.lang.Integer>
|
||||
internalGetMutableMapField() {
|
||||
onChanged();;
|
||||
if (mapField_ == null) {
|
||||
mapField_ = com.google.protobuf.MapField.newMapField(
|
||||
MapFieldDefaultEntryHolder.defaultEntry);
|
||||
}
|
||||
if (!mapField_.isMutable()) {
|
||||
mapField_ = mapField_.copy();
|
||||
}
|
||||
return mapField_;
|
||||
}
|
||||
|
||||
public int getMapFieldCount() {
|
||||
return internalGetMapField().getMap().size();
|
||||
}
|
||||
/**
|
||||
* <code>map<string, int32> map_field = 1;</code>
|
||||
*/
|
||||
|
||||
@java.lang.Override
|
||||
public boolean containsMapField(
|
||||
java.lang.String key) {
|
||||
if (key == null) { throw new java.lang.NullPointerException(); }
|
||||
return internalGetMapField().getMap().containsKey(key);
|
||||
}
|
||||
/**
|
||||
* Use {@link #getMapFieldMap()} instead.
|
||||
*/
|
||||
@java.lang.Override
|
||||
@java.lang.Deprecated
|
||||
public java.util.Map<java.lang.String, java.lang.Integer> getMapField() {
|
||||
return getMapFieldMap();
|
||||
}
|
||||
/**
|
||||
* <code>map<string, int32> map_field = 1;</code>
|
||||
*/
|
||||
@java.lang.Override
|
||||
|
||||
public java.util.Map<java.lang.String, java.lang.Integer> getMapFieldMap() {
|
||||
return internalGetMapField().getMap();
|
||||
}
|
||||
/**
|
||||
* <code>map<string, int32> map_field = 1;</code>
|
||||
*/
|
||||
@java.lang.Override
|
||||
|
||||
public int getMapFieldOrDefault(
|
||||
java.lang.String key,
|
||||
int defaultValue) {
|
||||
if (key == null) { throw new java.lang.NullPointerException(); }
|
||||
java.util.Map<java.lang.String, java.lang.Integer> map =
|
||||
internalGetMapField().getMap();
|
||||
return map.containsKey(key) ? map.get(key) : defaultValue;
|
||||
}
|
||||
/**
|
||||
* <code>map<string, int32> map_field = 1;</code>
|
||||
*/
|
||||
@java.lang.Override
|
||||
|
||||
public int getMapFieldOrThrow(
|
||||
java.lang.String key) {
|
||||
if (key == null) { throw new java.lang.NullPointerException(); }
|
||||
java.util.Map<java.lang.String, java.lang.Integer> map =
|
||||
internalGetMapField().getMap();
|
||||
if (!map.containsKey(key)) {
|
||||
throw new java.lang.IllegalArgumentException();
|
||||
}
|
||||
return map.get(key);
|
||||
}
|
||||
|
||||
public Builder clearMapField() {
|
||||
internalGetMutableMapField().getMutableMap()
|
||||
.clear();
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>map<string, int32> map_field = 1;</code>
|
||||
*/
|
||||
|
||||
public Builder removeMapField(
|
||||
java.lang.String key) {
|
||||
if (key == null) { throw new java.lang.NullPointerException(); }
|
||||
internalGetMutableMapField().getMutableMap()
|
||||
.remove(key);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Use alternate mutation accessors instead.
|
||||
*/
|
||||
@java.lang.Deprecated
|
||||
public java.util.Map<java.lang.String, java.lang.Integer>
|
||||
getMutableMapField() {
|
||||
return internalGetMutableMapField().getMutableMap();
|
||||
}
|
||||
/**
|
||||
* <code>map<string, int32> map_field = 1;</code>
|
||||
*/
|
||||
public Builder putMapField(
|
||||
java.lang.String key,
|
||||
int value) {
|
||||
if (key == null) { throw new java.lang.NullPointerException(); }
|
||||
|
||||
internalGetMutableMapField().getMutableMap()
|
||||
.put(key, value);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>map<string, int32> map_field = 1;</code>
|
||||
*/
|
||||
|
||||
public Builder putAllMapField(
|
||||
java.util.Map<java.lang.String, java.lang.Integer> values) {
|
||||
internalGetMutableMapField().getMutableMap()
|
||||
.putAll(values);
|
||||
return this;
|
||||
}
|
||||
@java.lang.Override
|
||||
public final Builder setUnknownFields(
|
||||
final com.google.protobuf.UnknownFieldSet unknownFields) {
|
||||
return super.setUnknownFields(unknownFields);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public final Builder mergeUnknownFields(
|
||||
final com.google.protobuf.UnknownFieldSet unknownFields) {
|
||||
return super.mergeUnknownFields(unknownFields);
|
||||
}
|
||||
|
||||
|
||||
// @@protoc_insertion_point(builder_scope:io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage)
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(class_scope:io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage)
|
||||
private static final io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage DEFAULT_INSTANCE;
|
||||
static {
|
||||
DEFAULT_INSTANCE = new io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage();
|
||||
}
|
||||
|
||||
public static io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage getDefaultInstance() {
|
||||
return DEFAULT_INSTANCE;
|
||||
}
|
||||
|
||||
private static final com.google.protobuf.Parser<SimpleMapMessage>
|
||||
PARSER = new com.google.protobuf.AbstractParser<SimpleMapMessage>() {
|
||||
@java.lang.Override
|
||||
public SimpleMapMessage parsePartialFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return new SimpleMapMessage(input, extensionRegistry);
|
||||
}
|
||||
};
|
||||
|
||||
public static com.google.protobuf.Parser<SimpleMapMessage> parser() {
|
||||
return PARSER;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.Parser<SimpleMapMessage> getParserForType() {
|
||||
return PARSER;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage getDefaultInstanceForType() {
|
||||
return DEFAULT_INSTANCE;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,43 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: io/bkbn/kompendium/protobufjavaconverter/converters/test.proto
|
||||
|
||||
package io.bkbn.kompendium.protobufjavaconverter;
|
||||
|
||||
public interface SimpleMapMessageOrBuilder extends
|
||||
// @@protoc_insertion_point(interface_extends:io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage)
|
||||
com.google.protobuf.MessageOrBuilder {
|
||||
|
||||
/**
|
||||
* <code>map<string, int32> map_field = 1;</code>
|
||||
*/
|
||||
int getMapFieldCount();
|
||||
/**
|
||||
* <code>map<string, int32> map_field = 1;</code>
|
||||
*/
|
||||
boolean containsMapField(
|
||||
java.lang.String key);
|
||||
/**
|
||||
* Use {@link #getMapFieldMap()} instead.
|
||||
*/
|
||||
@java.lang.Deprecated
|
||||
java.util.Map<java.lang.String, java.lang.Integer>
|
||||
getMapField();
|
||||
/**
|
||||
* <code>map<string, int32> map_field = 1;</code>
|
||||
*/
|
||||
java.util.Map<java.lang.String, java.lang.Integer>
|
||||
getMapFieldMap();
|
||||
/**
|
||||
* <code>map<string, int32> map_field = 1;</code>
|
||||
*/
|
||||
|
||||
int getMapFieldOrDefault(
|
||||
java.lang.String key,
|
||||
int defaultValue);
|
||||
/**
|
||||
* <code>map<string, int32> map_field = 1;</code>
|
||||
*/
|
||||
|
||||
int getMapFieldOrThrow(
|
||||
java.lang.String key);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,105 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: io/bkbn/kompendium/protobufjavaconverter/converters/test.proto
|
||||
|
||||
package io.bkbn.kompendium.protobufjavaconverter;
|
||||
|
||||
public interface SimpleTestMessageOrBuilder extends
|
||||
// @@protoc_insertion_point(interface_extends:io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage)
|
||||
com.google.protobuf.MessageOrBuilder {
|
||||
|
||||
/**
|
||||
* <code>double my_test_double = 1;</code>
|
||||
* @return The myTestDouble.
|
||||
*/
|
||||
double getMyTestDouble();
|
||||
|
||||
/**
|
||||
* <code>float my_test_float = 2;</code>
|
||||
* @return The myTestFloat.
|
||||
*/
|
||||
float getMyTestFloat();
|
||||
|
||||
/**
|
||||
* <code>int32 my_test_int32 = 3;</code>
|
||||
* @return The myTestInt32.
|
||||
*/
|
||||
int getMyTestInt32();
|
||||
|
||||
/**
|
||||
* <code>int64 my_test_int64 = 4;</code>
|
||||
* @return The myTestInt64.
|
||||
*/
|
||||
long getMyTestInt64();
|
||||
|
||||
/**
|
||||
* <code>uint32 my_test_uint32 = 5;</code>
|
||||
* @return The myTestUint32.
|
||||
*/
|
||||
int getMyTestUint32();
|
||||
|
||||
/**
|
||||
* <code>uint64 my_test_uint64 = 6;</code>
|
||||
* @return The myTestUint64.
|
||||
*/
|
||||
long getMyTestUint64();
|
||||
|
||||
/**
|
||||
* <code>sint32 my_test_sint32 = 7;</code>
|
||||
* @return The myTestSint32.
|
||||
*/
|
||||
int getMyTestSint32();
|
||||
|
||||
/**
|
||||
* <code>sint64 my_test_sint64 = 8;</code>
|
||||
* @return The myTestSint64.
|
||||
*/
|
||||
long getMyTestSint64();
|
||||
|
||||
/**
|
||||
* <code>fixed32 my_test_fixed32 = 9;</code>
|
||||
* @return The myTestFixed32.
|
||||
*/
|
||||
int getMyTestFixed32();
|
||||
|
||||
/**
|
||||
* <code>fixed64 my_test_fixed64 = 10;</code>
|
||||
* @return The myTestFixed64.
|
||||
*/
|
||||
long getMyTestFixed64();
|
||||
|
||||
/**
|
||||
* <code>sfixed32 my_test_sfixed32 = 11;</code>
|
||||
* @return The myTestSfixed32.
|
||||
*/
|
||||
int getMyTestSfixed32();
|
||||
|
||||
/**
|
||||
* <code>sfixed64 my_test_sfixed64 = 12;</code>
|
||||
* @return The myTestSfixed64.
|
||||
*/
|
||||
long getMyTestSfixed64();
|
||||
|
||||
/**
|
||||
* <code>bool my_test_bool = 13;</code>
|
||||
* @return The myTestBool.
|
||||
*/
|
||||
boolean getMyTestBool();
|
||||
|
||||
/**
|
||||
* <code>bytes my_test_bytes = 14;</code>
|
||||
* @return The myTestBytes.
|
||||
*/
|
||||
com.google.protobuf.ByteString getMyTestBytes();
|
||||
|
||||
/**
|
||||
* <code>string my_test_string = 15;</code>
|
||||
* @return The myTestString.
|
||||
*/
|
||||
java.lang.String getMyTestString();
|
||||
/**
|
||||
* <code>string my_test_string = 15;</code>
|
||||
* @return The bytes for myTestString.
|
||||
*/
|
||||
com.google.protobuf.ByteString
|
||||
getMyTestStringBytes();
|
||||
}
|
@ -0,0 +1,204 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: io/bkbn/kompendium/protobufjavaconverter/converters/test.proto
|
||||
|
||||
package io.bkbn.kompendium.protobufjavaconverter;
|
||||
|
||||
public final class Test {
|
||||
private Test() {}
|
||||
public static void registerAllExtensions(
|
||||
com.google.protobuf.ExtensionRegistryLite registry) {
|
||||
}
|
||||
|
||||
public static void registerAllExtensions(
|
||||
com.google.protobuf.ExtensionRegistry registry) {
|
||||
registerAllExtensions(
|
||||
(com.google.protobuf.ExtensionRegistryLite) registry);
|
||||
}
|
||||
static final com.google.protobuf.Descriptors.Descriptor
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_SimpleTestMessage_descriptor;
|
||||
static final
|
||||
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_SimpleTestMessage_fieldAccessorTable;
|
||||
static final com.google.protobuf.Descriptors.Descriptor
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_EnumMessage_descriptor;
|
||||
static final
|
||||
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_EnumMessage_fieldAccessorTable;
|
||||
static final com.google.protobuf.Descriptors.Descriptor
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_NestedMessage_descriptor;
|
||||
static final
|
||||
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_NestedMessage_fieldAccessorTable;
|
||||
static final com.google.protobuf.Descriptors.Descriptor
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_DoubleNestedMessage_descriptor;
|
||||
static final
|
||||
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_DoubleNestedMessage_fieldAccessorTable;
|
||||
static final com.google.protobuf.Descriptors.Descriptor
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_RepeatedMessage_descriptor;
|
||||
static final
|
||||
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_RepeatedMessage_fieldAccessorTable;
|
||||
static final com.google.protobuf.Descriptors.Descriptor
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_RepeatedEnumMessage_descriptor;
|
||||
static final
|
||||
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_RepeatedEnumMessage_fieldAccessorTable;
|
||||
static final com.google.protobuf.Descriptors.Descriptor
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_SimpleMapMessage_descriptor;
|
||||
static final
|
||||
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_SimpleMapMessage_fieldAccessorTable;
|
||||
static final com.google.protobuf.Descriptors.Descriptor
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_SimpleMapMessage_MapFieldEntry_descriptor;
|
||||
static final
|
||||
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_SimpleMapMessage_MapFieldEntry_fieldAccessorTable;
|
||||
static final com.google.protobuf.Descriptors.Descriptor
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_NestedMapMessage_descriptor;
|
||||
static final
|
||||
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_NestedMapMessage_fieldAccessorTable;
|
||||
static final com.google.protobuf.Descriptors.Descriptor
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_NestedMapMessage_MapFieldEntry_descriptor;
|
||||
static final
|
||||
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_NestedMapMessage_MapFieldEntry_fieldAccessorTable;
|
||||
static final com.google.protobuf.Descriptors.Descriptor
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_GoogleTypes_descriptor;
|
||||
static final
|
||||
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_GoogleTypes_fieldAccessorTable;
|
||||
|
||||
public static com.google.protobuf.Descriptors.FileDescriptor
|
||||
getDescriptor() {
|
||||
return descriptor;
|
||||
}
|
||||
private static com.google.protobuf.Descriptors.FileDescriptor
|
||||
descriptor;
|
||||
static {
|
||||
java.lang.String[] descriptorData = {
|
||||
"\n>io/bkbn/kompendium/protobufjavaconvert" +
|
||||
"er/converters/test.proto\022(io.bkbn.kompen" +
|
||||
"dium.protobufjavaconverter\032\037google/proto" +
|
||||
"buf/timestamp.proto\032\036google/protobuf/dur" +
|
||||
"ation.proto\"\373\002\n\021SimpleTestMessage\022\026\n\016my_" +
|
||||
"test_double\030\001 \001(\001\022\025\n\rmy_test_float\030\002 \001(\002" +
|
||||
"\022\025\n\rmy_test_int32\030\003 \001(\005\022\025\n\rmy_test_int64" +
|
||||
"\030\004 \001(\003\022\026\n\016my_test_uint32\030\005 \001(\r\022\026\n\016my_tes" +
|
||||
"t_uint64\030\006 \001(\004\022\026\n\016my_test_sint32\030\007 \001(\021\022\026" +
|
||||
"\n\016my_test_sint64\030\010 \001(\022\022\027\n\017my_test_fixed3" +
|
||||
"2\030\t \001(\007\022\027\n\017my_test_fixed64\030\n \001(\006\022\030\n\020my_t" +
|
||||
"est_sfixed32\030\013 \001(\017\022\030\n\020my_test_sfixed64\030\014" +
|
||||
" \001(\020\022\024\n\014my_test_bool\030\r \001(\010\022\025\n\rmy_test_by" +
|
||||
"tes\030\016 \001(\014\022\026\n\016my_test_string\030\017 \001(\t\"O\n\013Enu" +
|
||||
"mMessage\022@\n\006corpus\030\001 \001(\01620.io.bkbn.kompe" +
|
||||
"ndium.protobufjavaconverter.Corpus\"b\n\rNe" +
|
||||
"stedMessage\022Q\n\014nested_field\030\001 \001(\0132;.io.b" +
|
||||
"kbn.kompendium.protobufjavaconverter.Sim" +
|
||||
"pleTestMessage\"d\n\023DoubleNestedMessage\022M\n" +
|
||||
"\014nested_field\030\001 \001(\01327.io.bkbn.kompendium" +
|
||||
".protobufjavaconverter.NestedMessage\"f\n\017" +
|
||||
"RepeatedMessage\022S\n\016repeated_field\030\001 \003(\0132" +
|
||||
";.io.bkbn.kompendium.protobufjavaconvert" +
|
||||
"er.SimpleTestMessage\"_\n\023RepeatedEnumMess" +
|
||||
"age\022H\n\016repeated_field\030\001 \003(\01620.io.bkbn.ko" +
|
||||
"mpendium.protobufjavaconverter.Corpus\"\240\001" +
|
||||
"\n\020SimpleMapMessage\022[\n\tmap_field\030\001 \003(\0132H." +
|
||||
"io.bkbn.kompendium.protobufjavaconverter" +
|
||||
".SimpleMapMessage.MapFieldEntry\032/\n\rMapFi" +
|
||||
"eldEntry\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\005:\0028\001" +
|
||||
"\"\335\001\n\020NestedMapMessage\022[\n\tmap_field\030\001 \003(\013" +
|
||||
"2H.io.bkbn.kompendium.protobufjavaconver" +
|
||||
"ter.NestedMapMessage.MapFieldEntry\032l\n\rMa" +
|
||||
"pFieldEntry\022\013\n\003key\030\001 \001(\t\022J\n\005value\030\002 \001(\0132" +
|
||||
";.io.bkbn.kompendium.protobufjavaconvert" +
|
||||
"er.SimpleTestMessage:\0028\001\"u\n\013GoogleTypes\022" +
|
||||
"3\n\017timestamp_field\030\001 \001(\0132\032.google.protob" +
|
||||
"uf.Timestamp\0221\n\016duration_field\030\002 \001(\0132\031.g" +
|
||||
"oogle.protobuf.Duration*\243\001\n\006Corpus\022\026\n\022CO" +
|
||||
"RPUS_UNSPECIFIED\020\000\022\024\n\020CORPUS_UNIVERSAL\020\001" +
|
||||
"\022\016\n\nCORPUS_WEB\020\002\022\021\n\rCORPUS_IMAGES\020\003\022\020\n\014C" +
|
||||
"ORPUS_LOCAL\020\004\022\017\n\013CORPUS_NEWS\020\005\022\023\n\017CORPUS" +
|
||||
"_PRODUCTS\020\006\022\020\n\014CORPUS_VIDEO\020\007B,\n(io.bkbn" +
|
||||
".kompendium.protobufjavaconverterP\001b\006pro" +
|
||||
"to3"
|
||||
};
|
||||
descriptor = com.google.protobuf.Descriptors.FileDescriptor
|
||||
.internalBuildGeneratedFileFrom(descriptorData,
|
||||
new com.google.protobuf.Descriptors.FileDescriptor[] {
|
||||
com.google.protobuf.TimestampProto.getDescriptor(),
|
||||
com.google.protobuf.DurationProto.getDescriptor(),
|
||||
});
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_SimpleTestMessage_descriptor =
|
||||
getDescriptor().getMessageTypes().get(0);
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_SimpleTestMessage_fieldAccessorTable = new
|
||||
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_SimpleTestMessage_descriptor,
|
||||
new java.lang.String[] { "MyTestDouble", "MyTestFloat", "MyTestInt32", "MyTestInt64", "MyTestUint32", "MyTestUint64", "MyTestSint32", "MyTestSint64", "MyTestFixed32", "MyTestFixed64", "MyTestSfixed32", "MyTestSfixed64", "MyTestBool", "MyTestBytes", "MyTestString", });
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_EnumMessage_descriptor =
|
||||
getDescriptor().getMessageTypes().get(1);
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_EnumMessage_fieldAccessorTable = new
|
||||
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_EnumMessage_descriptor,
|
||||
new java.lang.String[] { "Corpus", });
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_NestedMessage_descriptor =
|
||||
getDescriptor().getMessageTypes().get(2);
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_NestedMessage_fieldAccessorTable = new
|
||||
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_NestedMessage_descriptor,
|
||||
new java.lang.String[] { "NestedField", });
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_DoubleNestedMessage_descriptor =
|
||||
getDescriptor().getMessageTypes().get(3);
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_DoubleNestedMessage_fieldAccessorTable = new
|
||||
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_DoubleNestedMessage_descriptor,
|
||||
new java.lang.String[] { "NestedField", });
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_RepeatedMessage_descriptor =
|
||||
getDescriptor().getMessageTypes().get(4);
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_RepeatedMessage_fieldAccessorTable = new
|
||||
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_RepeatedMessage_descriptor,
|
||||
new java.lang.String[] { "RepeatedField", });
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_RepeatedEnumMessage_descriptor =
|
||||
getDescriptor().getMessageTypes().get(5);
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_RepeatedEnumMessage_fieldAccessorTable = new
|
||||
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_RepeatedEnumMessage_descriptor,
|
||||
new java.lang.String[] { "RepeatedField", });
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_SimpleMapMessage_descriptor =
|
||||
getDescriptor().getMessageTypes().get(6);
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_SimpleMapMessage_fieldAccessorTable = new
|
||||
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_SimpleMapMessage_descriptor,
|
||||
new java.lang.String[] { "MapField", });
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_SimpleMapMessage_MapFieldEntry_descriptor =
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_SimpleMapMessage_descriptor.getNestedTypes().get(0);
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_SimpleMapMessage_MapFieldEntry_fieldAccessorTable = new
|
||||
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_SimpleMapMessage_MapFieldEntry_descriptor,
|
||||
new java.lang.String[] { "Key", "Value", });
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_NestedMapMessage_descriptor =
|
||||
getDescriptor().getMessageTypes().get(7);
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_NestedMapMessage_fieldAccessorTable = new
|
||||
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_NestedMapMessage_descriptor,
|
||||
new java.lang.String[] { "MapField", });
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_NestedMapMessage_MapFieldEntry_descriptor =
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_NestedMapMessage_descriptor.getNestedTypes().get(0);
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_NestedMapMessage_MapFieldEntry_fieldAccessorTable = new
|
||||
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_NestedMapMessage_MapFieldEntry_descriptor,
|
||||
new java.lang.String[] { "Key", "Value", });
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_GoogleTypes_descriptor =
|
||||
getDescriptor().getMessageTypes().get(8);
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_GoogleTypes_fieldAccessorTable = new
|
||||
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
|
||||
internal_static_io_bkbn_kompendium_protobufjavaconverter_GoogleTypes_descriptor,
|
||||
new java.lang.String[] { "TimestampField", "DurationField", });
|
||||
com.google.protobuf.TimestampProto.getDescriptor();
|
||||
com.google.protobuf.DurationProto.getDescriptor();
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(outer_class_scope)
|
||||
}
|
@ -0,0 +1,258 @@
|
||||
package io.bkbn.kompendium.protobufjavaconverter.converters
|
||||
|
||||
import com.google.protobuf.Descriptors
|
||||
import com.google.protobuf.GeneratedMessageV3
|
||||
import io.bkbn.kompendium.json.schema.definition.ArrayDefinition
|
||||
import io.bkbn.kompendium.json.schema.definition.EnumDefinition
|
||||
import io.bkbn.kompendium.json.schema.definition.JsonSchema
|
||||
import io.bkbn.kompendium.json.schema.definition.MapDefinition
|
||||
import io.bkbn.kompendium.json.schema.definition.ReferenceDefinition
|
||||
import io.bkbn.kompendium.json.schema.definition.TypeDefinition
|
||||
import io.bkbn.kompendium.protobufjavaconverter.Corpus
|
||||
import io.bkbn.kompendium.protobufjavaconverter.DoubleNestedMessage
|
||||
import io.bkbn.kompendium.protobufjavaconverter.NestedMapMessage
|
||||
import io.bkbn.kompendium.protobufjavaconverter.EnumMessage
|
||||
import io.bkbn.kompendium.protobufjavaconverter.GoogleTypes
|
||||
import io.bkbn.kompendium.protobufjavaconverter.NestedMessage
|
||||
import io.bkbn.kompendium.protobufjavaconverter.RepeatedEnumMessage
|
||||
import io.bkbn.kompendium.protobufjavaconverter.RepeatedMessage
|
||||
import io.bkbn.kompendium.protobufjavaconverter.SimpleMapMessage
|
||||
import io.bkbn.kompendium.protobufjavaconverter.SimpleTestMessage
|
||||
import io.kotest.core.spec.style.DescribeSpec
|
||||
import io.kotest.matchers.maps.shouldContainExactly
|
||||
import io.kotest.matchers.shouldBe
|
||||
import io.kotest.matchers.types.shouldBeTypeOf
|
||||
import io.kotest.matchers.types.shouldNotBeTypeOf
|
||||
import kotlin.reflect.KType
|
||||
import kotlin.reflect.full.createType
|
||||
|
||||
class FieldDescriptiorConvertersKtTest : DescribeSpec({
|
||||
describe("fromTypeToSchemaTests") {
|
||||
val simpleMessageDescriptor = SimpleTestMessage.getDescriptor()
|
||||
it("java int field should return TypeDefinition INT") {
|
||||
listOf(
|
||||
"uint32",
|
||||
"int32",
|
||||
"sint32",
|
||||
"fixed32",
|
||||
).forEach {
|
||||
fromTypeToSchema(simpleMessageDescriptor.findFieldByName("my_test_$it")).shouldBe(TypeDefinition.INT)
|
||||
}
|
||||
}
|
||||
it("long number type field should return TypeDefinition LONG") {
|
||||
listOf(
|
||||
"uint64",
|
||||
"int64",
|
||||
"sint64",
|
||||
).forEach {
|
||||
val field = simpleMessageDescriptor.findFieldByName("my_test_$it")
|
||||
fromTypeToSchema(field).shouldBe(TypeDefinition.LONG)
|
||||
}
|
||||
}
|
||||
|
||||
it("double field should return TypeDefinition DOUBLE") {
|
||||
listOf(
|
||||
"double",
|
||||
).forEach {
|
||||
fromTypeToSchema(simpleMessageDescriptor.findFieldByName("my_test_$it")).shouldBe(TypeDefinition.DOUBLE)
|
||||
}
|
||||
}
|
||||
it("bool field should return TypeDefinition BOOLEAN") {
|
||||
listOf(
|
||||
"bool",
|
||||
).forEach {
|
||||
fromTypeToSchema(simpleMessageDescriptor.findFieldByName("my_test_$it")).shouldBe(TypeDefinition.BOOLEAN)
|
||||
}
|
||||
}
|
||||
it("string fields should return TypeDefinition STRING }") {
|
||||
listOf(
|
||||
"string",
|
||||
"bytes",
|
||||
).forEach {
|
||||
fromTypeToSchema(simpleMessageDescriptor.findFieldByName("my_test_$it")).shouldBe(TypeDefinition.STRING)
|
||||
}
|
||||
}
|
||||
|
||||
it("Nested message should return ReferenceDefinition }") {
|
||||
val message = NestedMessage.getDescriptor()
|
||||
val result = fromNestedTypeToSchema(message.findFieldByName("nested_field"))
|
||||
result.shouldBeTypeOf<ReferenceDefinition>()
|
||||
result.`$ref`.shouldBe(message.findFieldByName("nested_field").messageType.name)
|
||||
}
|
||||
|
||||
it("Repeated message should return ArrayDefinition") {
|
||||
val message = RepeatedMessage.getDescriptor()
|
||||
val result = fromNestedTypeToSchema(message.findFieldByName("repeated_field"))
|
||||
result.shouldBeTypeOf<ArrayDefinition>()
|
||||
result.items.shouldBeTypeOf<ReferenceDefinition>()
|
||||
(result.items as ReferenceDefinition).`$ref`.shouldBe(SimpleTestMessage.getDescriptor().name)
|
||||
}
|
||||
|
||||
it("Repeated enum message should return ArrayDefinition") {
|
||||
val message: Descriptors.Descriptor = RepeatedEnumMessage.getDescriptor()
|
||||
val result: JsonSchema = fromNestedTypeToSchema(message.findFieldByName("repeated_field"))
|
||||
result.shouldBeTypeOf<ArrayDefinition>()
|
||||
result.items.shouldBeTypeOf<ReferenceDefinition>()
|
||||
(result.items as ReferenceDefinition).`$ref`.shouldBe(Corpus.getDescriptor().name)
|
||||
}
|
||||
|
||||
it("SimpleMapMessage message should return MapDefinition") {
|
||||
val message = SimpleMapMessage.getDescriptor()
|
||||
val mapField = message.findFieldByName("map_field")
|
||||
val expectedValueTypeDefinition =
|
||||
fromNestedTypeToSchema(mapField.containingType.nestedTypes.first().findFieldByName("value"))
|
||||
val result = fromNestedTypeToSchema(mapField)
|
||||
result.shouldBeTypeOf<MapDefinition>()
|
||||
(result.additionalProperties as TypeDefinition).properties!!.entries.first().value.shouldBe(
|
||||
expectedValueTypeDefinition
|
||||
)
|
||||
}
|
||||
|
||||
it("NestedMapMessage message should return MapDefinition") {
|
||||
val message = NestedMapMessage.getDescriptor()
|
||||
val mapField = message.findFieldByName("map_field")
|
||||
val expectedValueTypeDefinition =
|
||||
fromNestedTypeToSchema(mapField.containingType.nestedTypes.first().findFieldByName("value"))
|
||||
val result = fromNestedTypeToSchema(mapField)
|
||||
result.shouldBeTypeOf<MapDefinition>()
|
||||
(result.additionalProperties as TypeDefinition).properties!!.entries.first().value.shouldBe(
|
||||
expectedValueTypeDefinition
|
||||
)
|
||||
}
|
||||
|
||||
it("GoogleType duration return Object") {
|
||||
val message = GoogleTypes.getDescriptor()
|
||||
fromTypeToSchema(message.findFieldByName("duration_field")).shouldBeTypeOf<ReferenceDefinition>()
|
||||
}
|
||||
|
||||
it("GoogleType timestamp return Object") {
|
||||
val message = GoogleTypes.getDescriptor()
|
||||
fromTypeToSchema(message.findFieldByName("timestamp_field")).shouldBeTypeOf<ReferenceDefinition>()
|
||||
}
|
||||
}
|
||||
|
||||
describe("from message to schema map test") {
|
||||
it("Should contain our simple message description") {
|
||||
val message = SimpleTestMessage.getDefaultInstance()
|
||||
val expectedType: KType = message::class.createType()
|
||||
val resultSchema = testMessageBasics(message)
|
||||
val expectedMapping = mapOf(
|
||||
expectedType to TypeDefinition(
|
||||
type = "object",
|
||||
properties = message.descriptorForType.fields?.map { it.jsonName to fromNestedTypeToSchema(it) }?.toMap()
|
||||
)
|
||||
)
|
||||
resultSchema.shouldContainExactly(expectedMapping)
|
||||
}
|
||||
|
||||
it("Nested message to schema") {
|
||||
val message = NestedMessage.getDefaultInstance()
|
||||
val expectedType: KType = message::class.createType()
|
||||
val resultSchema = testMessageBasics(message)
|
||||
// We already tested all the separate field mappings and their types
|
||||
val expectedMapping = mapOf(
|
||||
// Expect the definition four our object
|
||||
expectedType to TypeDefinition(
|
||||
type = "object",
|
||||
properties = message.descriptorForType.fields?.map { it.jsonName to fromNestedTypeToSchema(it) }?.toMap()
|
||||
),
|
||||
// Expect the definition for our nested object
|
||||
SimpleTestMessage::class.createType() to TypeDefinition(
|
||||
type = "object",
|
||||
properties = SimpleTestMessage.getDescriptor().fields?.map {
|
||||
it.jsonName to fromNestedTypeToSchema(it)
|
||||
}?.toMap()
|
||||
)
|
||||
)
|
||||
resultSchema.shouldContainExactly(expectedMapping)
|
||||
val result = (resultSchema[expectedType] as TypeDefinition).properties!!["nestedField"]
|
||||
// Our nested field should be a reference
|
||||
result.shouldBeTypeOf<ReferenceDefinition>()
|
||||
// Our nested field should be a reference to simplemessage
|
||||
result.`$ref`.shouldBe(SimpleTestMessage.getDescriptor().name)
|
||||
}
|
||||
|
||||
it("Double nested message to schema") {
|
||||
val message = DoubleNestedMessage.getDefaultInstance()
|
||||
val expectedType: KType = message::class.createType()
|
||||
val resultSchema = testMessageBasics(message)
|
||||
// We already tested all the separate field mappings and their types
|
||||
val expectedMapping = mapOf(
|
||||
// Expect our object definition
|
||||
expectedType to TypeDefinition(
|
||||
type = "object",
|
||||
properties = message.descriptorForType.fields?.map { it.jsonName to fromNestedTypeToSchema(it) }?.toMap()
|
||||
),
|
||||
// Expect the definition for our nested object
|
||||
SimpleTestMessage::class.createType() to TypeDefinition(
|
||||
type = "object",
|
||||
properties = SimpleTestMessage.getDescriptor().fields?.map { it.jsonName to fromNestedTypeToSchema(it) }
|
||||
?.toMap()
|
||||
),
|
||||
NestedMessage::class.createType() to TypeDefinition(
|
||||
type = "object",
|
||||
properties = NestedMessage.getDescriptor().fields?.map { it.jsonName to fromNestedTypeToSchema(it) }?.toMap()
|
||||
),
|
||||
)
|
||||
// We expect 2 definitions one for our Message and one for our
|
||||
resultSchema.shouldContainExactly(expectedMapping)
|
||||
// Make sure both our message and nested message contain a reference
|
||||
val result = (resultSchema[expectedType] as TypeDefinition).properties!!["nestedField"]
|
||||
// Our nested field should be a reference
|
||||
result.shouldBeTypeOf<ReferenceDefinition>()
|
||||
// it should be a reference to our nested message
|
||||
result.`$ref`.shouldBe(NestedMessage.getDescriptor().name)
|
||||
val nestedResult = (resultSchema[NestedMessage::class.createType()] as TypeDefinition).properties!!["nestedField"]
|
||||
nestedResult.shouldBeTypeOf<ReferenceDefinition>()
|
||||
// Our nested message reference should be pointing to simpleTest message
|
||||
nestedResult.`$ref`.shouldBe(SimpleTestMessage.getDescriptor().name)
|
||||
// last but not least we should have definition for our SimpleTest message which is not a reference
|
||||
(resultSchema[SimpleTestMessage::class.createType()] as TypeDefinition).shouldNotBeTypeOf<ReferenceDefinition>()
|
||||
}
|
||||
|
||||
it("Repeated message to schema") {
|
||||
val message = RepeatedMessage.getDefaultInstance()
|
||||
testMessageBasics(message)
|
||||
}
|
||||
|
||||
it("Repeated enum message to schema") {
|
||||
val message = RepeatedEnumMessage.getDefaultInstance()
|
||||
testMessageBasics(message)
|
||||
}
|
||||
|
||||
it("Enum message to schema") {
|
||||
val message = EnumMessage.getDefaultInstance()
|
||||
testMessageBasics(message)
|
||||
}
|
||||
|
||||
it("Simple map message to schema") {
|
||||
val message = SimpleMapMessage.getDefaultInstance()
|
||||
testMessageBasics(message)
|
||||
}
|
||||
|
||||
it("Nested map message to schema") {
|
||||
val message = NestedMapMessage.getDefaultInstance()
|
||||
testMessageBasics(message)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* Tests the basics for any message and returns the map for further processing
|
||||
*/
|
||||
fun testMessageBasics(message: GeneratedMessageV3): Map<KType, JsonSchema> {
|
||||
val expectedType: KType = message::class.createType()
|
||||
// Results after conversion
|
||||
val resultSchema: Map<KType, JsonSchema> = message.createCustomTypesForTypeAndSubTypes()
|
||||
val resultEntry: JsonSchema = resultSchema.values.first()
|
||||
|
||||
resultSchema.keys.first().shouldBe(expectedType)
|
||||
when (resultEntry) {
|
||||
// Should have all our enum entries
|
||||
is EnumDefinition -> resultEntry.enum.size.shouldBe(message.descriptorForType.enumTypes.size)
|
||||
// should contain all our fields
|
||||
is TypeDefinition -> resultEntry.properties?.size.shouldBe(message.descriptorForType.fields.size)
|
||||
else -> {}
|
||||
}
|
||||
return resultSchema
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package io.bkbn.kompendium.protobufjavaconverter;
|
||||
|
||||
option java_multiple_files = true;
|
||||
|
||||
option java_package = "io.bkbn.kompendium.protobufjavaconverter";
|
||||
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "google/protobuf/duration.proto";
|
||||
|
||||
message SimpleTestMessage {
|
||||
double my_test_double = 1;
|
||||
float my_test_float = 2;
|
||||
int32 my_test_int32 = 3;
|
||||
int64 my_test_int64 = 4;
|
||||
uint32 my_test_uint32 = 5;
|
||||
uint64 my_test_uint64 = 6;
|
||||
|
||||
sint32 my_test_sint32 = 7;
|
||||
sint64 my_test_sint64 = 8;
|
||||
fixed32 my_test_fixed32 = 9;
|
||||
fixed64 my_test_fixed64 = 10;
|
||||
sfixed32 my_test_sfixed32 = 11;
|
||||
sfixed64 my_test_sfixed64 = 12;
|
||||
bool my_test_bool = 13;
|
||||
bytes my_test_bytes = 14;
|
||||
string my_test_string = 15;
|
||||
}
|
||||
|
||||
enum Corpus {
|
||||
CORPUS_UNSPECIFIED = 0;
|
||||
CORPUS_UNIVERSAL = 1;
|
||||
CORPUS_WEB = 2;
|
||||
CORPUS_IMAGES = 3;
|
||||
CORPUS_LOCAL = 4;
|
||||
CORPUS_NEWS = 5;
|
||||
CORPUS_PRODUCTS = 6;
|
||||
CORPUS_VIDEO = 7;
|
||||
}
|
||||
|
||||
message EnumMessage {
|
||||
Corpus corpus = 1;
|
||||
}
|
||||
|
||||
message NestedMessage {
|
||||
SimpleTestMessage nested_field = 1;
|
||||
}
|
||||
|
||||
message DoubleNestedMessage {
|
||||
NestedMessage nested_field = 1;
|
||||
}
|
||||
|
||||
message RepeatedMessage {
|
||||
repeated SimpleTestMessage repeated_field = 1;
|
||||
}
|
||||
|
||||
message RepeatedEnumMessage {
|
||||
repeated Corpus repeated_field = 1;
|
||||
}
|
||||
|
||||
message SimpleMapMessage {
|
||||
map<string, int32> map_field = 1;
|
||||
}
|
||||
|
||||
message NestedMapMessage {
|
||||
map<string, SimpleTestMessage> map_field = 1;
|
||||
}
|
||||
|
||||
message GoogleTypes {
|
||||
google.protobuf.Timestamp timestamp_field = 1;
|
||||
google.protobuf.Duration duration_field = 2;
|
||||
// TODO value types
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,21 @@
|
||||
package io.bkbn.kompendium.resources
|
||||
|
||||
import io.ktor.resources.Resource
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.reflect.full.findAnnotation
|
||||
import kotlin.reflect.full.hasAnnotation
|
||||
import kotlin.reflect.full.memberProperties
|
||||
|
||||
fun KClass<*>.getResourcePathFromClass(): String {
|
||||
val resource = findAnnotation<Resource>()
|
||||
?: error("Cannot notarize a resource without annotating with @Resource")
|
||||
|
||||
val path = resource.path
|
||||
val parent = memberProperties.map { it.returnType.classifier as KClass<*> }.find { it.hasAnnotation<Resource>() }
|
||||
|
||||
return if (parent == null) {
|
||||
path
|
||||
} else {
|
||||
parent.getResourcePathFromClass() + path
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package io.bkbn.kompendium.resources
|
||||
|
||||
import io.bkbn.kompendium.core.attribute.KompendiumAttributes
|
||||
import io.bkbn.kompendium.core.plugin.NotarizedRoute
|
||||
import io.bkbn.kompendium.core.plugin.NotarizedRoute.addToSpec
|
||||
import io.bkbn.kompendium.core.plugin.NotarizedRoute.calculateRoutePath
|
||||
import io.bkbn.kompendium.core.plugin.NotarizedRoute.collectAuthMethods
|
||||
import io.ktor.server.application.ApplicationCallPipeline
|
||||
import io.ktor.server.application.Hook
|
||||
import io.ktor.server.application.createRouteScopedPlugin
|
||||
import io.ktor.server.routing.Route
|
||||
|
||||
object NotarizedResource {
|
||||
object InstallHook : Hook<(ApplicationCallPipeline) -> Unit> {
|
||||
override fun install(pipeline: ApplicationCallPipeline, handler: (ApplicationCallPipeline) -> Unit) {
|
||||
handler(pipeline)
|
||||
}
|
||||
}
|
||||
|
||||
inline operator fun <reified T> invoke() = createRouteScopedPlugin(
|
||||
name = "NotarizedResource<${T::class.qualifiedName}>",
|
||||
createConfiguration = NotarizedRoute::Config
|
||||
) {
|
||||
on(InstallHook) {
|
||||
val route = it as? Route ?: return@on
|
||||
val spec = application.attributes[KompendiumAttributes.openApiSpec]
|
||||
val routePath = route.calculateRoutePath()
|
||||
val authMethods = route.collectAuthMethods()
|
||||
val resourcePath = T::class.getResourcePathFromClass()
|
||||
val fullPath = "$routePath$resourcePath"
|
||||
|
||||
addToSpec(spec, fullPath, authMethods)
|
||||
}
|
||||
}
|
||||
}
|
@ -12,12 +12,8 @@ import io.bkbn.kompendium.core.util.Helpers.addToSpec
|
||||
import io.bkbn.kompendium.core.util.SpecConfig
|
||||
import io.bkbn.kompendium.oas.path.Path
|
||||
import io.bkbn.kompendium.oas.payload.Parameter
|
||||
import io.ktor.resources.Resource
|
||||
import io.ktor.server.application.createApplicationPlugin
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.reflect.full.findAnnotation
|
||||
import kotlin.reflect.full.hasAnnotation
|
||||
import kotlin.reflect.full.memberProperties
|
||||
|
||||
object NotarizedResources {
|
||||
|
||||
@ -45,34 +41,18 @@ object NotarizedResources {
|
||||
val spec = application.attributes[KompendiumAttributes.openApiSpec]
|
||||
val serializableReader = application.attributes[KompendiumAttributes.schemaConfigurator]
|
||||
pluginConfig.resources.forEach { (k, v) ->
|
||||
val path = Path()
|
||||
path.parameters = v.parameters
|
||||
v.get?.addToSpec(path, spec, v, serializableReader)
|
||||
v.delete?.addToSpec(path, spec, v, serializableReader)
|
||||
v.head?.addToSpec(path, spec, v, serializableReader)
|
||||
v.options?.addToSpec(path, spec, v, serializableReader)
|
||||
v.post?.addToSpec(path, spec, v, serializableReader)
|
||||
v.put?.addToSpec(path, spec, v, serializableReader)
|
||||
v.patch?.addToSpec(path, spec, v, serializableReader)
|
||||
val resource = k.getResourcePathFromClass()
|
||||
val path = spec.paths[resource] ?: Path()
|
||||
path.parameters = path.parameters?.plus(v.parameters) ?: v.parameters
|
||||
v.get?.addToSpec(path, spec, v, serializableReader, resource)
|
||||
v.delete?.addToSpec(path, spec, v, serializableReader, resource)
|
||||
v.head?.addToSpec(path, spec, v, serializableReader, resource)
|
||||
v.options?.addToSpec(path, spec, v, serializableReader, resource)
|
||||
v.post?.addToSpec(path, spec, v, serializableReader, resource)
|
||||
v.put?.addToSpec(path, spec, v, serializableReader, resource)
|
||||
v.patch?.addToSpec(path, spec, v, serializableReader, resource)
|
||||
|
||||
val resource = k.getResourcesFromClass()
|
||||
spec.paths[resource] = path
|
||||
}
|
||||
}
|
||||
|
||||
private fun KClass<*>.getResourcesFromClass(): String {
|
||||
// todo if parent
|
||||
|
||||
val resource = findAnnotation<Resource>()
|
||||
?: error("Cannot notarize a resource without annotating with @Resource")
|
||||
|
||||
val path = resource.path
|
||||
val parent = memberProperties.map { it.returnType.classifier as KClass<*> }.find { it.hasAnnotation<Resource>() }
|
||||
|
||||
return if (parent == null) {
|
||||
path
|
||||
} else {
|
||||
parent.getResourcesFromClass() + path
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,9 +14,11 @@ import io.ktor.server.application.install
|
||||
import io.ktor.server.resources.Resources
|
||||
import io.ktor.server.resources.get
|
||||
import io.ktor.server.response.respondText
|
||||
import io.ktor.server.routing.Route
|
||||
import io.ktor.server.routing.route
|
||||
|
||||
class KompendiumResourcesTest : DescribeSpec({
|
||||
describe("Resource Tests") {
|
||||
describe("NotarizedResources Tests") {
|
||||
it("Can notarize a simple resource") {
|
||||
openApiTestAllSerializers(
|
||||
snapshotName = "T0001__simple_resource.json",
|
||||
@ -117,4 +119,72 @@ class KompendiumResourcesTest : DescribeSpec({
|
||||
}
|
||||
}
|
||||
}
|
||||
describe("NotarizedResource Tests") {
|
||||
it("Can notarize resources in route") {
|
||||
openApiTestAllSerializers(
|
||||
snapshotName = "T0003__resources_in_route.json",
|
||||
applicationSetup = {
|
||||
install(Resources)
|
||||
}
|
||||
) {
|
||||
route("/api") {
|
||||
typeEditDocumentation()
|
||||
get<Type.Edit> { edit ->
|
||||
call.respondText("Listing ${edit.parent.name}")
|
||||
}
|
||||
typeOtherDocumentation()
|
||||
get<Type.Other> { other ->
|
||||
call.respondText("Listing ${other.parent.name}, page ${other.page}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
private fun Route.typeOtherDocumentation() {
|
||||
install(NotarizedResource<Type.Other>()) {
|
||||
parameters = listOf(
|
||||
Parameter(
|
||||
name = "name",
|
||||
`in` = Parameter.Location.path,
|
||||
schema = TypeDefinition.STRING
|
||||
),
|
||||
Parameter(
|
||||
name = "page",
|
||||
`in` = Parameter.Location.path,
|
||||
schema = TypeDefinition.INT
|
||||
)
|
||||
)
|
||||
get = GetInfo.builder {
|
||||
summary("Other")
|
||||
description("example resource")
|
||||
response {
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<TestResponse>()
|
||||
description("does great things")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun Route.typeEditDocumentation() {
|
||||
install(NotarizedResource<Type.Edit>()) {
|
||||
parameters = listOf(
|
||||
Parameter(
|
||||
name = "name",
|
||||
`in` = Parameter.Location.path,
|
||||
schema = TypeDefinition.STRING
|
||||
)
|
||||
)
|
||||
get = GetInfo.builder {
|
||||
summary("Edit")
|
||||
description("example resource")
|
||||
response {
|
||||
responseCode(HttpStatusCode.OK)
|
||||
responseType<TestResponse>()
|
||||
description("does great things")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
124
resources/src/test/resources/T0003__resources_in_route.json
Normal file
124
resources/src/test/resources/T0003__resources_in_route.json
Normal file
@ -0,0 +1,124 @@
|
||||
{
|
||||
"openapi": "3.1.0",
|
||||
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||
"info": {
|
||||
"title": "Test API",
|
||||
"version": "1.33.7",
|
||||
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||
"termsOfService": "https://example.com",
|
||||
"contact": {
|
||||
"name": "Homer Simpson",
|
||||
"url": "https://gph.is/1NPUDiM",
|
||||
"email": "chunkylover53@aol.com"
|
||||
},
|
||||
"license": {
|
||||
"name": "MIT",
|
||||
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||
}
|
||||
},
|
||||
"servers": [
|
||||
{
|
||||
"url": "https://myawesomeapi.com",
|
||||
"description": "Production instance of my API"
|
||||
},
|
||||
{
|
||||
"url": "https://staging.myawesomeapi.com",
|
||||
"description": "Where the fun stuff happens"
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"/api/type/{name}/edit": {
|
||||
"get": {
|
||||
"tags": [],
|
||||
"summary": "Edit",
|
||||
"description": "example resource",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "does great things",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/TestResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"deprecated": false
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "name",
|
||||
"in": "path",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"required": true,
|
||||
"deprecated": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"/api/type/{name}/other/{page}": {
|
||||
"get": {
|
||||
"tags": [],
|
||||
"summary": "Other",
|
||||
"description": "example resource",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "does great things",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/TestResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"deprecated": false
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "name",
|
||||
"in": "path",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"required": true,
|
||||
"deprecated": false
|
||||
},
|
||||
{
|
||||
"name": "page",
|
||||
"in": "path",
|
||||
"schema": {
|
||||
"type": "number",
|
||||
"format": "int32"
|
||||
},
|
||||
"required": true,
|
||||
"deprecated": false
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"webhooks": {},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"TestResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"c": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"c"
|
||||
]
|
||||
}
|
||||
},
|
||||
"securitySchemes": {}
|
||||
},
|
||||
"security": [],
|
||||
"tags": []
|
||||
}
|
@ -1,10 +1,12 @@
|
||||
rootProject.name = "kompendium"
|
||||
|
||||
include("core")
|
||||
include("enrichment")
|
||||
include("oas")
|
||||
include("playground")
|
||||
include("locations")
|
||||
include("json-schema")
|
||||
include("protobuf-java-converter")
|
||||
include("resources")
|
||||
|
||||
run {
|
||||
|
Reference in New Issue
Block a user