software.amazon.awssdk.transfer.s3.internal.serialization.TransferManagerJsonMarshaller Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of s3-transfer-manager Show documentation
Show all versions of s3-transfer-manager Show documentation
The S3 Transfer Manager allows customers to easily and optimally
transfer objects and directories to and from S3.
/*
* Copyright Amazon.com, Inc. or its affiliates. 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.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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 software.amazon.awssdk.transfer.s3.internal.serialization;
import static software.amazon.awssdk.transfer.s3.internal.serialization.TransferManagerMarshallingUtils.getMarshaller;
import java.math.BigDecimal;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.core.SdkBytes;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructMap;
import software.amazon.awssdk.protocols.core.Marshaller;
import software.amazon.awssdk.protocols.jsoncore.JsonWriter;
/**
* Interface to marshall data according to the JSON protocol specification.
*
* @param Type to marshall.
*/
@FunctionalInterface
@SdkInternalApi
public interface TransferManagerJsonMarshaller extends Marshaller {
TransferManagerJsonMarshaller STRING = (val, jsonGenerator) -> jsonGenerator.writeValue(val);
TransferManagerJsonMarshaller SHORT = (val, jsonGenerator) -> jsonGenerator.writeValue(val);
TransferManagerJsonMarshaller INTEGER = (val, jsonGenerator) -> jsonGenerator.writeValue(val);
TransferManagerJsonMarshaller LONG = (val, jsonGenerator) -> jsonGenerator.writeValue(val);
TransferManagerJsonMarshaller FLOAT = (val, jsonGenerator) -> jsonGenerator.writeValue(val);
TransferManagerJsonMarshaller DOUBLE = (val, jsonGenerator) -> jsonGenerator.writeValue(val);
TransferManagerJsonMarshaller BIG_DECIMAL = (val, jsonGenerator) -> jsonGenerator.writeValue(val);
TransferManagerJsonMarshaller BOOLEAN = (val, jsonGenerator) -> jsonGenerator.writeValue(val);
TransferManagerJsonMarshaller INSTANT = (val, jsonGenerator) -> jsonGenerator.writeValue(val);
TransferManagerJsonMarshaller SDK_BYTES = (val, jsonGenerator) -> jsonGenerator.writeValue(val.asByteBuffer());
TransferManagerJsonMarshaller NULL = new TransferManagerJsonMarshaller() {
@Override
public void marshall(Void val, JsonWriter generator, String paramName) {
if (paramName == null) {
generator.writeNull();
}
}
@Override
public void marshall(Void val, JsonWriter jsonGenerator) {
}
};
TransferManagerJsonMarshaller> LIST = new TransferManagerJsonMarshaller>() {
@Override
public void marshall(List> list, JsonWriter jsonGenerator) {
jsonGenerator.writeStartArray();
list.forEach(val -> getMarshaller(val).marshall(val, jsonGenerator, null));
jsonGenerator.writeEndArray();
}
@Override
public boolean shouldEmit(List> list) {
return !list.isEmpty() || !(list instanceof SdkAutoConstructList);
}
};
TransferManagerJsonMarshaller