Package net.shibboleth.idp.attribute.transcoding

# Class TranscodingRule

java.lang.Object
net.shibboleth.idp.attribute.transcoding.TranscodingRule

public final class TranscodingRule extends Object
Wrapper around a `Map` representing a rule for transcoding, used to detect and load the rules at runtime from a Spring context.

## Field Summary

Fields
Modifier and Type
Field
Description
`private Map<Locale,String>`
`descriptions`
Map of locale-specific descriptions.
`private Map<Locale,String>`
`displayNames`
Map of locale-specific display names.
`private final Map<String,Object>`
`rule`
Underlying map containing the rule.

## Constructor Summary

Constructors
Constructor
Description
`TranscodingRule(Map<String,Object> map)`
Constructor.
`TranscodingRule(Properties properties)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`static TranscodingRule`
`fromResource(Resource resource)`
Build a new rule from a property set resource.
`<T> T`
`get(String key, Class<T> type)`
Get the value of a property key in the rule.
`Map<Locale,String>`
`getDescriptions()`
Get the descriptions to attach to any `IdPAttribute` objects created by this transcoder.
`Map<Locale,String>`
`getDisplayNames()`
Get the display names to attach to any `IdPAttribute` objects created by this transcoder.
`Map<String,Object>`
`getMap()`
Access the underlying mapping rule.
`<T> T`
`getOrDefault(String key, Class<T> type, T defValue)`
Get the value of a property key in the rule or a default value if no property exists.
`private Map<Locale,String>`
`processDescriptions()`
Process any properties that start with `AttributeTranscoderRegistry.PROP_DESCRIPTION` and create a Locale map around them.
`private Map<Locale,String>`
`processDisplayNames()`
Process any properties that start with `AttributeTranscoderRegistry.PROP_DISPLAY_NAME` and create a Locale map around them.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### rule

@Nonnull private final Map<String,Object> rule
Underlying map containing the rule.

### displayNames

@Nonnull private Map<Locale,String> displayNames
Map of locale-specific display names.

### descriptions

@Nonnull private Map<Locale,String> descriptions
Map of locale-specific descriptions.

## Constructor Details

### TranscodingRule

public TranscodingRule(@Nonnull @ParameterName(name="map") Map<String,Object> map)
Constructor.

Parameters:
  `map` - a map containing the rule

  The rule MUST contain at least:

  - `AttributeTranscoderRegistry.PROP_ID` - internal attribute ID to map to/from
  - `AttributeTranscoderRegistry.PROP_TRANSCODER` - `AttributeTranscoder` instance supporting the type

### TranscodingRule

public TranscodingRule(@Nonnull @ParameterName(name="properties") Properties properties)
Constructor.

Parameters:
  `properties` - a property set to initialize the map

  The rule MUST contain at least:

  - `AttributeTranscoderRegistry.PROP_ID` - internal attribute ID to map to/from
  - `AttributeTranscoderRegistry.PROP_TRANSCODER` - `AttributeTranscoder` class name

## Method Details

### getMap

@Nonnull @Live public Map<String,Object> getMap()
Access the underlying mapping rule.

Returns:
  the map representing the rule

### get

@Nullable public <T> T get(@Nonnull @NotEmpty String key, @Nonnull Class<T> type)
Get the value of a property key in the rule.

Type Parameters:
  `T` - type of property value
Parameters:
  `key` - key of property
  `type` - class type of property
Returns:
  the mapped value, or null

### getOrDefault

@Nullable public <T> T getOrDefault(@Nonnull @NotEmpty String key, @Nonnull Class<T> type, @Nullable T defValue)
Get the value of a property key in the rule or a default value if no property exists.

Type Parameters:
  `T` - type of property value
Parameters:
  `key` - key of property
  `type` - class type of property
  `defValue` - default value
Returns:
  the mapped value, or the default

### getDisplayNames

@Nonnull @NotLive @Unmodifiable public Map<Locale,String> getDisplayNames()
Get the display names to attach to any `IdPAttribute` objects created by this transcoder.

Returns:
  map of locale-based names

### getDescriptions

@Nonnull @NotLive @Unmodifiable public Map<Locale,String> getDescriptions()
Get the descriptions to attach to any `IdPAttribute` objects created by this transcoder.

Returns:
  map of locale-based descriptions

### processDisplayNames

@Nonnull @NotLive @Unmodifiable private Map<Locale,String> processDisplayNames()
Process any properties that start with `AttributeTranscoderRegistry.PROP_DISPLAY_NAME` and create a Locale map around them.

Returns:
  the map of display names

### processDescriptions

@Nonnull @NotLive @Unmodifiable private Map<Locale,String> processDescriptions()
Process any properties that start with `AttributeTranscoderRegistry.PROP_DESCRIPTION` and create a Locale map around them.

Returns:
  the map of descriptions

### fromResource

@Nonnull public static TranscodingRule fromResource(@Nonnull @ParameterName(name="resource") Resource resource) throws IOException
Build a new rule from a property set resource.

Parameters:
  `resource` - a property set to initialize the map
Returns:
  the new rule
Throws:
  `IOException` - if an error occurs