Class BodyRegistry
java.lang.Object
de.craftsblock.craftsnet.api.http.body.BodyRegistry
This class represents a registry for body parsers used in HTTP request processing.
It allows registering parsers for different types of request bodies,
and provides methods to retrieve and check the presence of a parser for a given body type.
- Since:
- 3.0.4-SNAPSHOT
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new BodyRegistry and registers default body parsers for common body types. -
Method Summary
Modifier and TypeMethodDescription<T extends Body>
BodyParser<T>Retrieves the body parser associated with the specified body type.<T extends Body>
booleanisParserPresent(@NotNull Class<T> type) Checks if a parser is registered for the specified body type.booleanisRegistered(BodyParser<? extends Body> loader) Checks if the givenBodyParseris registered.booleanisRegistered(Class<? extends BodyParser<? extends Body>> type) Checks if the given class representation of theBodyParseris registered.<T extends Body>
voidregister(@NotNull BodyParser<T> bodyParser) Registers a body parser for a specific body type.
-
Constructor Details
-
BodyRegistry
public BodyRegistry()Constructs a new BodyRegistry and registers default body parsers for common body types. This constructor initializes the registry with parsers for JSON, multipart form, and standard form bodies.
-
-
Method Details
-
register
Registers a body parser for a specific body type.- Type Parameters:
T- The type of body being parsed.- Parameters:
bodyParser- The body parser for the specified body type.
-
isRegistered
Checks if the givenBodyParseris registered. This class is a wrapper forisRegistered(Class).- Parameters:
loader- TheBodyParserto check.- Returns:
truewhen theBodyParserwas registered,falseotherwise.- Since:
- 3.2.1-SNAPSHOT
-
isRegistered
Checks if the given class representation of theBodyParseris registered.- Parameters:
type- The class representation of theBodyParserto check.- Returns:
truewhen theBodyParserwas registered,falseotherwise.- Since:
- 3.2.1-SNAPSHOT
-
getParser
Retrieves the body parser associated with the specified body type.- Type Parameters:
T- The type of body being parsed.- Parameters:
type- The class representing the body type.- Returns:
- The body parser for the specified body type, or null if not found.
-
isParserPresent
Checks if a parser is registered for the specified body type.- Type Parameters:
T- The type of body being parsed.- Parameters:
type- The class representing the body type.- Returns:
- true if a parser is registered for the specified body type, false otherwise.
-