# `RDF.Resource.Generator`
[🔗](https://github.com/rdf-elixir/rdf-ex/blob/v3.0.1/lib/rdf/resource_generator/resource_generator.ex#L1)

A configurable and customizable way to generate resource identifiers.

The basis are different implementations of the behaviour defined in this
module for configurable resource identifier generation methods.

Generally two kinds of identifiers are differentiated:

1. parameter-less identifiers which are generally random
2. identifiers which are based on some value, where every attempt to create
   an identifier for the same value, should produce the same identifier

Not all implementations must support both kind of identifiers.

The `RDF.Resource.Generator` module provides two `generate` functions for the
kindes of identifiers, `generate/1` for random-based and `generate/2` for
value-based identifiers.
The `config` keyword list they take must contain a `:generator` key, which
provides the module implementing the `RDF.Resource.Generator` behaviour.
All other keywords are specific to the generator implementation.
When the generator is configured differently for the different
identifier types, the identifier-type specific configuration can be put under
the keys `:random_based` and `:value_based` respectively.
The `RDF.Resource.Generator.generate` implementations will be called with the
general configuration options from the top-level merged with the identifier-type
specific configuration.

The `generate` functions however are usually not called directly.
See the [guide](https://rdf-elixir.dev/rdf-ex/resource-generators.html) on
how they are meant to be used.

The following `RDF.Resource.Generator` implementations are provided with RDF.ex:

- `RDF.BlankNode`
- `RDF.BlankNode.Generator`
- `RDF.IRI.UUID.Generator`

# `id_type`

```elixir
@type id_type() :: :random_based | :value_based
```

# `generate`

```elixir
@callback generate(config :: any()) :: RDF.Resource.t()
```

Generates a random resource identifier based on the given `config`.

# `generate`

```elixir
@callback generate(config :: any(), value :: binary()) :: RDF.Resource.t()
```

Generates a resource identifier based on the given `config` and `value`.

# `generator_config`

```elixir
@callback generator_config(
  id_type(),
  keyword()
) :: any()
```

Allows to normalize the configuration.

This callback is optional. A default implementation is generated which
returns the configuration as-is.

# `generate`

Generates a random resource identifier based on the given `config`.

See the [guide](https://rdf-elixir.dev/rdf-ex/resource-generators.html) on
how it is meant to be used.

# `generate`

Generates a resource identifier based on the given `config` and `value`.

See the [guide](https://rdf-elixir.dev/rdf-ex/resource-generators.html) on
how it is meant to be used.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
