Class CosIdSpecs

java.lang.Object
me.ahoo.cosid.spring.autoconfigure.CosIdSpecs

public final class CosIdSpecs extends Object
CosIdProperties to RuntimeSpec (07-runtime-and-spring.md ยง4.1): toSpec(me.ahoo.cosid.spring.autoconfigure.CosIdProperties, java.time.ZoneId) is a pure function, no Spring involved; bind(java.lang.Iterable<org.springframework.boot.context.properties.source.ConfigurationPropertySource>, org.springframework.boot.context.properties.bind.PlaceholdersResolver) binds cosid.* strictly. It checks what the properties alone can tell (a missing strategy, a codec item naming two codecs, ...) and reports every problem at once by property path; CosIdRuntime.start validates the spec as a whole.
  • Field Details

  • Method Details

    • bind

      public static CosIdProperties bind(Iterable<org.springframework.boot.context.properties.source.ConfigurationPropertySource> sources, org.springframework.boot.context.properties.bind.PlaceholdersResolver placeholders)
      Binds cosid.*; a key that binds to nothing fails (R1-spring-03): a typo would otherwise fall back to the default silently. cosid.stores.*.options, the keys of the integrations and the server, and system properties and environment variables are not checked here.
      Parameters:
      sources - the property sources, such as ConfigurationPropertySources.get(environment)
      placeholders - resolves ${...} in the values
      Returns:
      the properties
      Throws:
      org.springframework.boot.context.properties.bind.BindException - with the unbound keys
    • namespace

      public static Optional<String> namespace(String configured, String applicationName)
      The namespace of the runtime (D38): cosid.namespace, else spring.application.name, else "cosid".
      Parameters:
      configured - cosid.namespace, or null
      applicationName - spring.application.name, or null
      Returns:
      the namespace; empty when both are unset, for "cosid"
      Throws:
      me.ahoo.cosid.CosIdException - if the application name is no valid namespace
    • toSpec

      public static me.ahoo.cosid.runtime.RuntimeSpec toSpec(CosIdProperties properties, ZoneId zone)
      Maps the properties to a spec, in cosid.namespace or "cosid".
      Parameters:
      properties - the bound properties
      zone - the zone of the zone-dependent settings left empty (the system zone in an application)
      Returns:
      the spec
      Throws:
      me.ahoo.cosid.CosIdException - listing every problem by property path
    • toSpec

      public static me.ahoo.cosid.runtime.RuntimeSpec toSpec(CosIdProperties properties, String namespace, ZoneId zone)
      Maps the properties to a spec.
      Parameters:
      properties - the bound properties
      namespace - the namespace of the runtime, resolved by namespace(String, String)
      zone - the zone of the zone-dependent settings left empty (the system zone in an application)
      Returns:
      the spec
      Throws:
      me.ahoo.cosid.CosIdException - listing every problem by property path