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

Latest commit

 

History

History
172 lines (138 loc) · 7.63 KB

File metadata and controls

172 lines (138 loc) · 7.63 KB

NumberOnly

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

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
  • classes to store validated map payloads, extends FrozenMap
  • classes to build inputs for map payloads

Nested Class Summary

Modifier and Type Class and Description
sealed interface NumberOnly.NumberOnly1Boxed
sealed interface for validated payloads
record NumberOnly.NumberOnly1BoxedMap
boxed class to store validated Map payloads
static class NumberOnly.NumberOnly1
schema class
static class NumberOnly.NumberOnlyMapBuilder
builder for Map payloads
static class NumberOnly.NumberOnlyMap
output class for Map payloads
sealed interface NumberOnly.JustNumberBoxed
sealed interface for validated payloads
record NumberOnly.JustNumberBoxedNumber
boxed class to store validated Number payloads
static class NumberOnly.JustNumber
schema class

NumberOnly1Boxed

public sealed interface NumberOnly1Boxed
permits
NumberOnly1BoxedMap

sealed interface that stores validated payloads using boxed classes

NumberOnly1BoxedMap

public record NumberOnly1BoxedMap
implements NumberOnly1Boxed

record that stores validated Map payloads, sealed permits implementation

Constructor Summary

Constructor and Description
NumberOnly1BoxedMap(NumberOnlyMap data)
Creates an instance, private visibility

Method Summary

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

NumberOnly1

public static class NumberOnly1
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.NumberOnly;

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

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

// Map validation
NumberOnly.NumberOnlyMap validatedPayload =
    NumberOnly.NumberOnly1.validate(
    new NumberOnly.NumberOnlyMapBuilder()
        .JustNumber(1)

    .build(),
    configuration
);

Field Summary

Modifier and Type Field and Description
Set<Class<?>> type = Set.of(Map.class)
Map<String, Class<? extends JsonSchema>> properties = Map.ofEntries(
    new PropertyEntry("JustNumber", JustNumber.class))
)

Method Summary

Modifier and Type Method and Description
NumberOnlyMap validate(Map<?, ?> arg, SchemaConfiguration configuration)
NumberOnly1BoxedMap validateAndBox(Map<?, ?> arg, SchemaConfiguration configuration)
NumberOnly1Boxed validateAndBox(@Nullable Object arg, SchemaConfiguration configuration)
@Nullable Object validate(@Nullable Object arg, SchemaConfiguration configuration)

NumberOnlyMapBuilder

public class NumberOnlyMapBuilder
builder for Map<String, @Nullable Object>

A class that builds the Map input type

Constructor Summary

Constructor and Description
NumberOnlyMapBuilder()
Creates a builder that contains an empty map

Method Summary

Modifier and Type Method and Description
Map<String, @Nullable Object> build()
Returns map input that should be used with Schema.validate
NumberOnlyMapBuilder JustNumber(int value)
NumberOnlyMapBuilder JustNumber(float value)
NumberOnlyMapBuilder JustNumber(long value)
NumberOnlyMapBuilder JustNumber(double value)
NumberOnlyMapBuilder additionalProperty(String key, Void value)
NumberOnlyMapBuilder additionalProperty(String key, boolean value)
NumberOnlyMapBuilder additionalProperty(String key, String value)
NumberOnlyMapBuilder additionalProperty(String key, int value)
NumberOnlyMapBuilder additionalProperty(String key, float value)
NumberOnlyMapBuilder additionalProperty(String key, long value)
NumberOnlyMapBuilder additionalProperty(String key, double value)
NumberOnlyMapBuilder additionalProperty(String key, List<?> value)
NumberOnlyMapBuilder additionalProperty(String key, Map<String, ?> value)

NumberOnlyMap

public static class NumberOnlyMap
extends FrozenMap<String, @Nullable Object>

A class to store validated Map payloads

Method Summary

Modifier and Type Method and Description
static NumberOnlyMap of(Map<String, ? extends @Nullable Object> arg, SchemaConfiguration configuration)
Number JustNumber()
[optional]
@Nullable Object getAdditionalProperty(String name)
provides type safety for additional properties

JustNumberBoxed

public sealed interface JustNumberBoxed
permits
JustNumberBoxedNumber

sealed interface that stores validated payloads using boxed classes

JustNumberBoxedNumber

public record JustNumberBoxedNumber
implements JustNumberBoxed

record that stores validated Number payloads, sealed permits implementation

Constructor Summary

Constructor and Description
JustNumberBoxedNumber(Number data)
Creates an instance, private visibility

Method Summary

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

JustNumber

public static class JustNumber
extends NumberJsonSchema.NumberJsonSchema1

A schema class that validates payloads

Methods Inherited from class org.openapijsonschematools.client.schemas.NumberJsonSchema.NumberJsonSchema1
validate
validateAndBox

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