com.iprogrammerr.gentle.request.binary.DefaultBinaryWithAttributes Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gentle-request Show documentation
Show all versions of gentle-request Show documentation
Compact library for creating and reading http requests.
The newest version!
package com.iprogrammerr.gentle.request.binary;
import java.util.Map;
public final class DefaultBinaryWithAttributes implements BinaryWithAttributes {
private final Binary origin;
private final Map attributes;
public DefaultBinaryWithAttributes(Binary origin, Map attributes) {
this.origin = origin;
this.attributes = attributes;
}
public DefaultBinaryWithAttributes(byte[] content, Map attributes) {
this(() -> content, attributes);
}
@Override
public byte[] content() throws Exception {
return this.origin.content();
}
@Override
public String attribute(String key) throws Exception {
if (!this.attributes.containsKey(key)) {
throw new Exception(String.format("There is no attribute associated with %s key", key));
}
return this.attributes.get(key);
}
@Override
public boolean has(String key) {
return this.attributes.containsKey(key);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy