Packages

  • package root

    Documentation for the Axiell Utilities Project

    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:

    • referential transparency. The principle that defines a call to a method with the same arguments will always return the same result and that the method does not have any side effects (e.g. updating global variables, etc).
    • functional programming support. If a method or class does have side effects then the method or class is marked as effectful. The library has been designed to not contain any effectful code.
    • minimal functionality. The library is designed to be small with support for a small number of common utilities. The main reason for the small size is to limit the number of dependencies drawn in by the package.

    Package structure

    The com.axiell.util package consists of a number of utilities, where each utility provides a single piece of functionality.

    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 a C printf style.
    • Implicits implements implicit methods and classes used to pimp methods onto existing classes (e.g. fold() method to Boolean 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 the Configure class to access settings stored as resources within an application.
    Definition Classes
    root
  • package com
    Definition Classes
    root
  • package axiell
    Definition Classes
    com
  • package util

    Axiell Utilities Project

    Axiell Utilities Project

    A set of classes and traits that provide a simple mechanism for the internationalisation of strings and error handling. A mechanism is also supplied to read an application's configuration resource. All methods have been designed to be referentially transparent without the introduction of an effectful library (e.g. cats).

    Imports

    The utility classes/traits can be imported in the usual way, however it is necessary to include the Implicits object if the showLocal and jsonLocal type class methods are used, similarly for the read method on Configure.

    Example:

    import com.axiell.util.Implicits._

    A shorthand way to gain access to all utility classes is to import:

    import com.axiell.util._
    import com.axiell.util.Implicits._

    For more detail on project see the root package page.

    Definition Classes
    axiell
  • package instances

    Contains implicit values used by type classes.

    Contains implicit values used by type classes.

    The implicit values are used by the ShowLocal, JsonLocal and ConfigureReader type classes to print out language dependent strings, language dependent JSON strings and read configuration values respectively.

    Implicit values exist for the following classes:

    • ConfigureReader (read)
    • Error (showLocal, jsonLocal)
    • Int (showLocal, jsonLocal)
    • List (showLocal, jsonLocal)
    • Message (showLocal, jsonLocal)
    • java.time.OffsetDateTime (showLocal, jsonLocal)
    • java.lang.String (showLocal, jsonLocal)
    • java.lang.Throwable (showLocal, jsonLocal)

    The method names appended in brackets are the extension methods added by the implicit values.

    Definition Classes
    util
  • package syntax

    Contains implicit classes used to add extension methods.

    Contains implicit classes used to add extension methods.

    The implicit classes are used to add the following extension methods:

    • showLocal displays a language dependent version of an object
    • jsonLocal generates a JSON string with language dependent strings
    • masonLocal generates a Mason Draft 2 compliant JSON string for Error
    • fold functionality for Boolean type

    All traits found in the package are for the implementation of extension methods. The traits are mixed into the Implicits object so they can be easily imported into clients when required.

    Definition Classes
    util
  • Configure
  • ConfigureReader
  • Error
  • ErrorException
  • Formatter
  • Implicits
  • JsonLocal
  • Message
  • MessageBundle
  • ShowLocal
o

com.axiell.util

Implicits

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
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Implicits
  2. ShowLocalSyntax
  3. MasonLocalSyntax
  4. JsonLocalSyntax
  5. ErrorSyntax
  6. BooleanSyntax
  7. ThrowableInstances
  8. StringInstances
  9. OffsetDateTimeInstances
  10. MessageInstances
  11. ListInstances
  12. IntInstances
  13. ErrorExceptionInstances
  14. ErrorInstances
  15. ConfigureReaderInstances
  16. AnyRef
  17. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. 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
  2. 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
  3. implicit final class JsonLocalOps[A] extends AnyRef

    Adds jsonLocal method to any object of type A where JsonLocal[A] is implicitly defined.

    Adds jsonLocal method to any object of type A where JsonLocal[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
  4. 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
  5. implicit final class ShowLocalOps[A] extends AnyRef

    Adds showLocal method to any object of type A where ShowLocal[A] is implicitly defined.

    Adds showLocal method to any object of type A where ShowLocal[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

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  9. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  10. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  11. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  13. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  14. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  15. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  16. def toString(): String
    Definition Classes
    AnyRef → Any
  17. implicit val utilBooleanForConfigureReader: ConfigureReader[Boolean]

    Reads configuration Boolean values

    Reads configuration Boolean values

    Implements 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
  18. implicit val utilIntForConfigureReader: ConfigureReader[Int]

    Reads configuration Int values

    Reads configuration Int values

    Implements 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
  19. implicit val utilJsonLocalForError: JsonLocal[Error]

    Implements JsonLocal[Error] allowing the jsonLocal extension method for Error

    Implements JsonLocal[Error] allowing the jsonLocal extension method for Error

    The 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
  20. implicit val utilJsonLocalForErrorException: JsonLocal[ErrorException]

    Implements JsonLocal[ErrorException] allowing the jsonLocal extension method for ErrorException

    Implements JsonLocal[ErrorException] allowing the jsonLocal extension method for ErrorException

    The 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
  21. implicit val utilJsonLocalForInt: JsonLocal[Int]

    Implements JsonLocal[Int] allowing the jsonLocal method extension for Int

    Implements JsonLocal[Int] allowing the jsonLocal method extension for Int

    The JSON format of an integer value is simply the value itself.

    Definition Classes
    IntInstances
  22. implicit def utilJsonLocalForList[A](implicit arg0: JsonLocal[A]): JsonLocal[List[A]]

    Implements JsonLocal[List[_]] allowing the jsonLocal method extension for List

    Implements JsonLocal[List[_]] allowing the jsonLocal method extension for List

    The 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
  23. implicit val utilJsonLocalForMessage: JsonLocal[Message]

    Implements JsonLocal[Message] allowing the jsonLocal method extension for Message

    Implements JsonLocal[Message] allowing the jsonLocal method extension for Message

    The 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
  24. implicit val utilJsonLocalForOffsetDateTime: JsonLocal[OffsetDateTime]

    Implements JsonLocal[OffsetDateTime] allowing the jsonLocal method extension for java.time.OffsetDateTime

    Implements JsonLocal[OffsetDateTime] allowing the jsonLocal method extension for java.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
  25. implicit val utilJsonLocalForString: JsonLocal[String]

    Implements JsonLocal[String] allowing the jsonLocal method extension for java.lang.String.

    Implements JsonLocal[String] allowing the jsonLocal method extension for java.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
  26. implicit def utilJsonLocalForThrowable[A <: Throwable]: JsonLocal[A]

    Implements JsonLocal[Throwable] allowing the jsonLocal method extension for java.lang.Throwable and subclasses.

    Implements JsonLocal[Throwable] allowing the jsonLocal method extension for java.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
  27. implicit val utilListBooleanForConfigureReader: ConfigureReader[List[Boolean]]

    Reads a list of configuration Boolean values

    Reads a list of configuration Boolean values

    Implements 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
  28. implicit val utilListIntForConfigureReader: ConfigureReader[List[Int]]

    Reads a list of configuration Int values

    Reads a list of configuration Int values

    Implements 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
  29. implicit val utilListNumberForConfigureReader: ConfigureReader[List[Number]]

    Reads a list of configuration Number values

    Reads a list of configuration Number values

    Implements 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
  30. implicit val utilListStringForConfigureReader: ConfigureReader[List[String]]

    Reads a list of configuration String values

    Reads a list of configuration String values

    Implements 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
  31. implicit val utilNumberForConfigureReader: ConfigureReader[Number]

    Reads configuration Number values

    Reads configuration Number values

    Implements 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
  32. implicit val utilShowLocalForError: ShowLocal[Error]

    Implements ShowLocal[Error] allowing the showLocal extension method for Error

    Implements ShowLocal[Error] allowing the showLocal extension method for Error

    When showing an Error the error code 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
  33. implicit val utilShowLocalForErrorException: ShowLocal[ErrorException]

    Implements ShowLocal[ErrorException] allowing the showLocal extension method for ErrorException

    Implements ShowLocal[ErrorException] allowing the showLocal extension method for ErrorException

    When showing an ErrorException the stack trace is added to the Error 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
  34. implicit val utilShowLocalForInt: ShowLocal[Int]

    Implements ShowLocal[Int] allowing the showLocal method extension for Int

    Implements ShowLocal[Int] allowing the showLocal method extension for Int

    The string format of an integer value is simply the value itself.

    Definition Classes
    IntInstances
  35. implicit def utilShowLocalForList[A](implicit arg0: ShowLocal[A]): ShowLocal[List[A]]

    Implements ShowLocal[List[_]] allowing the showLocal method extension for List

    Implements ShowLocal[List[_]] allowing the showLocal method extension for List

    The 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
  36. implicit val utilShowLocalForMessage: ShowLocal[Message]

    Implements ShowLocal[Message] allowing the showLocal method extension for Message

    Implements ShowLocal[Message] allowing the showLocal method extension for Message

    When 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
  37. implicit val utilShowLocalForOffsetDateTime: ShowLocal[OffsetDateTime]

    Implements ShowLocal[OffsetDateTime] allowing the showLocal method extension for java.time.OffsetDateTime

    Implements ShowLocal[OffsetDateTime] allowing the showLocal method extension for java.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
  38. implicit val utilShowLocalForString: ShowLocal[String]

    Implements ShowLocal[String] allowing the showLocal method extension for java.lang.String.

    Implements ShowLocal[String] allowing the showLocal method extension for java.lang.String.

    The format of the string generated is the text itself.

    Definition Classes
    StringInstances
  39. implicit def utilShowLocalForThrowable[A <: Throwable]: ShowLocal[A]

    Implements ShowLocal[Throwable] enabling the showLocal extension method for java.lang.Throwable

    Implements ShowLocal[Throwable] enabling the showLocal extension method for java.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
  40. implicit val utilStringForConfigureReader: ConfigureReader[String]

    Reads configuration String values

    Reads configuration String values

    Implements 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
  41. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  42. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  43. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from ShowLocalSyntax

Inherited from MasonLocalSyntax

Inherited from JsonLocalSyntax

Inherited from ErrorSyntax

Inherited from BooleanSyntax

Inherited from ThrowableInstances

Inherited from StringInstances

Inherited from MessageInstances

Inherited from ListInstances

Inherited from IntInstances

Inherited from ErrorInstances

Inherited from AnyRef

Inherited from Any

Ungrouped