object Implicits extends ConfigureReaderInstances with ErrorInstances with ErrorExceptionInstances with IntInstances with ListInstances with MessageInstances with OffsetDateTimeInstances with StringInstances with ThrowableInstances with BooleanSyntax with ErrorSyntax with JsonLocalSyntax with MasonLocalSyntax with ShowLocalSyntax
Groups all implicits into a single object
Method extension implicits (Syntax suffix) and implicit variables (Instances Suffix) are mixed into a single object allowing a single import statement to be used to bring them all into scope.
The required import statement is:
import com.axiell.util.Implicits._
- Source
- Implicits.scala
- Alphabetic
- By Inheritance
- Implicits
- ShowLocalSyntax
- MasonLocalSyntax
- JsonLocalSyntax
- ErrorSyntax
- BooleanSyntax
- ThrowableInstances
- StringInstances
- OffsetDateTimeInstances
- MessageInstances
- ListInstances
- IntInstances
- ErrorExceptionInstances
- ErrorInstances
- ConfigureReaderInstances
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- implicit final class BooleanOps extends AnyRef
Adds extension methods to scala.Boolean via implicit class
Adds extension methods to scala.Boolean via implicit class
- Definition Classes
- BooleanSyntax
- implicit final class ErrorOps extends AnyRef
Adds extension methods to Error via implicit class
Adds extension methods to Error via implicit class
- Definition Classes
- ErrorSyntax
- implicit final class JsonLocalOps[A] extends AnyRef
Adds
jsonLocal
method to any object of typeA
whereJsonLocal[A]
is implicitly defined.Adds
jsonLocal
method to any object of typeA
whereJsonLocal[A]
is implicitly defined.Example:
import com.axiell.util.Implicits._ import java.util.Locale implicit locale = Locale.GERMAN Message(MessageBundle("Messages"), "MessageCode").jsonLocal
outputs the German version of the "MessageCode" label in the "Messages" strings bundle in JSON format.
- A
type to add
jsonLocal
extension method to
- Definition Classes
- JsonLocalSyntax
- implicit final class MasonLocalOps extends AnyRef
Adds extension methods to Error via implicit class
Adds extension methods to Error via implicit class
- Definition Classes
- MasonLocalSyntax
- implicit final class ShowLocalOps[A] extends AnyRef
Adds
showLocal
method to any object of typeA
whereShowLocal[A]
is implicitly defined.Adds
showLocal
method to any object of typeA
whereShowLocal[A]
is implicitly defined.Example:
import com.axiell.util.Implicits._ import java.util.Locale implicit locale = Locale.GERMAN Message(MessageBundle("Messages"), "MessageCode").showLocal
outputs the German version of the "MessageCode" label in the "Messages" strings bundle.
- A
type to add
showLocal
extension method to
- Definition Classes
- ShowLocalSyntax
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- implicit val utilBooleanForConfigureReader: ConfigureReader[Boolean]
Reads configuration
Boolean
valuesReads configuration
Boolean
valuesImplements an instance of
ConfigureReader[Boolean]
to read a configuration key value and return it as a boolean. If the key cannot be found or the value cannot be converted to a boolean then an Error is returned.- Definition Classes
- ConfigureReaderInstances
- implicit val utilIntForConfigureReader: ConfigureReader[Int]
Reads configuration
Int
valuesReads configuration
Int
valuesImplements an instance of
ConfigureReader[Int]
to read a configuration key value and return it as an integer. If the key cannot be found or the value cannot be converted to an integer then an Error is returned.- Definition Classes
- ConfigureReaderInstances
- implicit val utilJsonLocalForError: JsonLocal[Error]
Implements
JsonLocal[Error]
allowing thejsonLocal
extension method for ErrorImplements
JsonLocal[Error]
allowing thejsonLocal
extension method for ErrorThe format of the JSON string generated is a JSON object where the property key is the context label and the property value the context data stored in the error's map.
- Definition Classes
- ErrorInstances
- implicit val utilJsonLocalForErrorException: JsonLocal[ErrorException]
Implements
JsonLocal[ErrorException]
allowing thejsonLocal
extension method for ErrorExceptionImplements
JsonLocal[ErrorException]
allowing thejsonLocal
extension method for ErrorExceptionThe format of the JSON string generated is a JSON object where the property key is the context label and the property value the context data stored in the error's map.
- Definition Classes
- ErrorExceptionInstances
- implicit val utilJsonLocalForInt: JsonLocal[Int]
Implements
JsonLocal[Int]
allowing thejsonLocal
method extension for IntImplements
JsonLocal[Int]
allowing thejsonLocal
method extension for IntThe JSON format of an integer value is simply the value itself.
- Definition Classes
- IntInstances
- implicit def utilJsonLocalForList[A](implicit arg0: JsonLocal[A]): JsonLocal[List[A]]
Implements
JsonLocal[List[_]]
allowing thejsonLocal
method extension for ListImplements
JsonLocal[List[_]]
allowing thejsonLocal
method extension for ListThe format of the JSON string generated is a JSON array where each element in the array is value in the list. The JSON for each value is generated using the value's
jsonLocal
extension method.- A
type of values in the list
- returns
JSON formatter for list
- Definition Classes
- ListInstances
- implicit val utilJsonLocalForMessage: JsonLocal[Message]
Implements
JsonLocal[Message]
allowing thejsonLocal
method extension for MessageImplements
JsonLocal[Message]
allowing thejsonLocal
method extension for MessageThe format of the JSON output is based on Mason properties. Since a message consists of a code and its associated arguments, the JSON contains the language dependent message string and the code used to extract the string.
- Definition Classes
- MessageInstances
- implicit val utilJsonLocalForOffsetDateTime: JsonLocal[OffsetDateTime]
Implements
JsonLocal[OffsetDateTime]
allowing thejsonLocal
method extension forjava.time.OffsetDateTime
Implements
JsonLocal[OffsetDateTime]
allowing thejsonLocal
method extension forjava.time.OffsetDateTime
The format of the JSON string generated is the string representation of the date and time including the timezone offset. An example output is
2007-12-03T10:15:30+01:00
. Since the value is a JSON string it is wrapped in double quotes and escaped.- Definition Classes
- OffsetDateTimeInstances
- implicit val utilJsonLocalForString: JsonLocal[String]
Implements
JsonLocal[String]
allowing thejsonLocal
method extension forjava.lang.String
.Implements
JsonLocal[String]
allowing thejsonLocal
method extension forjava.lang.String
.The format of the JSON string generated is the string itself with JSON special characters escaped and enclosed in double quotes.
- Definition Classes
- StringInstances
- implicit def utilJsonLocalForThrowable[A <: Throwable]: JsonLocal[A]
Implements
JsonLocal[Throwable]
allowing thejsonLocal
method extension forjava.lang.Throwable
and subclasses.Implements
JsonLocal[Throwable]
allowing thejsonLocal
method extension forjava.lang.Throwable
and subclasses.The stack trace of the exception is returned as a JSON string. The message at the top of the stack trace will be displayed in the locale of the system.
- A
subclass of
Throwable
to be handled- returns
JsonLocal suitable for generating JSON from a
Throwable
- Definition Classes
- ThrowableInstances
- implicit val utilListBooleanForConfigureReader: ConfigureReader[List[Boolean]]
Reads a list of configuration
Boolean
valuesReads a list of configuration
Boolean
valuesImplements an instance of
ConfigureReader[List[Boolean]]
to read a configuration key value and return a list of booleans. If the key cannot be found or the value cannot be converted to a list of booleans then an Error is returned.- Definition Classes
- ConfigureReaderInstances
- implicit val utilListIntForConfigureReader: ConfigureReader[List[Int]]
Reads a list of configuration
Int
valuesReads a list of configuration
Int
valuesImplements an instance of
ConfigureReader[List[Int]]
to read a configuration key value and return a list of integers. If the key cannot be found or the value cannot be converted to a list of integers then an Error is returned.- Definition Classes
- ConfigureReaderInstances
- implicit val utilListNumberForConfigureReader: ConfigureReader[List[Number]]
Reads a list of configuration
Number
valuesReads a list of configuration
Number
valuesImplements an instance of
ConfigureReader[List[Number]]
to read a configuration key value and return a list of numbers. If the key cannot be found or the value cannot be converted to a list of numbers then an Error is returned.- Definition Classes
- ConfigureReaderInstances
- implicit val utilListStringForConfigureReader: ConfigureReader[List[String]]
Reads a list of configuration
String
valuesReads a list of configuration
String
valuesImplements an instance of
ConfigureReader[List[String]]
to read a configuration key value and return a list of string. If the key cannot be found or the value cannot be converted to a list of strings then an Error is returned.- Definition Classes
- ConfigureReaderInstances
- implicit val utilNumberForConfigureReader: ConfigureReader[Number]
Reads configuration
Number
valuesReads configuration
Number
valuesImplements an instance of
ConfigureReader[Number]
to read a configuration key value and return it as a number. If the key cannot be found or the value cannot be converted to a number then an Error is returned.- Definition Classes
- ConfigureReaderInstances
- implicit val utilShowLocalForError: ShowLocal[Error]
Implements
ShowLocal[Error]
allowing theshowLocal
extension method for ErrorImplements
ShowLocal[Error]
allowing theshowLocal
extension method for ErrorWhen showing an
Error
the errorcode
is displayed in square brackets first, followed by a language specific (as defined by the supplied locale) error string. All other context information is displayed on one line per entry indented two spaces with continuation lines indented four spaces.- Definition Classes
- ErrorInstances
- implicit val utilShowLocalForErrorException: ShowLocal[ErrorException]
Implements
ShowLocal[ErrorException]
allowing theshowLocal
extension method for ErrorExceptionImplements
ShowLocal[ErrorException]
allowing theshowLocal
extension method for ErrorExceptionWhen showing an
ErrorException
the stack trace is added to theError
properties and output as part of the string. The string consists of each property separated by a comma with the property name and value shown, separated by->
.- Definition Classes
- ErrorExceptionInstances
- implicit val utilShowLocalForInt: ShowLocal[Int]
Implements
ShowLocal[Int]
allowing theshowLocal
method extension for IntImplements
ShowLocal[Int]
allowing theshowLocal
method extension for IntThe string format of an integer value is simply the value itself.
- Definition Classes
- IntInstances
- implicit def utilShowLocalForList[A](implicit arg0: ShowLocal[A]): ShowLocal[List[A]]
Implements
ShowLocal[List[_]]
allowing theshowLocal
method extension for ListImplements
ShowLocal[List[_]]
allowing theshowLocal
method extension for ListThe format of the string generated is a comma separated set of values wrapped in round brackets. Each value's
showLocal
extension method is used to generate the value's string version.- A
type of values in the list
- returns
string formatter for list
- Definition Classes
- ListInstances
- implicit val utilShowLocalForMessage: ShowLocal[Message]
Implements
ShowLocal[Message]
allowing theshowLocal
method extension for MessageImplements
ShowLocal[Message]
allowing theshowLocal
method extension for MessageWhen showing a
Message
the com.axiell.util.Formatter class is used to extract the language specific string, as determined by the implicit locale and message code, from the given strings bundle. The string has the message arguments interpolated.- Definition Classes
- MessageInstances
- implicit val utilShowLocalForOffsetDateTime: ShowLocal[OffsetDateTime]
Implements
ShowLocal[OffsetDateTime]
allowing theshowLocal
method extension forjava.time.OffsetDateTime
Implements
ShowLocal[OffsetDateTime]
allowing theshowLocal
method extension forjava.time.OffsetDateTime
The format of the string generated is the textual representation of the date and time including the timezone offset. An example output is
2007-12-03T10:15:30+01:00
.- Definition Classes
- OffsetDateTimeInstances
- implicit val utilShowLocalForString: ShowLocal[String]
Implements
ShowLocal[String]
allowing theshowLocal
method extension forjava.lang.String
.Implements
ShowLocal[String]
allowing theshowLocal
method extension forjava.lang.String
.The format of the string generated is the text itself.
- Definition Classes
- StringInstances
- implicit def utilShowLocalForThrowable[A <: Throwable]: ShowLocal[A]
Implements
ShowLocal[Throwable]
enabling theshowLocal
extension method forjava.lang.Throwable
Implements
ShowLocal[Throwable]
enabling theshowLocal
extension method forjava.lang.Throwable
The
ShowLocal[Throwable]
implementation simply returns a string containing a text version of the stack trace. Since the stack trace is language independent there is no need to apply the locale.- A
subclass of
Throwable
to be handled- returns
ShowLocal suitable for generating a string from a
Throwable
- Definition Classes
- ThrowableInstances
- implicit val utilStringForConfigureReader: ConfigureReader[String]
Reads configuration
String
valuesReads configuration
String
valuesImplements an instance of
ConfigureReader[String]
to read a configuration key value and return it as a string. If the key cannot be found or the value cannot be converted to a string then an Error is returned.- Definition Classes
- ConfigureReaderInstances
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
Documentation for the Axiell Utilities Project
Overview
The Axiell Utilities Project attempts to provide a small library of classes and object applicable to most Axiell developments. The library is not geared towards any one project and so should be useful for new projects as well as existing ones.
The library is based on a few simple principles, namely:
Package structure
The
package consists of a number of utilities, where each utility provides a single piece of functionality.com.axiell.util
Notable utilities are:
Configure
generic configuration reader allowing application settings defined as resources to be interrogated.Error
generic error handling class defining a locale independent error message along with details relating to the context of the error. The context may include an exception and other relevant values.Formatter
retrieves and formats a locale specific string from a specified resource bundle. The formatting is specified in aC
printf style.Implicits
implements implicit methods and classes used to pimp methods onto existing classes (e.g.fold()
method toBoolean
class) and to provide implicit implementations for the JsonLocal and ShowLocal type classes.JsonLocal
type class used to output locale specific JSON structures. Implementations exist for Message and Error.Message
provides a locale independent mechanism for handling strings. The strings for a given locale are stored in resource bundles that are accessed when the message is to be displayed.ShowLocal
type class used to show locale specific strings. Allows Message and Error to be converted to a given language string.Dependencies
The list of dependencies are:
Typesafe Config
a generic configuration file reader. The library is used by theConfigure
class to access settings stored as resources within an application.