# Apache Tamaya — Extension: Optional Tamaya Configuration

## Tamaya Optional Configuration (Extension Module)

### Overview

The Tamaya optional module provides contains three types only. It is for projects that want to benefit from Tamaya configuration optionally only. E.g. doing an OSS project you can declare to support configuration with Tamaya as an optional extension. This module can be added as a hard dependency to your code, hereby adding only three artofacts. It automatically checks the availability of Tamaya on the classpath and only if available tries to access it for configuration evaluation. Additionally an EvaluationPolicy lets you define the precedence of configured values (yours, or Tamaya ones if present).

### Compatibility

The module is based on Java 7, so it will not run on Java 7 and beyond.

### Installation

To benefit from configuration builder support you only must add the corresponding dependency to your module:

    <dependency>
      <groupId>org.apache.tamaya.ext</groupId>
      <artifactId>tamaya-optional</artifactId>
      <version>{tamayaVersion}</version>
    </dependency>

### Reading configuration using the Tamaya Optional Module

The optional module allows reading configuration with a small subset of functionality only. For extended of full featured config please consider using the Apache Tamaya as a full configuration backend.

    BigDecimal interestRate =
                     OptionalConfiguration.of(
                        EvaluationPolicy.TAMAYA_OVERRIDES_OTHER,
                        (k) -> MyConfigMechanism.get(k) // String get(String key);
                     )
                    .get("com.mycomp.ratecalculator.rate", BigDecimal.class))
                    .orElse(BigDecimal.of(0.05d));