kopia lustrzana https://github.com/gaul/s3proxy
Prefer static imports for Preconditions
rodzic
51e7f3c22a
commit
2e82478f0e
|
@ -16,10 +16,11 @@
|
|||
|
||||
package org.gaul.s3proxy;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
/**
|
||||
* List of S3 error codes. Reference:
|
||||
|
@ -63,7 +64,7 @@ enum S3ErrorCode {
|
|||
this.errorCode = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL,
|
||||
name());
|
||||
this.httpStatusCode = httpStatusCode;
|
||||
this.message = Preconditions.checkNotNull(message);
|
||||
this.message = checkNotNull(message);
|
||||
}
|
||||
|
||||
public String getErrorCode() {
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
|
||||
package org.gaul.s3proxy;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
|
@ -23,7 +26,6 @@ import java.net.URI;
|
|||
import java.util.Properties;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.inject.Module;
|
||||
|
@ -56,11 +58,12 @@ public final class S3Proxy {
|
|||
public S3Proxy(BlobStore blobStore, URI endpoint, String identity,
|
||||
String credential, String keyStorePath, String keyStorePassword,
|
||||
boolean forceMultiPartUpload, Optional<String> virtualHost) {
|
||||
Preconditions.checkNotNull(blobStore);
|
||||
Preconditions.checkNotNull(endpoint);
|
||||
checkNotNull(blobStore);
|
||||
checkNotNull(endpoint);
|
||||
// TODO: allow service paths?
|
||||
Preconditions.checkArgument(endpoint.getPath().isEmpty(),
|
||||
checkArgument(endpoint.getPath().isEmpty(),
|
||||
"endpoint path must be empty, was: " + endpoint.getPath());
|
||||
checkNotNull(virtualHost);
|
||||
|
||||
server = new Server();
|
||||
HttpConnectionFactory httpConnectionFactory =
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
|
||||
package org.gaul.s3proxy;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
@ -50,7 +53,6 @@ import javax.xml.stream.XMLStreamReader;
|
|||
import javax.xml.stream.XMLStreamWriter;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
@ -133,13 +135,13 @@ final class S3ProxyHandler extends AbstractHandler {
|
|||
|
||||
S3ProxyHandler(BlobStore blobStore, String identity, String credential,
|
||||
boolean forceMultiPartUpload, Optional<String> virtualHost) {
|
||||
this.blobStore = Preconditions.checkNotNull(blobStore);
|
||||
this.blobStore = checkNotNull(blobStore);
|
||||
this.blobStoreType =
|
||||
blobStore.getContext().unwrap().getProviderMetadata().getId();
|
||||
this.identity = identity;
|
||||
this.credential = credential;
|
||||
this.forceMultiPartUpload = forceMultiPartUpload;
|
||||
this.virtualHost = Preconditions.checkNotNull(virtualHost);
|
||||
this.virtualHost = checkNotNull(virtualHost);
|
||||
xmlOutputFactory.setProperty("javax.xml.stream.isRepairingNamespaces",
|
||||
Boolean.FALSE);
|
||||
}
|
||||
|
@ -1222,7 +1224,7 @@ final class S3ProxyHandler extends AbstractHandler {
|
|||
private void sendSimpleErrorResponse(HttpServletResponse response,
|
||||
S3ErrorCode code, String element, String characters)
|
||||
throws IOException {
|
||||
Preconditions.checkArgument(!(element == null ^ characters == null),
|
||||
checkArgument(!(element == null ^ characters == null),
|
||||
"Must specify neither or both element and characters");
|
||||
logger.debug("{} {} {}", code, element, characters);
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<module name="AvoidNestedBlocks"/>
|
||||
<module name="AvoidStarImport"/>
|
||||
<module name="AvoidStaticImport">
|
||||
<property name="excludes" value="org.assertj.core.api.Assertions.assertThat,org.junit.Assert.fail"/>
|
||||
<property name="excludes" value="com.google.common.base.Preconditions.checkArgument,com.google.common.base.Preconditions.checkNotNull,com.google.common.base.Preconditions.checkState,org.assertj.core.api.Assertions.assertThat,org.junit.Assert.fail"/>
|
||||
</module>
|
||||
<module name="ClassTypeParameterName"/>
|
||||
<module name="CovariantEquals"/>
|
||||
|
|
Ładowanie…
Reference in New Issue