Skip to content

Commit 770d470

Browse files
committed
Correct more style issues and remove warnings
This change is a follow-up to post-merge comments in #706 made by @ajkannan and @aozarov. The following changes have been made: - Don't use `@Nullable` on `equals()` methods - Don't `throws Exception` in test methods unless needed - Use incomplete sentences in JavaDoc summary fragment - Capitalize Cloud Storage - Get rid of some one-line JavaDocs - Use `@code` formatting when appropriate - Remove `Paths.get()` usages which is deprecated in Java 8 - Remove `@SuppressWarnings("null")` which no one uses
1 parent ee60eb0 commit 770d470

20 files changed

+191
-209
lines changed

gcloud-java-contrib/gcloud-java-nio/src/main/java/com/google/gcloud/storage/contrib/nio/CloudStorageConfiguration.java

+16-9
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
import java.util.Map;
88

99
/**
10-
* Configuration for a {@link CloudStorageFileSystem} instance.
10+
* Configuration for {@link CloudStorageFileSystem} instances.
1111
*/
1212
@AutoValue
1313
public abstract class CloudStorageConfiguration {
1414

1515
/**
16-
* Returns path of the current working directory. This defaults to the root directory.
16+
* Returns path of current working directory. This defaults to the root directory.
1717
*/
1818
public abstract String workingDirectory();
1919

@@ -31,10 +31,14 @@ public abstract class CloudStorageConfiguration {
3131
*/
3232
public abstract boolean stripPrefixSlash();
3333

34-
/** Return {@code true} if paths with a trailing slash should be treated as fake directories. */
34+
/**
35+
* Returns {@code true} if paths with a trailing slash should be treated as fake directories.
36+
*/
3537
public abstract boolean usePseudoDirectories();
3638

37-
/** Returns the block size (in bytes) used when talking to the GCS HTTP server. */
39+
/**
40+
* Returns block size (in bytes) used when talking to the GCS HTTP server.
41+
*/
3842
public abstract int blockSize();
3943

4044
/**
@@ -50,7 +54,8 @@ public static Builder builder() {
5054
return new Builder();
5155
}
5256

53-
/** Builder for {@link CloudStorageConfiguration}.
57+
/**
58+
* Builder for {@link CloudStorageConfiguration}.
5459
*/
5560
public static final class Builder {
5661

@@ -61,8 +66,8 @@ public static final class Builder {
6166
private int blockSize = CloudStorageFileSystem.BLOCK_SIZE_DEFAULT;
6267

6368
/**
64-
* Changes the current working directory for a new filesystem. This cannot be changed once it's
65-
* been set. You'll need to simply create another filesystem object.
69+
* Changes current working directory for new filesystem. This cannot be changed once it's
70+
* been set. You'll need to create another {@link CloudStorageFileSystem} object.
6671
*
6772
* @throws IllegalArgumentException if {@code path} is not absolute.
6873
*/
@@ -92,7 +97,8 @@ public Builder stripPrefixSlash(boolean value) {
9297
return this;
9398
}
9499

95-
/** Configures if paths with a trailing slash should be treated as fake directories.
100+
/**
101+
* Configures if paths with a trailing slash should be treated as fake directories.
96102
*/
97103
public Builder usePseudoDirectories(boolean value) {
98104
usePseudoDirectories = value;
@@ -109,7 +115,8 @@ public Builder blockSize(int value) {
109115
return this;
110116
}
111117

112-
/** Creates a new instance, but does not destroy the builder.
118+
/**
119+
* Creates new instance without destroying builder.
113120
*/
114121
public CloudStorageConfiguration build() {
115122
return new AutoValue_CloudStorageConfiguration(

gcloud-java-contrib/gcloud-java-nio/src/main/java/com/google/gcloud/storage/contrib/nio/CloudStorageFileAttributeView.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import java.nio.file.attribute.FileTime;
1313
import java.util.Objects;
1414

15-
import javax.annotation.Nullable;
1615
import javax.annotation.concurrent.Immutable;
1716

1817
/**
@@ -59,7 +58,7 @@ public void setTimes(FileTime lastModifiedTime, FileTime lastAccessTime, FileTim
5958
}
6059

6160
@Override
62-
public boolean equals(@Nullable Object other) {
61+
public boolean equals(Object other) {
6362
return this == other
6463
|| other instanceof CloudStorageFileAttributeView
6564
&& Objects.equals(storage, ((CloudStorageFileAttributeView) other).storage)

gcloud-java-contrib/gcloud-java-nio/src/main/java/com/google/gcloud/storage/contrib/nio/CloudStorageFileAttributes.java

+10-8
Original file line numberDiff line numberDiff line change
@@ -7,53 +7,55 @@
77
import java.nio.file.attribute.BasicFileAttributes;
88
import java.util.List;
99

10-
/** Interface for attributes on a cloud storage file or pseudo-directory. */
10+
/**
11+
* Interface for attributes on a Cloud Storage file or pseudo-directory.
12+
*/
1113
public interface CloudStorageFileAttributes extends BasicFileAttributes {
1214

1315
/**
14-
* Returns the HTTP etag hash for this object.
16+
* Returns HTTP etag hash of object contents.
1517
*
1618
* @see "https://developers.google.com/storage/docs/hashes-etags"
1719
*/
1820
Optional<String> etag();
1921

2022
/**
21-
* Returns the mime type (e.g. text/plain) if it was set for this object.
23+
* Returns mime type (e.g. text/plain), if set.
2224
*
2325
* @see "http://en.wikipedia.org/wiki/Internet_media_type#List_of_common_media_types"
2426
*/
2527
Optional<String> mimeType();
2628

2729
/**
28-
* Returns the ACL value on this Cloud Storage object.
30+
* Returns access control list.
2931
*
3032
* @see "https://developers.google.com/storage/docs/reference-headers#acl"
3133
*/
3234
Optional<List<Acl>> acl();
3335

3436
/**
35-
* Returns the {@code Cache-Control} HTTP header value, if set on this object.
37+
* Returns {@code Cache-Control} HTTP header value, if set.
3638
*
3739
* @see "https://developers.google.com/storage/docs/reference-headers#cachecontrol"
3840
*/
3941
Optional<String> cacheControl();
4042

4143
/**
42-
* Returns the {@code Content-Encoding} HTTP header value, if set on this object.
44+
* Returns {@code Content-Encoding} HTTP header value, if set.
4345
*
4446
* @see "https://developers.google.com/storage/docs/reference-headers#contentencoding"
4547
*/
4648
Optional<String> contentEncoding();
4749

4850
/**
49-
* Returns the {@code Content-Disposition} HTTP header value, if set on this object.
51+
* Returns {@code Content-Disposition} HTTP header value, if set.
5052
*
5153
* @see "https://developers.google.com/storage/docs/reference-headers#contentdisposition"
5254
*/
5355
Optional<String> contentDisposition();
5456

5557
/**
56-
* Returns user-specified metadata associated with this object.
58+
* Returns user-specified metadata.
5759
*
5860
* @see "https://developers.google.com/storage/docs/reference-headers#contentdisposition"
5961
*/

gcloud-java-contrib/gcloud-java-nio/src/main/java/com/google/gcloud/storage/contrib/nio/CloudStorageFileSystem.java

+7-8
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@
1818
import java.util.Objects;
1919
import java.util.Set;
2020

21-
import javax.annotation.Nullable;
2221
import javax.annotation.concurrent.Immutable;
2322

2423
/**
25-
* Google Cloud Storage {@link FileSystem}
24+
* Google Cloud Storage {@link FileSystem} implementation.
2625
*
2726
* @see <a href="https://developers.google.com/storage/docs/concepts-techniques#concepts">
2827
* Concepts and Terminology</a>
@@ -33,7 +32,7 @@
3332
public final class CloudStorageFileSystem extends FileSystem {
3433

3534
/**
36-
* Returns Google Cloud Storage {@link FileSystem} object for a given bucket name.
35+
* Returns Google Cloud Storage {@link FileSystem} object for {@code bucket}.
3736
*
3837
* <p><b>NOTE:</b> You may prefer to use Java's standard API instead:<pre> {@code
3938
*
@@ -52,7 +51,7 @@ public static CloudStorageFileSystem forBucket(String bucket) {
5251
}
5352

5453
/**
55-
* Creates a new filesystem for a particular bucket, with customizable settings.
54+
* Creates new file system instance for {@code bucket}, with customizable settings.
5655
*
5756
* @see #forBucket(String)
5857
*/
@@ -88,21 +87,21 @@ public CloudStorageFileSystemProvider provider() {
8887
}
8988

9089
/**
91-
* Returns the Cloud Storage bucket name being served by this file system.
90+
* Returns Cloud Storage bucket name being served by this file system.
9291
*/
9392
public String bucket() {
9493
return bucket;
9594
}
9695

9796
/**
98-
* Returns the configuration object for this filesystem instance.
97+
* Returns configuration object for this file system instance.
9998
*/
10099
public CloudStorageConfiguration config() {
101100
return config;
102101
}
103102

104103
/**
105-
* Converts a cloud storage object name to a {@link Path} object.
104+
* Converts Cloud Storage object name to a {@link Path} object.
106105
*/
107106
@Override
108107
public CloudStoragePath getPath(String first, String... more) {
@@ -186,7 +185,7 @@ public WatchService newWatchService() throws IOException {
186185
}
187186

188187
@Override
189-
public boolean equals(@Nullable Object other) {
188+
public boolean equals(Object other) {
190189
return this == other
191190
|| other instanceof CloudStorageFileSystem
192191
&& Objects.equals(config, ((CloudStorageFileSystem) other).config)

gcloud-java-contrib/gcloud-java-nio/src/main/java/com/google/gcloud/storage/contrib/nio/CloudStorageFileSystemProvider.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
import javax.annotation.concurrent.ThreadSafe;
5858

5959
/**
60-
* Google Cloud Storage {@link FileSystemProvider}.
60+
* Google Cloud Storage {@link FileSystemProvider} implementation.
6161
*/
6262
@ThreadSafe
6363
@AutoService(FileSystemProvider.class)
@@ -100,15 +100,15 @@ public String getScheme() {
100100
}
101101

102102
/**
103-
* Returns cloud storage file system, provided a URI with no path, e.g. {@code gs://bucket}.
103+
* Returns Cloud Storage file system, provided a URI with no path, e.g. {@code gs://bucket}.
104104
*/
105105
@Override
106106
public CloudStorageFileSystem getFileSystem(URI uri) {
107107
return newFileSystem(uri, Collections.<String, Object>emptyMap());
108108
}
109109

110110
/**
111-
* Returns cloud storage file system, provided a URI with no path, e.g. {@code gs://bucket}.
111+
* Returns Cloud Storage file system, provided a URI with no path, e.g. {@code gs://bucket}.
112112
*/
113113
@Override
114114
public CloudStorageFileSystem newFileSystem(URI uri, Map<String, ?> env) {
@@ -537,7 +537,7 @@ public FileStore getFileStore(Path path) {
537537
}
538538

539539
@Override
540-
public boolean equals(@Nullable Object other) {
540+
public boolean equals(Object other) {
541541
return this == other
542542
|| other instanceof CloudStorageFileSystemProvider
543543
&& Objects.equals(storage, ((CloudStorageFileSystemProvider) other).storage);

gcloud-java-contrib/gcloud-java-nio/src/main/java/com/google/gcloud/storage/contrib/nio/CloudStorageObjectAttributes.java

+2-34
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@
1414
import java.util.Objects;
1515

1616
import javax.annotation.Nonnull;
17-
import javax.annotation.Nullable;
1817
import javax.annotation.concurrent.Immutable;
1918

2019
/**
21-
* Metadata for a Google Cloud Storage object.
20+
* Metadata for a Google Cloud Storage file.
2221
*/
2322
@Immutable
2423
final class CloudStorageObjectAttributes implements CloudStorageFileAttributes {
@@ -47,67 +46,36 @@ public FileTime lastModifiedTime() {
4746
return creationTime();
4847
}
4948

50-
/**
51-
* Returns the HTTP etag hash for this object.
52-
*/
5349
@Override
5450
public Optional<String> etag() {
5551
return Optional.fromNullable(info.etag());
5652
}
5753

58-
/**
59-
* Returns the mime type (e.g. text/plain) if it was set for this object.
60-
*/
6154
@Override
6255
public Optional<String> mimeType() {
6356
return Optional.fromNullable(info.contentType());
6457
}
6558

66-
/**
67-
* Returns the ACL value on this Cloud Storage object.
68-
*
69-
* @see "https://developers.google.com/storage/docs/reference-headers#acl"
70-
*/
7159
@Override
7260
public Optional<List<Acl>> acl() {
7361
return Optional.fromNullable(info.acl());
7462
}
7563

76-
/**
77-
* Returns the {@code Cache-Control} HTTP header value, if set on this object.
78-
*
79-
* @see "https://developers.google.com/storage/docs/reference-headers#cachecontrol"
80-
*/
8164
@Override
8265
public Optional<String> cacheControl() {
8366
return Optional.fromNullable(info.cacheControl());
8467
}
8568

86-
/**
87-
* Returns the {@code Content-Encoding} HTTP header value, if set on this object.
88-
*
89-
* @see "https://developers.google.com/storage/docs/reference-headers#contentencoding"
90-
*/
9169
@Override
9270
public Optional<String> contentEncoding() {
9371
return Optional.fromNullable(info.contentEncoding());
9472
}
9573

96-
/**
97-
* Returns the {@code Content-Disposition} HTTP header value, if set on this object.
98-
*
99-
* @see "https://developers.google.com/storage/docs/reference-headers#contentdisposition"
100-
*/
10174
@Override
10275
public Optional<String> contentDisposition() {
10376
return Optional.fromNullable(info.contentDisposition());
10477
}
10578

106-
/**
107-
* Returns user-specified metadata associated with this object.
108-
*
109-
* @see "https://developers.google.com/storage/docs/reference-headers#contentdisposition"
110-
*/
11179
@Override
11280
public ImmutableMap<String, String> userMetadata() {
11381
if (null == info.metadata()) {
@@ -147,7 +115,7 @@ public Object fileKey() {
147115
}
148116

149117
@Override
150-
public boolean equals(@Nullable Object other) {
118+
public boolean equals(Object other) {
151119
return this == other
152120
|| other instanceof CloudStorageObjectAttributes
153121
&& Objects.equals(info, ((CloudStorageObjectAttributes) other).info);

gcloud-java-contrib/gcloud-java-nio/src/main/java/com/google/gcloud/storage/contrib/nio/CloudStorageObjectImmutableException.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.google.gcloud.storage.contrib.nio;
22

33
/**
4-
* Exception thrown to indicate we don't support a mutation of a cloud storage object.
4+
* Exception reminding user that Cloud Storage objects can't be mutated.
55
*/
66
public final class CloudStorageObjectImmutableException extends UnsupportedOperationException {
77

gcloud-java-contrib/gcloud-java-nio/src/main/java/com/google/gcloud/storage/contrib/nio/CloudStoragePath.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ public int compareTo(Path other) {
274274
}
275275

276276
@Override
277-
public boolean equals(@Nullable Object other) {
277+
public boolean equals(Object other) {
278278
return this == other
279279
|| other instanceof CloudStoragePath
280280
&& Objects.equals(bucket(), ((CloudStoragePath) other).bucket())

gcloud-java-contrib/gcloud-java-nio/src/main/java/com/google/gcloud/storage/contrib/nio/CloudStoragePseudoDirectoryAttributes.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import java.util.List;
1111

1212
/**
13-
* Metadata for a cloud storage pseudo-directory.
13+
* Metadata for a Cloud Storage pseudo-directory.
1414
*/
1515
final class CloudStoragePseudoDirectoryAttributes implements CloudStorageFileAttributes {
1616

gcloud-java-contrib/gcloud-java-nio/src/main/java/com/google/gcloud/storage/contrib/nio/CloudStorageUtil.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static CloudStoragePath checkPath(Path path) {
3030
if (!(checkNotNull(path) instanceof CloudStoragePath)) {
3131
throw new ProviderMismatchException(
3232
String.format(
33-
"Not a cloud storage path: %s (%s)", path, path.getClass().getSimpleName()));
33+
"Not a Cloud Storage path: %s (%s)", path, path.getClass().getSimpleName()));
3434
}
3535
return (CloudStoragePath) path;
3636
}

0 commit comments

Comments
 (0)