com.palantir.dialogue.BodySerDe Maven / Gradle / Ivy
/*
* (c) Copyright 2019 Palantir Technologies Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.palantir.dialogue;
import java.io.InputStream;
import java.util.Optional;
/** Request and response Deserialization and Serialization functionality used by generated code. */
public interface BodySerDe {
/** Creates a {@link Serializer} for the requested type. Serializer instances should be reused. */
Serializer serializer(TypeMarker type);
/** Creates a {@link Deserializer} for the requested type. Deserializer instances should be reused. */
Deserializer deserializer(TypeMarker type);
/**
* Returns a {@link Deserializer} that fails if a non-empty reponse body is presented and returns null otherwise.
*/
Deserializer emptyBodyDeserializer();
/**
* Returns a {@link Deserializer} that reads an {@link InputStream} from the {@link Response} body.
*
* This method is named
inputStreamDeserializer
not binaryDeserializer
* to support future streaming binary bindings without conflicting method signatures.
*/
Deserializer inputStreamDeserializer();
/** Same as {@link #inputStreamDeserializer()} with support for 204 responses. */
Deserializer> optionalInputStreamDeserializer();
/** Serializes a {@link BinaryRequestBody} to application/octet-stream
. */
RequestBody serialize(BinaryRequestBody value);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy