Skip to content

Commit ee60eb0

Browse files
committed
Merge pull request #706 from jart/nio-java-formatter
Run google-java-format on GCS NIO
2 parents c32010c + a02f0e9 commit ee60eb0

25 files changed

+397
-306
lines changed

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

+5-4
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66

77
import java.util.Map;
88

9-
/** CloudStorageConfiguration is the configuration class for
10-
* {@link CloudStorageFileSystem#forBucket}. */
9+
/**
10+
* Configuration for a {@link CloudStorageFileSystem} instance.
11+
*/
1112
@AutoValue
1213
public abstract class CloudStorageConfiguration {
1314

14-
/** Returns the path of the current working directory. Defaults to the root directory.
15+
/**
16+
* Returns path of the current working directory. This defaults to the root directory.
1517
*/
1618
public abstract String workingDirectory();
1719

@@ -107,7 +109,6 @@ public Builder blockSize(int value) {
107109
return this;
108110
}
109111

110-
111112
/** Creates a new instance, but does not destroy the builder.
112113
*/
113114
public CloudStorageConfiguration build() {

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

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

3-
import static com.google.common.base.Verify.verifyNotNull;
3+
import static com.google.common.base.Preconditions.checkNotNull;
44

55
import com.google.common.base.MoreObjects;
66
import com.google.gcloud.storage.BlobInfo;
@@ -15,21 +15,22 @@
1515
import javax.annotation.Nullable;
1616
import javax.annotation.concurrent.Immutable;
1717

18-
/** Metadata view for a Google Cloud Storage object.
18+
/**
19+
* Metadata view for a Google Cloud Storage object.
1920
*/
2021
@Immutable
2122
public final class CloudStorageFileAttributeView implements BasicFileAttributeView {
2223

23-
//private final CloudStorageFileSystemProvider provider;
2424
private final Storage storage;
2525
private final CloudStoragePath path;
2626

2727
CloudStorageFileAttributeView(Storage storage, CloudStoragePath path) {
28-
this.storage = verifyNotNull(storage);
29-
this.path = verifyNotNull(path);
28+
this.storage = checkNotNull(storage);
29+
this.path = checkNotNull(path);
3030
}
3131

32-
/** Returns {@value CloudStorageFileSystem#GCS_VIEW}.
32+
/**
33+
* Returns {@value CloudStorageFileSystem#GCS_VIEW}.
3334
*/
3435
@Override
3536
public String name() {
@@ -38,8 +39,7 @@ public String name() {
3839

3940
@Override
4041
public CloudStorageFileAttributes readAttributes() throws IOException {
41-
if (path.seemsLikeADirectory()
42-
&& path.getFileSystem().config().usePseudoDirectories()) {
42+
if (path.seemsLikeADirectory() && path.getFileSystem().config().usePseudoDirectories()) {
4343
return new CloudStoragePseudoDirectoryAttributes(path);
4444
}
4545
BlobInfo blobInfo = storage.get(path.getBlobId());
@@ -62,8 +62,8 @@ public void setTimes(FileTime lastModifiedTime, FileTime lastAccessTime, FileTim
6262
public boolean equals(@Nullable Object other) {
6363
return this == other
6464
|| other instanceof CloudStorageFileAttributeView
65-
&& Objects.equals(storage, ((CloudStorageFileAttributeView) other).storage)
66-
&& Objects.equals(path, ((CloudStorageFileAttributeView) other).path);
65+
&& Objects.equals(storage, ((CloudStorageFileAttributeView) other).storage)
66+
&& Objects.equals(path, ((CloudStorageFileAttributeView) other).path);
6767
}
6868

6969
@Override
@@ -73,9 +73,6 @@ public int hashCode() {
7373

7474
@Override
7575
public String toString() {
76-
return MoreObjects.toStringHelper(this)
77-
.add("storage", storage)
78-
.add("path", path)
79-
.toString();
76+
return MoreObjects.toStringHelper(this).add("storage", storage).add("path", path).toString();
8077
}
8178
}

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

+37-26
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ public static CloudStorageFileSystem forBucket(String bucket) {
5757
* @see #forBucket(String)
5858
*/
5959
public static CloudStorageFileSystem forBucket(String bucket, CloudStorageConfiguration config) {
60-
checkArgument(!bucket.startsWith(URI_SCHEME + ":"),
61-
"Bucket name must not have schema: %s", bucket);
60+
checkArgument(
61+
!bucket.startsWith(URI_SCHEME + ":"), "Bucket name must not have schema: %s", bucket);
6262
return new CloudStorageFileSystem(
6363
new CloudStorageFileSystemProvider(), bucket, checkNotNull(config));
6464
}
@@ -75,9 +75,7 @@ public static CloudStorageFileSystem forBucket(String bucket, CloudStorageConfig
7575
private final CloudStorageConfiguration config;
7676

7777
CloudStorageFileSystem(
78-
CloudStorageFileSystemProvider provider,
79-
String bucket,
80-
CloudStorageConfiguration config) {
78+
CloudStorageFileSystemProvider provider, String bucket, CloudStorageConfiguration config) {
8179
checkArgument(!bucket.isEmpty(), "bucket");
8280
this.provider = provider;
8381
this.bucket = bucket;
@@ -89,47 +87,56 @@ public CloudStorageFileSystemProvider provider() {
8987
return provider;
9088
}
9189

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

98-
/** Returns the configuration object for this filesystem instance.
99-
*/
97+
/**
98+
* Returns the configuration object for this filesystem instance.
99+
*/
100100
public CloudStorageConfiguration config() {
101101
return config;
102102
}
103103

104-
/** Converts a cloud storage object name to a {@link Path} object.
105-
*/
104+
/**
105+
* Converts a cloud storage object name to a {@link Path} object.
106+
*/
106107
@Override
107108
public CloudStoragePath getPath(String first, String... more) {
108-
checkArgument(!first.startsWith(URI_SCHEME + ":"),
109-
"GCS FileSystem.getPath() must not have schema and bucket name: %s", first);
109+
checkArgument(
110+
!first.startsWith(URI_SCHEME + ":"),
111+
"GCS FileSystem.getPath() must not have schema and bucket name: %s",
112+
first);
110113
return CloudStoragePath.getPath(this, first, more);
111114
}
112115

113-
/** Does nothing.
114-
*/
116+
/**
117+
* Does nothing.
118+
*/
115119
@Override
116120
public void close() {}
117121

118-
/** Returns {@code true}.
119-
*/
122+
/**
123+
* Returns {@code true}.
124+
*/
120125
@Override
121126
public boolean isOpen() {
122127
return true;
123128
}
124129

125-
/** Returns {@code false}.
126-
*/
130+
/**
131+
* Returns {@code false}.
132+
*/
127133
@Override
128134
public boolean isReadOnly() {
129135
return false;
130136
}
131137

132-
/** Returns {@value UnixPath#SEPARATOR}.
138+
/**
139+
* Returns {@value UnixPath#SEPARATOR}.
133140
*/
134141
@Override
135142
public String getSeparator() {
@@ -151,22 +158,26 @@ public Set<String> supportedFileAttributeViews() {
151158
return SUPPORTED_VIEWS;
152159
}
153160

154-
/** Always throws {@link UnsupportedOperationException}. */
161+
/**
162+
* Throws {@link UnsupportedOperationException} because this feature hasn't been implemented yet.
163+
*/
155164
@Override
156165
public PathMatcher getPathMatcher(String syntaxAndPattern) {
157166
// TODO: Implement me.
158167
throw new UnsupportedOperationException();
159168
}
160169

161-
/** Always throws {@link UnsupportedOperationException}.
162-
*/
170+
/**
171+
* Throws {@link UnsupportedOperationException} because this feature hasn't been implemented yet.
172+
*/
163173
@Override
164174
public UserPrincipalLookupService getUserPrincipalLookupService() {
165175
// TODO: Implement me.
166176
throw new UnsupportedOperationException();
167177
}
168178

169-
/** Always throws {@link UnsupportedOperationException}.
179+
/**
180+
* Throws {@link UnsupportedOperationException} because this feature hasn't been implemented yet.
170181
*/
171182
@Override
172183
public WatchService newWatchService() throws IOException {
@@ -178,8 +189,8 @@ public WatchService newWatchService() throws IOException {
178189
public boolean equals(@Nullable Object other) {
179190
return this == other
180191
|| other instanceof CloudStorageFileSystem
181-
&& Objects.equals(config, ((CloudStorageFileSystem) other).config)
182-
&& Objects.equals(bucket, ((CloudStorageFileSystem) other).bucket);
192+
&& Objects.equals(config, ((CloudStorageFileSystem) other).config)
193+
&& Objects.equals(bucket, ((CloudStorageFileSystem) other).bucket);
183194
}
184195

185196
@Override

0 commit comments

Comments
 (0)