java

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2026 License: MIT Imports: 22 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package java emits Java 25 source. Generation is pure: callers choose where to write the returned files, and no generated predicate receives I/O access.

Index

Constants

View Source
const OpenAPIPropertyElementPathSegment = "~2"

OpenAPIPropertyElementPathSegment is the reserved affected-path segment for one runtime list element or map key in an occurrence replay selector. It is not a JSON Pointer escape and cannot collide with an authored field name.

Variables

This section is empty.

Functions

func JSONNativeValidatorName

func JSONNativeValidatorName(program *language.Program, contractName, moduleName string) (string, error)

JSONNativeValidatorName shares the collision-safe sidecar class name with project/property generation. It does not execute or weaken validation.

func OpenAPIContextOccurrenceReplayTarget

func OpenAPIContextOccurrenceReplayTarget(operationID, status string, paths []string, offset int) string

OpenAPIContextOccurrenceReplayTarget selects one repeated additional context clause by its checked affected paths and source offset.

func OpenAPIContextReplayTarget

func OpenAPIContextReplayTarget(operationID, status string) string

OpenAPIContextReplayTarget returns the opaque replay selector for a response pair validated through an additional checked context type.

func OpenAPIRequestOccurrenceReplayTarget

func OpenAPIRequestOccurrenceReplayTarget(operationID string, paths []string, offset int) string

OpenAPIRequestOccurrenceReplayTarget selects one repeated request clause by its checked affected paths and source offset. Prefer the shorter request selector when a diagnostic code occurs only once in the request.

func OpenAPIRequestReplayTarget

func OpenAPIRequestReplayTarget(operationID string) string

OpenAPIRequestReplayTarget returns the opaque replay selector for one operation's request property. The generator still verifies that the selector names exactly one authoritative catalog property.

func OpenAPIResponseOccurrenceReplayTarget

func OpenAPIResponseOccurrenceReplayTarget(operationID, status string, paths []string, offset int) string

OpenAPIResponseOccurrenceReplayTarget selects one repeated response-origin clause, including a response clause evaluated through a context binding.

func OpenAPIResponseReplayTarget

func OpenAPIResponseReplayTarget(operationID, status string) string

OpenAPIResponseReplayTarget selects response-origin invalid predicates, including those evaluated within a context. It also selects valid response pairs when the binding has no additional context type.

Types

type File

type File struct {
	Path   string
	Source string
}

func GenerateJSONSerde

func GenerateJSONSerde(program *language.Program, namespace, contractName, moduleName string, options JSONSerdeOptions) (files []File, failure error)

GenerateJSONSerde emits semantic models plus a Jackson 3 module for one closed, non-generic record or scalar root. Wire choices that could lose exact values are explicit; unsupported shapes fail the whole generation.

func GenerateModels

func GenerateModels(program *language.Program, namespace, contractName string) (files []File, failure error)

GenerateModels emits semantic Java models and the checked validator they use. No filesystem or deployment operations occur. All emitted constructors validate by default; named bypass factories retain structural checks. Unsupported model forms reject the complete output, never degrade fields to Object or raw Data.

func GenerateOpenAPIContext

func GenerateOpenAPIContext(program *language.Program, namespace, contractName, className string, schema refineopenapi.Schema) (files []File, failure error)

GenerateOpenAPIContext emits a pure Java 25 request/response validation facade over the same checked operation metadata used by Go. It generates no transport, routing, network, or filesystem behavior.

func GenerateProjectAvroSerde

func GenerateProjectAvroSerde(project *native.Project, contractName, serdeName string) (files []File, failure error)

GenerateProjectAvroSerde emits the shared semantic models and an Apache Avro 1.12 adapter for the checked project's selected root. Decode traversal and collection allocation are bounded before values enter the semantic model.

func GenerateProjectJSONSerde

func GenerateProjectJSONSerde(project *native.Project, contractName, moduleName string) ([]File, error)

