Skip to content

Philippus/pureconfig-javanet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pureconfig-javanet

build codecov Current Version license

pureconfig-javanet is a PureConfig module that supplies readers and writers that turn a host:port pair into a InetSocketAddress and turn a list of host:port pairs, separated by a comma, into a Seq[InetSocketAddress]. It supports IPv4 and IPv6 addresses and host names in the following shapes:

127.0.0.1:80
2001:db8::1:80
[2001:db8::1]:80
127.0.0.1:80, localhost:80

To stay pure the InetSocketAddress is constructed using the createUnresolved-method, and thus will be flagged as unresolved, see https://docs.oracle.com/javase/8/docs/api/java/net/InetSocketAddress.html#createUnresolved-java.lang.String-int-.

Installation

pureconfig-javanet is published for Scala 2.13 and Scala 3. To start using it add the following to your build.sbt:

libraryDependencies += "nl.gn0s1s" %% "pureconfig-javanet" % "0.1.0"

PureConfig itself also needs to be added as a dependency to your project.

Example usage

  import java.net.InetSocketAddress

  import com.typesafe.config.ConfigFactory.parseString
  import nl.gn0s1s.pureconfig.module.javanet.*
  import pureconfig.generic.auto.*
  import pureconfig.syntax.*

  case class Config(host: InetSocketAddress)

  val conf = parseString(""""host": "127.0.0.1:65535"""") // val conf: com.typesafe.config.Config = Config(SimpleConfigObject({"host":"127.0.0.1:65535"}))

  conf.to[Config] // val res0: pureconfig.ConfigReader.Result[Config] = Right(Config(127.0.0.1:65535))

License

The code is available under the Mozilla Public License, version 2.0.

About

⚙️ PureConfig module for java.net.InetSocketAddress

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages