Interface OneOf

All Superinterfaces:
Configuration

public interface OneOf extends Configuration
Marker interface for configuration values which may be one of a set of sub-configuration types.

All methods in an interface extending OneOf must contain only methods returning Optional items. Only one of the methods will return a value (the chosen value in the configuration), while all other methods will always be empty. This is sometimes called a sum type.

For example, suppose a configuration value may either have a static String value defined in configuration, or refer to the value of some attribute in a user account. In such case, one could write a OneOf interface that looks like this:

 
      interface MapAttributeToValue extends OneOf {
          Optional<String> staticValue();

          Optional<String> valueOfAttributeNamed();
         }
 
 
When reading this configuration value, either staticValue() or valueOfAttributeNamed() would return a value, but not both. Notice that the types of each option could be different.

If it should be possible to also have none of these values set, just make the getter for the OneOf interface return an Optional (example re-using the MapAttributeToValue interface):

 
      interface MyConfig extends Configuration {
          Optional<MapAttributeToValue> attributeToValueMapping();
         }
 
 
  • Method Summary

    Methods inherited from interface se.curity.identityserver.sdk.config.Configuration

    id