GenerateProjectJSONSerde composes the immutable native sidecar with semantic Jackson decoding. Reads validate native bytes before constructing a model; writes stage and validate bytes before touching the caller's generator.

func GenerateProjectNativeJSONValidator

func GenerateProjectNativeJSONValidator(project *native.Project, className string) (files []File, failure error)

GenerateProjectNativeJSONValidator emits an offline native-schema validator for a JSON Schema Draft 2020-12 or OpenAPI 3.x project. OAS 3.0 resources are first adapted by native.Project to equivalent Draft 2020-12 assertions. The public helper validates bytes only; callers compose it with their semantic serde so that both the immutable native sidecar and editable refinements are enforced. Pattern-bearing schemas conditionally receive the bounded shared QuickJS-NG WebAssembly ECMA-262 adapter. Helpers without native patterns have no Chicory runtime linkage and require no companion guest resources.

func GenerateProjectOpenAPIContext

func GenerateProjectOpenAPIContext(project *native.Project, contractName, className string) (files []File, failure error)

GenerateProjectOpenAPIContext composes checked native operation-part Schema Objects with structural JSON decoding and the complete Refine request, response, and context predicates. Inputs are semantic JSON values, never HTTP syntax. Schema locations come only from Project.OpenAPIOperationIndex.

func GenerateProjectOpenAPIPropertyTests

func GenerateProjectOpenAPIPropertyTests(project *native.Project, namespace, contractName, facadeName string, options PropertyTestOptions) ([]File, error)

GenerateProjectOpenAPIPropertyTests emits one executable JetCheck launcher which exercises every checked request and response binding through the real native-first OpenAPI facade. Targets cannot narrow the authoritative catalog. Examples cover valid, invalid, indeterminate, and native-invalid outcomes. Replay selectors bind request values or request/response pairs to one exact catalog property. Standalone wire-adapter overrides reject the complete generation request instead of being skipped.

func GenerateProjectPropertyTests

func GenerateProjectPropertyTests(project *native.Project, namespace, contractName string, options PropertyTestOptions) ([]File, error)

GenerateProjectPropertyTests retains the ordinary property suite and only specializes its raw root generator when the authoritative native Schema Object proves a small ASCII language. Every emitted candidate still passes through the generated native adapter and Refine validator.

func GeneratePropertyTests

func GeneratePropertyTests(program *language.Program, namespace, contractName string, options PropertyTestOptions) ([]File, error)

GeneratePropertyTests emits an executable Java property suite using JetCheck 0.3.0. Unsupported strategies reject the complete output.

func GenerateRuntime

func GenerateRuntime(namespace string) ([]File, error)

GenerateRuntime emits shared runtime sources, not schema-specific models or serde adapters. An empty package selects Java's unnamed package. Paths are package-relative; a flat-layout caller can retain only their base names. These development sources are intended to live in the user's single artifact; no separately deployed Maven runtime artifact is required.

func GenerateValidator

func GenerateValidator(program *language.Program, namespace, className string) (files []File, failure error)

GenerateValidator emits a checked contract and its Java 25 runtime. It does not yet emit semantic model classes or native serde. Structural records, aliases, lists, generic/recursive ADTs, named/recursive/higher-order functions and pattern matching are supported. Unsupported execution features reject the entire generation; see docs/JAVA-RUNTIME.md for the current boundaries.

func GenerateValidatorWithTypes

func GenerateValidatorWithTypes(program *language.Program, namespace, className string, targets map[string]string) (files []File, failure error)

GenerateValidatorWithTypes additionally emits named handles for checked closed payload-type expressions, such as "Box Age" or "Tree (Int where it > 0)". Java receives static metadata, never a runtime schema/type-source parser. The target labels are map keys, not Java identifiers. All output is atomic.

type GenerationError

type GenerationError struct {
	At      language.Span
	Message string
}

GenerationError identifies syntax the development Java backend cannot yet execute. No files are returned on failure; no predicate is silently omitted.

func (*GenerationError) Error

func (e *GenerationError) Error() string

