# `RDF.Star.Statement`
[🔗](https://github.com/rdf-elixir/rdf-ex/blob/v3.0.1/lib/rdf/star/statement.ex#L1)

Helper functions for RDF-star statements.

An RDF-star statement is either a `RDF.Star.Triple` or a `RDF.Star.Quad`.

# `coercible`

```elixir
@type coercible() :: RDF.Star.Triple.coercible() | RDF.Star.Quad.coercible()
```

# `coercible_graph_name`

```elixir
@type coercible_graph_name() :: RDF.Statement.coercible_graph_name()
```

# `coercible_object`

```elixir
@type coercible_object() :: RDF.Statement.coercible_object() | RDF.Star.Triple.t()
```

# `coercible_predicate`

```elixir
@type coercible_predicate() :: RDF.Statement.coercible_predicate()
```

# `coercible_subject`

```elixir
@type coercible_subject() :: RDF.Statement.coercible_subject() | RDF.Star.Triple.t()
```

# `graph_name`

```elixir
@type graph_name() :: RDF.Statement.graph_name()
```

# `object`

```elixir
@type object() :: RDF.Statement.object() | RDF.Star.Triple.t()
```

# `predicate`

```elixir
@type predicate() :: RDF.Statement.predicate()
```

# `subject`

```elixir
@type subject() :: RDF.Statement.subject() | RDF.Star.Triple.t()
```

# `t`

```elixir
@type t() :: RDF.Star.Triple.t() | RDF.Star.Quad.t()
```

# `term_mapping`

```elixir
@type term_mapping() :: RDF.Statement.term_mapping()
```

# `coerce`

```elixir
@spec coerce(coercible(), RDF.PropertyMap.t() | nil) ::
  RDF.Star.Triple.t() | RDF.Star.Quad.t()
```

Creates a `RDF.Star.Statement` tuple with proper RDF values.

An error is raised when the given elements are not coercible to RDF-star values.

## Examples

    iex> RDF.Star.Statement.coerce {"http://example.com/S", "http://example.com/p", 42}
    {~I<http://example.com/S>, ~I<http://example.com/p>, RDF.literal(42)}
    iex> RDF.Star.Statement.coerce {"http://example.com/S", "http://example.com/p", 42, "http://example.com/Graph"}
    {~I<http://example.com/S>, ~I<http://example.com/p>, RDF.literal(42), ~I<http://example.com/Graph>}

# `coerce_graph_name`

# `coerce_object`

```elixir
@spec coerce_object(coercible_object(), RDF.PropertyMap.t() | nil) :: object()
```

Coerces the given `value` to a valid object of an RDF-star statement.

# `coerce_predicate`

# `coerce_predicate`

# `coerce_subject`

```elixir
@spec coerce_subject(coercible_subject(), RDF.PropertyMap.t() | nil) :: subject()
```

Coerces the given `value` to a valid subject of an RDF-star statement.

Raises an `RDF.Triple.InvalidSubjectError` when the value can not be coerced.

# `new`

Creates a `RDF.Star.Triple` or `RDF.Star.Quad` with proper RDF values.

An error is raised when the given elements are not coercible to RDF-star values.

Note: The `RDF.statement` function is a shortcut to this function.

## Examples

    iex> RDF.Star.Statement.new({EX.S, EX.p, 42})
    {RDF.iri("http://example.com/S"), RDF.iri("http://example.com/p"), RDF.literal(42)}

    iex> RDF.Star.Statement.new({EX.S, EX.p, 42, EX.Graph})
    {RDF.iri("http://example.com/S"), RDF.iri("http://example.com/p"), RDF.literal(42), RDF.iri("http://example.com/Graph")}

    iex> RDF.Star.Statement.new({EX.S, :p, 42, EX.Graph}, RDF.PropertyMap.new(p: EX.p))
    {RDF.iri("http://example.com/S"), RDF.iri("http://example.com/p"), RDF.literal(42), RDF.iri("http://example.com/Graph")}

# `new`

# `new`

# `star_statement?`

```elixir
@spec star_statement?(RDF.Star.Triple.t() | RDF.Star.Quad.t() | any()) :: boolean()
```

Checks if the given tuple is an RDF-star statement with a quoted triple on subject or object position.

Note: This function won't check if the given tuple or the quoted triple is valid.
Use `valid?/1` for this purpose.

## Examples

    iex> RDF.Star.Statement.star_statement?({EX.S, EX.P, EX.O})
    false
    iex> RDF.Star.Statement.star_statement?({EX.AS, EX.AP, {EX.S, EX.P, EX.O}})
    true
    iex> RDF.Star.Statement.star_statement?({{EX.S, EX.P, EX.O}, EX.AP, EX.AO})
    true

# `valid?`

```elixir
@spec valid?(RDF.Star.Triple.t() | RDF.Star.Quad.t() | any()) :: boolean()
```

Checks if the given tuple is a valid RDF-star statement, i.e. RDF-star triple or quad.

The elements of a valid RDF-star statement must be RDF terms. On the subject
position only IRIs, blank nodes and triples allowed, while on the predicate and graph
context position only IRIs allowed. The object position can be any RDF term or a triple.

# `valid_graph_name?`

```elixir
@spec valid_graph_name?(graph_name() | any()) :: boolean()
```

# `valid_object?`

```elixir
@spec valid_object?(object() | any()) :: boolean()
```

# `valid_predicate?`

```elixir
@spec valid_predicate?(predicate() | any()) :: boolean()
```

# `valid_subject?`

```elixir
@spec valid_subject?(subject() | any()) :: boolean()
```

---

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