@@ -46,8 +46,7 @@ public AttachedDisk apply(
46
46
};
47
47
static final Function <AttachedDisk , com .google .api .services .compute .model .AttachedDisk >
48
48
TO_PB_FUNCTION =
49
- new Function <AttachedDisk ,
50
- com .google .api .services .compute .model .AttachedDisk >() {
49
+ new Function <AttachedDisk , com .google .api .services .compute .model .AttachedDisk >() {
51
50
@ Override
52
51
public com .google .api .services .compute .model .AttachedDisk apply (
53
52
AttachedDisk attachedDisk ) {
@@ -233,7 +232,9 @@ public static final class Builder {
233
232
private Boolean boot ;
234
233
private Boolean autoDelete ;
235
234
236
- private Builder () {}
235
+ private Builder (DiskId sourceDisk ) {
236
+ this .sourceDisk = checkNotNull (sourceDisk );
237
+ }
237
238
238
239
private Builder (PersistentDiskConfiguration configuration ) {
239
240
sourceDisk = configuration .sourceDisk ;
@@ -261,8 +262,8 @@ public Builder mode(Mode mode) {
261
262
262
263
/**
263
264
* Sets whether to use the attached disk as a boot disk. If {@code true} the virtual machine
264
- * will use the first partition of the disk for its root filesystem. If not specified, the
265
- * disk is not used as a boot disk.
265
+ * instance will use the first partition of the disk for its root filesystem. If not
266
+ * specified, the isk is not used as a boot disk.
266
267
*/
267
268
public Builder boot (boolean boot ) {
268
269
this .boot = boot ;
@@ -288,7 +289,7 @@ public PersistentDiskConfiguration build() {
288
289
289
290
PersistentDiskConfiguration (Builder builder ) {
290
291
super (Type .PERSISTENT , null , builder .boot , builder .autoDelete );
291
- this .sourceDisk = checkNotNull ( builder .sourceDisk ) ;
292
+ this .sourceDisk = builder .sourceDisk ;
292
293
this .mode = builder .mode ;
293
294
}
294
295
@@ -353,7 +354,7 @@ com.google.api.services.compute.model.AttachedDisk toPb() {
353
354
* persistent disk to attach.
354
355
*/
355
356
public static Builder builder (DiskId sourceDisk ) {
356
- return new Builder (). sourceDisk ( sourceDisk );
357
+ return new Builder (sourceDisk );
357
358
}
358
359
359
360
/**
@@ -367,8 +368,7 @@ public static PersistentDiskConfiguration of(DiskId sourceDisk) {
367
368
@ SuppressWarnings ("unchecked" )
368
369
static PersistentDiskConfiguration fromPb (
369
370
com .google .api .services .compute .model .AttachedDisk diskPb ) {
370
- Builder builder = new Builder ();
371
- builder .sourceDisk (DiskId .fromUrl (diskPb .getSource ()));
371
+ Builder builder = new Builder (DiskId .fromUrl (diskPb .getSource ()));
372
372
if (diskPb .getMode () != null ) {
373
373
builder .mode (Mode .valueOf (diskPb .getMode ()));
374
374
}
@@ -385,7 +385,9 @@ static PersistentDiskConfiguration fromPb(
385
385
/**
386
386
* An attached disk configuration for bootable persistent disks that must be created with the
387
387
* instance they are attached to. Attached disks that use this configuration can only be attached
388
- * to an instance upon creation.
388
+ * to an instance upon creation. A {@code CreateDiskConfiguration} object is never returned by the
389
+ * service: after the instance is created the corresponding attached disk will be returned with a
390
+ * {@link PersistentDiskConfiguration}.
389
391
*/
390
392
public static final class CreateDiskConfiguration extends AttachedDiskConfiguration {
391
393
@@ -407,7 +409,9 @@ public static final class Builder {
407
409
private ImageId sourceImage ;
408
410
private Boolean autoDelete ;
409
411
410
- private Builder () {}
412
+ private Builder (ImageId sourceImage ) {
413
+ this .sourceImage = checkNotNull (sourceImage );
414
+ }
411
415
412
416
private Builder (CreateDiskConfiguration configuration ) {
413
417
this .diskName = configuration .diskName ;
@@ -474,7 +478,7 @@ public CreateDiskConfiguration build() {
474
478
this .diskName = builder .diskName ;
475
479
this .diskType = builder .diskType ;
476
480
this .diskSizeGb = builder .diskSizeGb ;
477
- this .sourceImage = checkNotNull ( builder .sourceImage ) ;
481
+ this .sourceImage = builder .sourceImage ;
478
482
}
479
483
480
484
/**
@@ -568,7 +572,7 @@ com.google.api.services.compute.model.AttachedDisk toPb() {
568
572
* will be used to create the disk.
569
573
*/
570
574
public static Builder builder (ImageId sourceImage ) {
571
- return new Builder (). sourceImage ( sourceImage );
575
+ return new Builder (sourceImage );
572
576
}
573
577
574
578
/**
@@ -623,7 +627,7 @@ private Builder(ScratchDiskConfiguration configuration) {
623
627
}
624
628
625
629
/**
626
- * Sets the identity of the disk type.
630
+ * Sets the identity of the disk type for the scratch disk to attach .
627
631
*/
628
632
public Builder diskType (DiskTypeId diskType ) {
629
633
this .diskType = diskType ;
@@ -827,7 +831,7 @@ public Integer index() {
827
831
}
828
832
829
833
/**
830
- * Sets the attached disk configuration. Returns {@link ScratchDiskConfiguration} to attach a
834
+ * Returns the attached disk configuration. Returns {@link ScratchDiskConfiguration} to attach a
831
835
* scratch disk to the instance. Returns {@link PersistentDiskConfiguration} to attach a
832
836
* persistent disk to the instance. Returns {@link CreateDiskConfiguration} to create and attach
833
837
* a new persistent disk.
@@ -903,7 +907,7 @@ public static AttachedDisk of(AttachedDiskConfiguration configuration) {
903
907
}
904
908
905
909
/**
906
- * Returns an {@code AttachedDisk} object given its configuration and the device name.
910
+ * Returns an {@code AttachedDisk} object given the device name and its configuration .
907
911
*/
908
912
public static AttachedDisk of (String deviceName , AttachedDiskConfiguration configuration ) {
909
913
return builder (configuration ).deviceName (deviceName ).build ();
0 commit comments