Interface LayeredPropertyMap

  • All Implemented Interfaces:

    
    public interface LayeredPropertyMap
    
                        

    Interface for supporting Map<String, String> structure. It has the required functions for converting and parsing the string values to objects.

    The layered property map provides simple conversions to possibly complex objects which can use several keys in dot-notation. Take an example of the map:

    • "corda.name" to "CN=me, O=R3, L=Dublin, C=IE"
    • "corda.sessionKey" to "-----BEGIN PUBLIC KEY-----Base64–encoded public key-----END PUBLIC KEY-----"
    • "corda.endpoints.0.url" to "localhost"
    • "corda.endpoints.0.protocolVersion" to "1"
    • "corda.endpoints.1.url" to "localhost"
    • "corda.endpoints.1.protocolVersion" to "2"
    That map can be parsed into:
    • MemberX500Name using parse("corda.name", MemberX500Name.class)
    • Session PublicKey using parse("corda.sessionKey", PublicKey.class)
    • List of endpoints using parseList("corda.endpoints", EndpointInfo.class)
    Example usages:
    • Java:
      
      Set<Map.Entry<String, String>> entries = propertyMap.getEntries();
      String groupId = propertyMap.parse("corda.groupId", String.class);
      Instant modifiedTime = propertyMap.parseOrNull("corda.modifiedTime", Instant.class);
      Set<String> additionalInformation = propertyMap.parseSet("additional.names", String.class);
      List<EndpointInfo> endpoints = propertyMap.parseList("corda.endpoints", EndpointInfo.class);
      
    • Kotlin:
      
      val entries = propertyMap.entries
      val groupId = propertyMap.parse("corda.groupId", String::class.java)
      val modifiedTime = propertyMap.parseOrNull("corda.modifiedTime", Instant::class.java)
      val additionalInformation = propertyMap.parseSet("additional.names", String::class.java)
      val endpoints = propertyMap.parseList("corda.endpoints", EndpointInfo::class.java)
      
    The default implementation of the LayeredPropertyMap is extendable by supplying implementations of custom converters using OSGi. Out of box it supports conversion to simple types like int, boolean, as well as MemberX500Name.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      abstract Set<Map.Entry<String, String>> getEntries()
      abstract String get(@NotNull() String key) Finds the value of the given key in the entries.
      abstract <T> T parse(@NotNull() String key, @NotNull() Class<out T> clazz) Converts the value of the given key to the specified type.
      abstract <T> T parseOrNull(@NotNull() String key, @NotNull() Class<out T> clazz) Converts the value of the given key to the specified type or returns null if the key is not found or the value itself is null.
      abstract <T> List<T> parseList(@NotNull() String itemKeyPrefix, @NotNull() Class<out T> clazz) Converts several items with the given prefix to the list.
      abstract <T> Set<T> parseSet(@NotNull() String itemKeyPrefix, @NotNull() Class<out T> clazz) Converts several items with the given prefix to Set.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • get

        @Nullable() abstract String get(@NotNull() String key)

        Finds the value of the given key in the entries.

        Parameters:
        key - Key for the entry we are looking for.
      • parse

        @NotNull() abstract <T> T parse(@NotNull() String key, @NotNull() Class<out T> clazz)

        Converts the value of the given key to the specified type.

        Parameters:
        key - Key for the entry we are looking for.
        clazz - The type of the value we want to convert to.
      • parseOrNull

        @Nullable() abstract <T> T parseOrNull(@NotNull() String key, @NotNull() Class<out T> clazz)

        Converts the value of the given key to the specified type or returns null if the key is not found or the value itself is null.

        Parameters:
        key - Key for the entry we are looking for.
        clazz - The type of the value we want to convert to.
      • parseList

        @NotNull() abstract <T> List<T> parseList(@NotNull() String itemKeyPrefix, @NotNull() Class<out T> clazz)

        Converts several items with the given prefix to the list.

        Here is an example of what a list will look like (the itemKeyPrefix have to be "corda.endpoints" or "corda.endpoints."):

        
         corda.endpoints.1.url = localhost
         corda.endpoints.1.protocolVersion = 1
         corda.endpoints.2.url = localhost
         corda.endpoints.2.protocolVersion = 1
         corda.endpoints.3.url = localhost
         corda.endpoints.3.protocolVersion = 1
        
        Parameters:
        itemKeyPrefix - Prefix of the key for the entry we are looking for.
        clazz - The type of elements in the list.
      • parseSet

        @NotNull() abstract <T> Set<T> parseSet(@NotNull() String itemKeyPrefix, @NotNull() Class<out T> clazz)

        Converts several items with the given prefix to Set.

        Here is an example of what a set will look like (the itemKeyPrefix has to be "corda.ledgerKeyHashes" or "corda.ledgerKeyHashes."):

        
         corda.ledgerKeyHashes.1 = <hash value of ledger key 1>
         corda.ledgerKeyHashes.2 = <hash value of ledger key 2>
         corda.ledgerKeyHashes.3 = <hash value of ledger key 3>
        
        Parameters:
        itemKeyPrefix - Prefix of the key for the entry we are looking for.
        clazz - The type of the elements in the set.