macros


License

License

Categories

Categories

Auto Application Layer Libs Code Generators
GroupId

GroupId

io.methvin.autodelegate
ArtifactId

ArtifactId

macros_2.12
Last Version

Last Version

0.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

macros
macros
Project URL

Project URL

https://github.com/gmethvin/autodelegate
Project Organization

Project Organization

io.methvin.autodelegate
Source Code Management

Source Code Management

https://github.com/gmethvin/autodelegate

Download macros_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/io.methvin.autodelegate/macros_2.12/ -->
<dependency>
    <groupId>io.methvin.autodelegate</groupId>
    <artifactId>macros_2.12</artifactId>
    <version>0.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/io.methvin.autodelegate/macros_2.12/
implementation 'io.methvin.autodelegate:macros_2.12:0.0.1'
// https://jarcasting.com/artifacts/io.methvin.autodelegate/macros_2.12/
implementation ("io.methvin.autodelegate:macros_2.12:0.0.1")
'io.methvin.autodelegate:macros_2.12:jar:0.0.1'
<dependency org="io.methvin.autodelegate" name="macros_2.12" rev="0.0.1">
  <artifact name="macros_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.methvin.autodelegate', module='macros_2.12', version='0.0.1')
)
libraryDependencies += "io.methvin.autodelegate" % "macros_2.12" % "0.0.1"
[io.methvin.autodelegate/macros_2.12 "0.0.1"]

Dependencies

compile (2)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.4
org.scala-lang : scala-reflect jar 2.12.4

test (1)

Group / Artifact Type Version
org.scalatest : scalatest_2.12 jar 3.0.4

Project Modules

There are no modules declared in this project.

FastForward

FastForward is a macro library that automatically implements traits or abstract classes by forwarding to another instance. It currently provides one macro called forward that generates an instance of a trait with abstract methods forwarded to a specific instance you pass to the macro.

Example

For example, say I have a trait Foo that I want to implement. If I have an instance of a class Bar that contains members of the same name, forward will automatically generate the implementations of the abstract Foo methods to forward to the methods of the instance of Bar you passed.

import io.methvin.fastforward._

trait Foo {
  def foo: String
  def bar: Long
  val baz: Option[String]
}
class Bar {
  def foo = "foo"
  def bar: Long = 2
  def baz = Some("baz")
}
val bar = new Bar
val impl: Foo = forward[Foo](bar)

Versions

Version
0.0.1