Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Latest commit

 

History

History
99 lines (79 loc) · 3.83 KB

File metadata and controls

99 lines (79 loc) · 3.83 KB

Currency

org.openapijsonschematools.client.components.schemas.Currency.java public class Currency

A class that contains necessary nested

  • schema classes (which validate payloads), extends JsonSchema
  • sealed interfaces which store validated payloads, java version of a sum type
  • boxed classes which store validated payloads, sealed permits class implementations
  • enum classes

Nested Class Summary

Modifier and Type Class and Description
sealed interface Currency.Currency1Boxed
sealed interface for validated payloads
record Currency.Currency1BoxedString
boxed class to store validated String payloads
static class Currency.Currency1
schema class
enum Currency.StringCurrencyEnums
String enum

Currency1Boxed

public sealed interface Currency1Boxed
permits
Currency1BoxedString

sealed interface that stores validated payloads using boxed classes

Currency1BoxedString

public record Currency1BoxedString
implements Currency1Boxed

record that stores validated String payloads, sealed permits implementation

Constructor Summary

Constructor and Description
Currency1BoxedString(String data)
Creates an instance, private visibility

Method Summary

Modifier and Type Method and Description
String data()
validated payload
@Nullable Object getData()
validated payload

Currency1

public static class Currency1
extends JsonSchema

A schema class that validates payloads

Code Sample

import org.openapijsonschematools.client.configurations.JsonSchemaKeywordFlags;
import org.openapijsonschematools.client.configurations.SchemaConfiguration;
import org.openapijsonschematools.client.exceptions.ValidationException;
import org.openapijsonschematools.client.schemas.validation.MapUtils;
import org.openapijsonschematools.client.schemas.validation.FrozenList;
import org.openapijsonschematools.client.schemas.validation.FrozenMap;
import org.openapijsonschematools.client.components.schemas.Currency;

import java.util.Arrays;
import java.util.List;
import java.util.AbstractMap;

static final SchemaConfiguration configuration = new SchemaConfiguration(new JsonSchemaKeywordFlags.Builder().build());

// String validation
String validatedPayload = Currency.Currency1.validate(
    "eur",
    configuration
);

Field Summary

Modifier and Type Field and Description
Set<Class<?>> type = Set.of(
    String.class
)
Set enumValues = SetMaker.makeSet(
    "eur",
    "usd"
)

Method Summary

Modifier and Type Method and Description
String validate(String arg, SchemaConfiguration configuration)
String validate(StringCurrencyEnums arg, SchemaConfiguration configuration)
Currency1BoxedString validateAndBox(String arg, SchemaConfiguration configuration)
Currency1Boxed validateAndBox(@Nullable Object arg, SchemaConfiguration configuration)
@Nullable Object validate(@Nullable Object arg, SchemaConfiguration configuration)

StringCurrencyEnums

public enum StringCurrencyEnums
extends Enum<StringCurrencyEnums>

A class that stores String enum values

Enum Constant Summary

Enum Constant Description
EUR value = "eur"
USD value = "usd"

[Back to top] [Back to Component Schemas] [Back to README]