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

Latest commit

 

History

History
110 lines (88 loc) · 4.51 KB

File metadata and controls

110 lines (88 loc) · 4.51 KB

NullableString

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

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

Nested Class Summary

Modifier and Type Class and Description
sealed interface NullableString.NullableString1Boxed
sealed interface for validated payloads
record NullableString.NullableString1BoxedVoid
boxed class to store validated null payloads
record NullableString.NullableString1BoxedString
boxed class to store validated String payloads
static class NullableString.NullableString1
schema class

NullableString1Boxed

public sealed interface NullableString1Boxed
permits
NullableString1BoxedVoid, NullableString1BoxedString

sealed interface that stores validated payloads using boxed classes

NullableString1BoxedVoid

public record NullableString1BoxedVoid
implements NullableString1Boxed

record that stores validated null payloads, sealed permits implementation

Constructor Summary

Constructor and Description
NullableString1BoxedVoid(Void data)
Creates an instance, private visibility

Method Summary

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

NullableString1BoxedString

public record NullableString1BoxedString
implements NullableString1Boxed

record that stores validated String payloads, sealed permits implementation

Constructor Summary

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

Method Summary

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

NullableString1

public static class NullableString1
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.NullableString;

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

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

// null validation
Void validatedPayload = NullableString.NullableString1.validate(
    (Void) null,
    configuration
);

// String validation
String validatedPayload = NullableString.NullableString1.validate(
    "a",
    configuration
);

Field Summary

Modifier and Type Field and Description
Set<Class<?>> type = Set.of(
    Void.class,
    String.class
)

Method Summary

Modifier and Type Method and Description
Void validate(Void arg, SchemaConfiguration configuration)
NullableString1BoxedVoid validateAndBox(Void arg, SchemaConfiguration configuration)
String validate(String arg, SchemaConfiguration configuration)
NullableString1BoxedString validateAndBox(String arg, SchemaConfiguration configuration)
NullableString1Boxed validateAndBox(@Nullable Object arg, SchemaConfiguration configuration)
@Nullable Object validate(@Nullable Object arg, SchemaConfiguration configuration)

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