constretto-scala


License

License

Categories

Categories

Scala Languages
GroupId

GroupId

org.constretto
ArtifactId

ArtifactId

constretto-scala_2.13
Last Version

Last Version

1.3
Release Date

Release Date

Type

Type

jar
Description

Description

constretto-scala
constretto-scala
Project URL

Project URL

http://constretto.org
Project Organization

Project Organization

org.constretto
Source Code Management

Source Code Management

http://github.com/constretto/constretto-scala

Download constretto-scala_2.13

How to add to project

<!-- https://jarcasting.com/artifacts/org.constretto/constretto-scala_2.13/ -->
<dependency>
    <groupId>org.constretto</groupId>
    <artifactId>constretto-scala_2.13</artifactId>
    <version>1.3</version>
</dependency>
// https://jarcasting.com/artifacts/org.constretto/constretto-scala_2.13/
implementation 'org.constretto:constretto-scala_2.13:1.3'
// https://jarcasting.com/artifacts/org.constretto/constretto-scala_2.13/
implementation ("org.constretto:constretto-scala_2.13:1.3")
'org.constretto:constretto-scala_2.13:jar:1.3'
<dependency org="org.constretto" name="constretto-scala_2.13" rev="1.3">
  <artifact name="constretto-scala_2.13" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.constretto', module='constretto-scala_2.13', version='1.3')
)
libraryDependencies += "org.constretto" % "constretto-scala_2.13" % "1.3"
[org.constretto/constretto-scala_2.13 "1.3"]

Dependencies

compile (2)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.13.1
org.constretto : constretto-core jar 2.2.3

test (1)

Group / Artifact Type Version
org.scalatest : scalatest_2.13 jar 3.0.8

Project Modules

There are no modules declared in this project.

Constretto Scala API


Constretto Scala API is a native Scala wrapper API over the Constretto configuration management framework for Java applications.
By using this API you will be able to get a API that feels natural for Scala developers without losing any of the features of Constretto.

How to Install?

Constretto is cross compiled for Scala versions 2.12 and 2.13 and deployed to the maven central repository.

If you are using Maven, you can simply add constretto-scala as dependencies in your pom:

	<dependencies>
		...
		<dependency>
			<groupId>org.constretto</groupId>
			<artifactId>constretto-scala_${scalaVersion}</artifactId>
			<version>1.3</version>
		</dependency>
		...
	</dependencies>
	

If you are using SBT:

	val constretto = "org.constretto" %% "constretto-scala" % "1.3"

How to use?

Constretto-Scala provides a simple API to configure and retrieve values from Constretto.

	import org.constretto._
	import Constretto._
	
	val constretto = Constretto(List(properties("classpath:test.properties")),"myTag","myOtherTag")
	
	val aKeyThatMightExist:Option[String] = constretto.get[String]("myKey") 
	val aKeyThatMustExist:String = constretto[String]("myKey")  // throws exception on missing key	

Constretto-Scala defines a Converter type class for converting values to specific types.
It comes bundled with predefined instances for all ValueConverter types defined by Constretto.

	val existsInt:Option[Int] = constretto.get[Int]("someIntKey") // uses the intConverter instance to convert a string to an int
	val unknownType:Option[Bar] = constretto.get[Bar]("someBarKey") // gives compile error since no ScalaValueConverter is defined for type Bar

You can easily define your own Scala Converter instances

	object Bar {
	  implicit def barConverter = Converter.fromString[Bar] {
        _.split(":") match {
          case Array(first, second) => Bar(first, second.toInt)
        }
	  }
	}
	case class Bar(a:String, b:Int)
	
	val bar:Option[Bar] = constretto.get[Bar]("someBarKey") // compiles just fine and uses the barConverter to convert strings to Bars

How to report errors or request features?

Please use the GitHub issue tracker https://github.com/constretto/constretto-scala/issues

For further information and documentation

Constretto has several more nice features, and they are covered in the reference manual at the Constretto official website: http://constretto.org

org.constretto

Constretto

Versions

Version
1.3