Source:
<code>public WritableByteChannel create(final StorageResourceId resourceId, CreateObjectOptions options) throws IOException { logger.atFine().log("create(%s)", resourceId); Preconditions.checkArgument( resourceId.isStorageObject(), "Expected full StorageObject id, got %s", resourceId); Optional<Long> overwriteGeneration = resourceId.hasGenerationId() ? Optional.of(resourceId.getGenerationId()) <START> : getWriteGeneration(resourceId, options.overwriteExisting()); <END> ObjectWriteConditions writeConditions = new ObjectWriteConditions(overwriteGeneration, Optional.<Long>absent()); Map<String, String> rewrittenMetadata = encodeMetadata(options.getMetadata()); if (storageOptions.isGrpcEnabled()) { Optional<String> requesterPaysProject = requesterShouldPay(resourceId.getBucketName()) ? Optional.of(storageOptions.getRequesterPaysOptions().getProjectId()) : Optional.absent(); GoogleCloudStorageGrpcWriteChannel channel = new GoogleCloudStorageGrpcWriteChannel( backgroundTasksThreadPool, storageStubProvider.getAsyncStub(), resourceId, storageOptions.getWriteChannelOptions(), writeConditions, requesterPaysProject, rewrittenMetadata, options.getContentType()); channel.initialize(); return channel; } GoogleCloudStorageWriteChannel channel = new GoogleCloudStorageWriteChannel( backgroundTasksThreadPool, gcs, clientRequestHelper, resourceId.getBucketName(), resourceId.getObjectName(), options.getContentType(), options.getContentEncoding(), null, storageOptions.getWriteChannelOptions(), writeConditions, rewrittenMetadata) { @Override public Storage.Objects.Insert createRequest(InputStreamContent inputStream) throws IOException { return configureRequest(super.createRequest(inputStream), resourceId.getBucketName()); } }; channel.initialize(); return channel; }</code><technical_language>need check existence of object depend options.overwriteExisting() condition: java options.overwriteExisting() ? Optional.absent() : Optional.of(0);</technical_language>

Target:
public WritableByteChannel create(final StorageResourceId resourceId, CreateObjectOptions options) throws IOException { logger.atFine().log("create(%s)", resourceId); Preconditions.checkArgument( resourceId.isStorageObject(), "Expected full StorageObject id, got %s", resourceId); Optional<Long> writeGeneration = resourceId.hasGenerationId() ? Optional.of(resourceId.getGenerationId()) : getWriteGeneration(resourceId, options.overwriteExisting()); ObjectWriteConditions writeConditions = new ObjectWriteConditions( com.google.common.base.Optional.fromJavaUtil(writeGeneration), com.google.common.base.Optional.absent()); Map<String, String> rewrittenMetadata = encodeMetadata(options.getMetadata()); if (storageOptions.isGrpcEnabled()) { Optional<String> requesterPaysProject = requesterShouldPay(resourceId.getBucketName()) ? Optional.of(storageOptions.getRequesterPaysOptions().getProjectId()) : Optional.empty(); GoogleCloudStorageGrpcWriteChannel channel = new GoogleCloudStorageGrpcWriteChannel( backgroundTasksThreadPool, storageStubProvider.getAsyncStub(), resourceId, storageOptions.getWriteChannelOptions(), writeConditions, com.google.common.base.Optional.fromJavaUtil(requesterPaysProject), rewrittenMetadata, options.getContentType()); channel.initialize(); return channel; } GoogleCloudStorageWriteChannel channel = new GoogleCloudStorageWriteChannel( backgroundTasksThreadPool, gcs, clientRequestHelper, resourceId.getBucketName(), resourceId.getObjectName(), options.getContentType(), options.getContentEncoding(), null, storageOptions.getWriteChannelOptions(), writeConditions, rewrittenMetadata) { @Override public Storage.Objects.Insert createRequest(InputStreamContent inputStream) throws IOException { return configureRequest(super.createRequest(inputStream), resourceId.getBucketName()); } }; channel.initialize(); return channel; }