All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sap.cloud.rest.api.client.model.multipart.MultipartEntity Maven / Gradle / Ivy

Go to download

Java HTTP client library for HTTP handling, when building clients for RESTful APIs.

The newest version!
package com.sap.cloud.rest.api.client.model.multipart;

import java.util.List;
import java.util.stream.Collectors;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

/**
 * Represents a multipart entity. It consists of a list of {@link EntityPart}s.
 *
 * @param 
 *            the type of the entity parts
 */
public class MultipartEntity {

    private final List> multipartEntity;

    public MultipartEntity(List> parts) {
        this.multipartEntity = parts;
    }

    public List> getParts() {
        return multipartEntity;
    }

    public List> getPartsByName(String name) {
        return multipartEntity.stream()
                .filter(x -> x.getName().equals(name))
                .collect(Collectors.toList());
    }

    public String toString() {
        return new ToStringBuilder(MultipartEntity.class.getName(), ToStringStyle.JSON_STYLE)
                .append("multipartEntity", multipartEntity)
                .toString();
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((multipartEntity == null) ? 0 : multipartEntity.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null) return false;
        if (getClass() != obj.getClass()) return false;
        MultipartEntity other = (MultipartEntity) obj;
        if (multipartEntity == null) {
            if (other.multipartEntity != null) return false;
        } else if (!multipartEntity.equals(other.multipartEntity)) return false;
        return true;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy