Skip to content

Commit 20b01d3

Browse files
jartmziccard
authored andcommitted
Correct more style issues and remove warnings
This change is a follow-up to post-merge comments in googleapis#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 d51f838 commit 20b01d3

19 files changed

+179
-197
lines changed

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

Lines changed: 16 additions & 9 deletions
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/cloud/storage/contrib/nio/CloudStorageFileAttributeView.java

Lines changed: 1 addition & 2 deletions
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/cloud/storage/contrib/nio/CloudStorageFileAttributes.java

Lines changed: 10 additions & 8 deletions
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/cloud/storage/contrib/nio/CloudStorageFileSystem.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import javax.annotation.concurrent.Immutable;
2525

2626
/**
27-
* Google Cloud Storage {@link FileSystem}
27+
* Google Cloud Storage {@link FileSystem} implementation.
2828
*
2929
* @see <a href="https://developers.google.com/storage/docs/concepts-techniques#concepts">
3030
* Concepts and Terminology</a>
@@ -35,7 +35,7 @@
3535
public final class CloudStorageFileSystem extends FileSystem {
3636

3737
/**
38-
* Returns Google Cloud Storage {@link FileSystem} object for a given bucket name.
38+
* Returns Google Cloud Storage {@link FileSystem} object for {@code bucket}.
3939
*
4040
* <p><b>NOTE:</b> You may prefer to use Java's standard API instead:<pre> {@code
4141
*
@@ -54,7 +54,7 @@ public static CloudStorageFileSystem forBucket(String bucket) {
5454
}
5555

5656
/**
57-
* Creates a new filesystem for a particular bucket, with customizable settings.
57+
* Creates new file system instance for {@code bucket}, with customizable settings.
5858
*
5959
* @see #forBucket(String)
6060
*/
@@ -113,21 +113,21 @@ public CloudStorageFileSystemProvider provider() {
113113
}
114114

115115
/**
116-
* Returns the Cloud Storage bucket name being served by this file system.
116+
* Returns Cloud Storage bucket name being served by this file system.
117117
*/
118118
public String bucket() {
119119
return bucket;
120120
}
121121

122122
/**
123-
* Returns the configuration object for this filesystem instance.
123+
* Returns configuration object for this file system instance.
124124
*/
125125
public CloudStorageConfiguration config() {
126126
return config;
127127
}
128128

129129
/**
130-
* Converts a cloud storage object name to a {@link Path} object.
130+
* Converts Cloud Storage object name to a {@link Path} object.
131131
*/
132132
@Override
133133
public CloudStoragePath getPath(String first, String... more) {
@@ -211,7 +211,7 @@ public WatchService newWatchService() throws IOException {
211211
}
212212

213213
@Override
214-
public boolean equals(@Nullable Object other) {
214+
public boolean equals(Object other) {
215215
return this == other
216216
|| other instanceof CloudStorageFileSystem
217217
&& Objects.equals(config, ((CloudStorageFileSystem) other).config)

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
import javax.annotation.concurrent.ThreadSafe;
5757

5858
/**
59-
* Google Cloud Storage {@link FileSystemProvider}.
59+
* Google Cloud Storage {@link FileSystemProvider} implementation.
6060
*/
6161
@ThreadSafe
6262
@AutoService(FileSystemProvider.class)
@@ -99,15 +99,15 @@ public String getScheme() {
9999
}
100100

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

109109
/**
110-
* Returns cloud storage file system, provided a URI with no path, e.g. {@code gs://bucket}.
110+
* Returns Cloud Storage file system, provided a URI with no path, e.g. {@code gs://bucket}.
111111
*/
112112
@Override
113113
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/cloud/storage/contrib/nio/CloudStorageObjectAttributes.java

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@
1313
import java.util.Objects;
1414

1515
import javax.annotation.Nonnull;
16-
import javax.annotation.Nullable;
1716
import javax.annotation.concurrent.Immutable;
1817

1918
/**
20-
* Metadata for a Google Cloud Storage object.
19+
* Metadata for a Google Cloud Storage file.
2120
*/
2221
@Immutable
2322
final class CloudStorageObjectAttributes implements CloudStorageFileAttributes {
@@ -46,67 +45,36 @@ public FileTime lastModifiedTime() {
4645
return creationTime();
4746
}
4847

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

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

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

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

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

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

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

148116
@Override
149-
public boolean equals(@Nullable Object other) {
117+
public boolean equals(Object other) {
150118
return this == other
151119
|| other instanceof CloudStorageObjectAttributes
152120
&& Objects.equals(info, ((CloudStorageObjectAttributes) other).info);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.google.cloud.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/cloud/storage/contrib/nio/CloudStoragePath.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ public int compareTo(Path other) {
273273
}
274274

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

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

Lines changed: 1 addition & 1 deletion
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/cloud/storage/contrib/nio/CloudStorageUtil.java

Lines changed: 1 addition & 1 deletion
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)