Package org.springframework.aot.generate

# Class GeneratedFiles.FileHandler

java.lang.Object
org.springframework.aot.generate.GeneratedFiles.FileHandler

Enclosing interface:
  GeneratedFiles

public abstract static class GeneratedFiles.FileHandler extends Object
Provide access to a particular file and offer convenient methods to retrieve, save, or override its content.

Since:
  6.2

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`FileHandler(boolean exists, Supplier<InputStreamSource> existingContent)`

## Method Summary

Modifier and Type
Method
Description
`protected abstract void`
`copy(InputStreamSource content, boolean override)`
`void`
`create(InputStreamSource content)`
Create a file with the given content.
`boolean`
`exists()`
Specify whether the file already exists.
`InputStreamSource`
`getContent()`
Return an `InputStreamSource` for the content of the file or `null` if the file does not exist.
`void`
`override(InputStreamSource content)`
Override the content of the file handled by this instance using the given content.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### FileHandler

protected FileHandler(boolean exists, Supplier<InputStreamSource> existingContent)

## Method Details

### exists

public boolean exists()
Specify whether the file already exists.

Returns:
  `true` if the file already exists

### getContent

@Nullable public InputStreamSource getContent()
Return an `InputStreamSource` for the content of the file or `null` if the file does not exist.

### create

public void create(InputStreamSource content)
Create a file with the given content.

Throws:
  `IllegalStateException` - if the file already exists

### override

public void override(InputStreamSource content)
Override the content of the file handled by this instance using the given content. If the file does not exist, it is created.

### copy

protected abstract void copy(InputStreamSource content, boolean override)