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

Latest commit

 

History

History
316 lines (250 loc) · 12.8 KB

File metadata and controls

316 lines (250 loc) · 12.8 KB

Whale

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

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
  • enum classes

Nested Class Summary

Modifier and Type Class and Description
sealed interface Whale.Whale1Boxed
sealed interface for validated payloads
record Whale.Whale1BoxedMap
boxed class to store validated Map payloads
static class Whale.Whale1
schema class
static class Whale.WhaleMapBuilder
builder for Map payloads
static class Whale.WhaleMap
output class for Map payloads
sealed interface Whale.ClassNameBoxed
sealed interface for validated payloads
record Whale.ClassNameBoxedString
boxed class to store validated String payloads
static class Whale.ClassName
schema class
enum Whale.StringClassNameEnums
String enum
sealed interface Whale.HasTeethBoxed
sealed interface for validated payloads
record Whale.HasTeethBoxedBoolean
boxed class to store validated boolean payloads
static class Whale.HasTeeth
schema class
sealed interface Whale.HasBaleenBoxed
sealed interface for validated payloads
record Whale.HasBaleenBoxedBoolean
boxed class to store validated boolean payloads
static class Whale.HasBaleen
schema class

Whale1Boxed

public sealed interface Whale1Boxed
permits
Whale1BoxedMap

sealed interface that stores validated payloads using boxed classes

Whale1BoxedMap

public record Whale1BoxedMap
implements Whale1Boxed

record that stores validated Map payloads, sealed permits implementation

Constructor Summary

Constructor and Description
Whale1BoxedMap(WhaleMap data)
Creates an instance, private visibility

Method Summary

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

Whale1

public static class Whale1
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.Whale;

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

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

// Map validation
Whale.WhaleMap validatedPayload =
    Whale.Whale1.validate(
    new Whale.WhaleMapBuilder()
        .className("whale")

        .hasBaleen(true)

        .hasTeeth(true)

    .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("hasBaleen", HasBaleen.class)),
    new PropertyEntry("hasTeeth", HasTeeth.class)),
    new PropertyEntry("className", ClassName.class))
)
Set required = Set.of(
    "className"
)

Method Summary

Modifier and Type Method and Description
WhaleMap validate(Map<?, ?> arg, SchemaConfiguration configuration)
Whale1BoxedMap validateAndBox(Map<?, ?> arg, SchemaConfiguration configuration)
Whale1Boxed validateAndBox(@Nullable Object arg, SchemaConfiguration configuration)
@Nullable Object validate(@Nullable Object arg, SchemaConfiguration configuration)

WhaleMap0Builder

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

A class that builds the Map input type

Constructor Summary

Constructor and Description
WhaleMap0Builder(Map<String, @Nullable Object> instance)
Creates a builder that contains the passed instance

Method Summary

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

WhaleMapBuilder

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

A class that builds the Map input type

Constructor Summary

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

Method Summary

Modifier and Type Method and Description
WhaleMap0Builder className(String value)
WhaleMap0Builder className(StringClassNameEnums value)

WhaleMap

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

A class to store validated Map payloads

Method Summary

Modifier and Type Method and Description
static WhaleMap of(Map<String, ? extends @Nullable Object> arg, SchemaConfiguration configuration)
String className()
must be one of ["whale"]
boolean hasBaleen()
[optional]
boolean hasTeeth()
[optional]
@Nullable Object getAdditionalProperty(String name)
provides type safety for additional properties

ClassNameBoxed

public sealed interface ClassNameBoxed
permits
ClassNameBoxedString

sealed interface that stores validated payloads using boxed classes

ClassNameBoxedString

public record ClassNameBoxedString
implements ClassNameBoxed

record that stores validated String payloads, sealed permits implementation

Constructor Summary

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

Method Summary

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

ClassName

public static class ClassName
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.Whale;

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 = Whale.ClassName.validate(
    "whale",
    configuration
);

Field Summary

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

Method Summary

Modifier and Type Method and Description
String validate(String arg, SchemaConfiguration configuration)
String validate(StringClassNameEnums arg, SchemaConfiguration configuration)
ClassNameBoxedString validateAndBox(String arg, SchemaConfiguration configuration)
ClassNameBoxed validateAndBox(@Nullable Object arg, SchemaConfiguration configuration)
@Nullable Object validate(@Nullable Object arg, SchemaConfiguration configuration)

StringClassNameEnums

public enum StringClassNameEnums
extends Enum<StringClassNameEnums>

A class that stores String enum values

Enum Constant Summary

Enum Constant Description
WHALE value = "whale"

HasTeethBoxed

public sealed interface HasTeethBoxed
permits
HasTeethBoxedBoolean

sealed interface that stores validated payloads using boxed classes

HasTeethBoxedBoolean

public record HasTeethBoxedBoolean
implements HasTeethBoxed

record that stores validated boolean payloads, sealed permits implementation

Constructor Summary

Constructor and Description
HasTeethBoxedBoolean(boolean data)
Creates an instance, private visibility

Method Summary

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

HasTeeth

public static class HasTeeth
extends BooleanJsonSchema.BooleanJsonSchema1

A schema class that validates payloads

Methods Inherited from class org.openapijsonschematools.client.schemas.BooleanJsonSchema.BooleanJsonSchema1
validate
validateAndBox

HasBaleenBoxed

public sealed interface HasBaleenBoxed
permits
HasBaleenBoxedBoolean

sealed interface that stores validated payloads using boxed classes

HasBaleenBoxedBoolean

public record HasBaleenBoxedBoolean
implements HasBaleenBoxed

record that stores validated boolean payloads, sealed permits implementation

Constructor Summary

Constructor and Description
HasBaleenBoxedBoolean(boolean data)
Creates an instance, private visibility

Method Summary

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

HasBaleen

public static class HasBaleen
extends BooleanJsonSchema.BooleanJsonSchema1

A schema class that validates payloads

Methods Inherited from class org.openapijsonschematools.client.schemas.BooleanJsonSchema.BooleanJsonSchema1
validate
validateAndBox

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