type JSONCodecLimits

type JSONCodecLimits struct {
	Bytes        int
	Depth        int
	Nodes        int
	NumberLength int
	StringLength int
	NameLength   int
}

JSONCodecLimits are generation-time maxima. Emitted Java constructors may tighten them, but cannot relax them. Zero fields select bounded defaults.

type JSONDiscriminator

type JSONDiscriminator struct {
	Field     string
	Values    map[string]string
	Arguments map[string][]string
}

type JSONIntegerEncoding

type JSONIntegerEncoding uint8
const (
	JSONIntegerNumber JSONIntegerEncoding = iota
	JSONIntegerString
)

type JSONRealEncoding

type JSONRealEncoding uint8
const (
	JSONRealUnspecified JSONRealEncoding = iota
	JSONRealExactDecimal
	JSONRealRationalString
)

type JSONSerdeOptions

type JSONSerdeOptions struct {
	Root                   string
	PreserveExtraFields    bool
	PreserveExtraFieldsFor map[string]bool
	RejectExtraFields      bool
	RejectExtraFieldsFor   map[string]bool
	Discriminators         map[string]JSONDiscriminator
	Scalars                map[string]native.ScalarEncoding
	NumericExpansion       int
	Integers               JSONIntegerEncoding
	Reals                  JSONRealEncoding
	Timestamps             JSONTimestampEncoding
	CodecLimits            JSONCodecLimits
	// contains filtered or unexported fields
}

func JSONSerdeOptionsFromMetadata

func JSONSerdeOptionsFromMetadata(root string, metadata native.WireMetadata) (JSONSerdeOptions, error)

JSONSerdeOptionsFromMetadata is the single checked conversion from native project wire metadata to the policies understood by the Jackson JSON serde. Named scalar policies are copied and retained at each named reference.

type JSONTimestampEncoding

type JSONTimestampEncoding uint8
const (
	JSONTimestampUnspecified JSONTimestampEncoding = iota
	JSONTimestampRFC3339String
)

type PropertyExample

type PropertyExample struct {
	Target          string
	Value           value.Data
	Expected        PropertyOutcome
	NativeExpected  PropertyNativeOutcome
	DiagnosticCodes []string
}

type PropertyNativeOutcome

type PropertyNativeOutcome uint8
const (
	ExampleNativeValid PropertyNativeOutcome = iota
	ExampleNativeInvalid
)

type PropertyOutcome

type PropertyOutcome uint8
const (
	ExampleValid PropertyOutcome = iota + 1
	ExampleInvalid
	ExampleIndeterminate
)

type PropertyReplay

type PropertyReplay struct {
	Target         string
	Kind           ReplayKind
	DiagnosticCode string
	SerializedData string
}

type PropertyTarget

type PropertyTarget struct{ Name string }

type PropertyTestOptions

type PropertyTestOptions struct {
	Targets             []PropertyTarget
	CaseCount           int
	AttemptBudget       int
	Seed                int64
	Examples            []PropertyExample
	Replays             []PropertyReplay
	JSONModule          string
	AvroSerde           string
	NativeJSONValidator string
}

type ReplayKind

type ReplayKind uint8
const (
	ReplayValid ReplayKind = iota + 1
	ReplayInvalid
)

type Resource

type Resource struct {
	Path    string
	Content []byte
}

Resource is a non-source output required by generated Java. Its path is a classpath-relative slash-separated name and Content is always a defensive copy. It is deliberately separate from File's Java-source-only contract.

func GenerateProjectNativeJSONResources

func GenerateProjectNativeJSONResources(project *native.Project) ([]Resource, error)

GenerateProjectNativeJSONResources returns the checked runtime resources required by GenerateProjectNativeJSONValidator, GenerateProjectJSONSerde, and GenerateProjectOpenAPIContext. Callers writing sources directly must place these at their exact classpath-relative paths. Project generation does this automatically. Schemas without native patterns return no resources and acquire no Chicory linkage.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL