Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
software.amazon.awssdk.services.iot.model.OTAUpdateFile Maven / Gradle / Ivy
Go to download
The AWS Java SDK for AWS Iot Service module holds the client classes that are used for communicating
with AWS IoT Service
/*
* 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.services.iot.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.traits.MapTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructMap;
import software.amazon.awssdk.core.util.SdkAutoConstructMap;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Describes a file to be associated with an OTA update.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class OTAUpdateFile implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField FILE_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("fileName").getter(getter(OTAUpdateFile::fileName)).setter(setter(Builder::fileName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("fileName").build()).build();
private static final SdkField FILE_TYPE_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("fileType").getter(getter(OTAUpdateFile::fileType)).setter(setter(Builder::fileType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("fileType").build()).build();
private static final SdkField FILE_VERSION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("fileVersion").getter(getter(OTAUpdateFile::fileVersion)).setter(setter(Builder::fileVersion))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("fileVersion").build()).build();
private static final SdkField FILE_LOCATION_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("fileLocation").getter(getter(OTAUpdateFile::fileLocation)).setter(setter(Builder::fileLocation))
.constructor(FileLocation::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("fileLocation").build()).build();
private static final SdkField CODE_SIGNING_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("codeSigning").getter(getter(OTAUpdateFile::codeSigning)).setter(setter(Builder::codeSigning))
.constructor(CodeSigning::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("codeSigning").build()).build();
private static final SdkField> ATTRIBUTES_FIELD = SdkField
.> builder(MarshallingType.MAP)
.memberName("attributes")
.getter(getter(OTAUpdateFile::attributes))
.setter(setter(Builder::attributes))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("attributes").build(),
MapTrait.builder()
.keyLocationName("key")
.valueLocationName("value")
.valueFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("value").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(FILE_NAME_FIELD,
FILE_TYPE_FIELD, FILE_VERSION_FIELD, FILE_LOCATION_FIELD, CODE_SIGNING_FIELD, ATTRIBUTES_FIELD));
private static final Map> SDK_NAME_TO_FIELD = memberNameToFieldInitializer();
private static final long serialVersionUID = 1L;
private final String fileName;
private final Integer fileType;
private final String fileVersion;
private final FileLocation fileLocation;
private final CodeSigning codeSigning;
private final Map attributes;
private OTAUpdateFile(BuilderImpl builder) {
this.fileName = builder.fileName;
this.fileType = builder.fileType;
this.fileVersion = builder.fileVersion;
this.fileLocation = builder.fileLocation;
this.codeSigning = builder.codeSigning;
this.attributes = builder.attributes;
}
/**
*
* The name of the file.
*
*
* @return The name of the file.
*/
public final String fileName() {
return fileName;
}
/**
*
* An integer value you can include in the job document to allow your devices to identify the type of file received
* from the cloud.
*
*
* @return An integer value you can include in the job document to allow your devices to identify the type of file
* received from the cloud.
*/
public final Integer fileType() {
return fileType;
}
/**
*
* The file version.
*
*
* @return The file version.
*/
public final String fileVersion() {
return fileVersion;
}
/**
*
* The location of the updated firmware.
*
*
* @return The location of the updated firmware.
*/
public final FileLocation fileLocation() {
return fileLocation;
}
/**
*
* The code signing method of the file.
*
*
* @return The code signing method of the file.
*/
public final CodeSigning codeSigning() {
return codeSigning;
}
/**
* For responses, this returns true if the service returned a value for the Attributes property. This DOES NOT check
* that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property). This is
* useful because the SDK will never return a null collection or map, but you may need to differentiate between the
* service returning nothing (or null) and the service returning an empty collection or map. For requests, this
* returns true if a value for the property was specified in the request builder, and false if a value was not
* specified.
*/
public final boolean hasAttributes() {
return attributes != null && !(attributes instanceof SdkAutoConstructMap);
}
/**
*
* A list of name-attribute pairs. They won't be sent to devices as a part of the Job document.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasAttributes} method.
*
*
* @return A list of name-attribute pairs. They won't be sent to devices as a part of the Job document.
*/
public final Map attributes() {
return attributes;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(fileName());
hashCode = 31 * hashCode + Objects.hashCode(fileType());
hashCode = 31 * hashCode + Objects.hashCode(fileVersion());
hashCode = 31 * hashCode + Objects.hashCode(fileLocation());
hashCode = 31 * hashCode + Objects.hashCode(codeSigning());
hashCode = 31 * hashCode + Objects.hashCode(hasAttributes() ? attributes() : null);
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof OTAUpdateFile)) {
return false;
}
OTAUpdateFile other = (OTAUpdateFile) obj;
return Objects.equals(fileName(), other.fileName()) && Objects.equals(fileType(), other.fileType())
&& Objects.equals(fileVersion(), other.fileVersion()) && Objects.equals(fileLocation(), other.fileLocation())
&& Objects.equals(codeSigning(), other.codeSigning()) && hasAttributes() == other.hasAttributes()
&& Objects.equals(attributes(), other.attributes());
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*/
@Override
public final String toString() {
return ToString.builder("OTAUpdateFile").add("FileName", fileName()).add("FileType", fileType())
.add("FileVersion", fileVersion()).add("FileLocation", fileLocation()).add("CodeSigning", codeSigning())
.add("Attributes", hasAttributes() ? attributes() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "fileName":
return Optional.ofNullable(clazz.cast(fileName()));
case "fileType":
return Optional.ofNullable(clazz.cast(fileType()));
case "fileVersion":
return Optional.ofNullable(clazz.cast(fileVersion()));
case "fileLocation":
return Optional.ofNullable(clazz.cast(fileLocation()));
case "codeSigning":
return Optional.ofNullable(clazz.cast(codeSigning()));
case "attributes":
return Optional.ofNullable(clazz.cast(attributes()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Map> memberNameToFieldInitializer() {
Map> map = new HashMap<>();
map.put("fileName", FILE_NAME_FIELD);
map.put("fileType", FILE_TYPE_FIELD);
map.put("fileVersion", FILE_VERSION_FIELD);
map.put("fileLocation", FILE_LOCATION_FIELD);
map.put("codeSigning", CODE_SIGNING_FIELD);
map.put("attributes", ATTRIBUTES_FIELD);
return Collections.unmodifiableMap(map);
}
private static Function getter(Function g) {
return obj -> g.apply((OTAUpdateFile) obj);
}
private static BiConsumer setter(BiConsumer s) {
return (obj, val) -> s.accept((Builder) obj, val);
}
public interface Builder extends SdkPojo, CopyableBuilder {
/**
*
* The name of the file.
*
*
* @param fileName
* The name of the file.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder fileName(String fileName);
/**
*
* An integer value you can include in the job document to allow your devices to identify the type of file
* received from the cloud.
*
*
* @param fileType
* An integer value you can include in the job document to allow your devices to identify the type of
* file received from the cloud.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder fileType(Integer fileType);
/**
*
* The file version.
*
*
* @param fileVersion
* The file version.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder fileVersion(String fileVersion);
/**
*
* The location of the updated firmware.
*
*
* @param fileLocation
* The location of the updated firmware.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder fileLocation(FileLocation fileLocation);
/**
*
* The location of the updated firmware.
*
* This is a convenience method that creates an instance of the {@link FileLocation.Builder} avoiding the need
* to create one manually via {@link FileLocation#builder()}.
*
*
* When the {@link Consumer} completes, {@link FileLocation.Builder#build()} is called immediately and its
* result is passed to {@link #fileLocation(FileLocation)}.
*
* @param fileLocation
* a consumer that will call methods on {@link FileLocation.Builder}
* @return Returns a reference to this object so that method calls can be chained together.
* @see #fileLocation(FileLocation)
*/
default Builder fileLocation(Consumer fileLocation) {
return fileLocation(FileLocation.builder().applyMutation(fileLocation).build());
}
/**
*
* The code signing method of the file.
*
*
* @param codeSigning
* The code signing method of the file.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder codeSigning(CodeSigning codeSigning);
/**
*
* The code signing method of the file.
*
* This is a convenience method that creates an instance of the {@link CodeSigning.Builder} avoiding the need to
* create one manually via {@link CodeSigning#builder()}.
*
*
* When the {@link Consumer} completes, {@link CodeSigning.Builder#build()} is called immediately and its result
* is passed to {@link #codeSigning(CodeSigning)}.
*
* @param codeSigning
* a consumer that will call methods on {@link CodeSigning.Builder}
* @return Returns a reference to this object so that method calls can be chained together.
* @see #codeSigning(CodeSigning)
*/
default Builder codeSigning(Consumer codeSigning) {
return codeSigning(CodeSigning.builder().applyMutation(codeSigning).build());
}
/**
*
* A list of name-attribute pairs. They won't be sent to devices as a part of the Job document.
*
*
* @param attributes
* A list of name-attribute pairs. They won't be sent to devices as a part of the Job document.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder attributes(Map attributes);
}
static final class BuilderImpl implements Builder {
private String fileName;
private Integer fileType;
private String fileVersion;
private FileLocation fileLocation;
private CodeSigning codeSigning;
private Map attributes = DefaultSdkAutoConstructMap.getInstance();
private BuilderImpl() {
}
private BuilderImpl(OTAUpdateFile model) {
fileName(model.fileName);
fileType(model.fileType);
fileVersion(model.fileVersion);
fileLocation(model.fileLocation);
codeSigning(model.codeSigning);
attributes(model.attributes);
}
public final String getFileName() {
return fileName;
}
public final void setFileName(String fileName) {
this.fileName = fileName;
}
@Override
public final Builder fileName(String fileName) {
this.fileName = fileName;
return this;
}
public final Integer getFileType() {
return fileType;
}
public final void setFileType(Integer fileType) {
this.fileType = fileType;
}
@Override
public final Builder fileType(Integer fileType) {
this.fileType = fileType;
return this;
}
public final String getFileVersion() {
return fileVersion;
}
public final void setFileVersion(String fileVersion) {
this.fileVersion = fileVersion;
}
@Override
public final Builder fileVersion(String fileVersion) {
this.fileVersion = fileVersion;
return this;
}
public final FileLocation.Builder getFileLocation() {
return fileLocation != null ? fileLocation.toBuilder() : null;
}
public final void setFileLocation(FileLocation.BuilderImpl fileLocation) {
this.fileLocation = fileLocation != null ? fileLocation.build() : null;
}
@Override
public final Builder fileLocation(FileLocation fileLocation) {
this.fileLocation = fileLocation;
return this;
}
public final CodeSigning.Builder getCodeSigning() {
return codeSigning != null ? codeSigning.toBuilder() : null;
}
public final void setCodeSigning(CodeSigning.BuilderImpl codeSigning) {
this.codeSigning = codeSigning != null ? codeSigning.build() : null;
}
@Override
public final Builder codeSigning(CodeSigning codeSigning) {
this.codeSigning = codeSigning;
return this;
}
public final Map getAttributes() {
if (attributes instanceof SdkAutoConstructMap) {
return null;
}
return attributes;
}
public final void setAttributes(Map attributes) {
this.attributes = AttributesMapCopier.copy(attributes);
}
@Override
public final Builder attributes(Map attributes) {
this.attributes = AttributesMapCopier.copy(attributes);
return this;
}
@Override
public OTAUpdateFile build() {
return new OTAUpdateFile(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
@Override
public Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
}
}