> For the complete documentation index, see [llms.txt](https://smuddgge.gitbook.io/squishy-library/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://smuddgge.gitbook.io/squishy-library/configuration/single-type-config-directory.md).

# Single Type Config Directory

A directory of configuration files that store a **single** **type** **of** **class**.

{% tabs %}
{% tab title="Creation" %}

```java
public class Example implements ConfigurationConvertible<Example> {
        
        public String string;

        @Override
        public @NotNull ConfigurationSection convert() {
            ConfigurationSection section = new MemoryConfigurationSection();
            section.set("string", string);
            return section;
        }

        @Override
        public @NotNull Example convert(@NotNull ConfigurationSection section) {
            this.string = section.getString("string");
            return this;
        }
}
```

{% code overflow="wrap" %}

```java
SingleTypeConfigurationDirectory<Example> directory 
        = new SingleTypeConfigurationDirectory<>(
        
    new File(""),
    identifier -> new Example(),
    false
);
```

{% endcode %}
{% endtab %}

{% tab title="Read / Write" %}

```java
directory.set("identifier", new Example());

Example example = directory.get("identifier").orElseThrow();

directory.remove("identifier");

boolean contains =  directory.contains("identifier");
```

{% endtab %}

{% tab title="Save" %}
It will save every time you write to it.

{% hint style="danger" %}
If you have multiple directory instances, there could be read/write colisions!
{% endhint %}
{% endtab %}
{% endtabs %}
