README.md 5.3 KB
Newer Older
梦境迷离's avatar
梦境迷离 已提交
1
# smt
I
IceMimosa 已提交
2

梦境迷离's avatar
梦境迷离 已提交
3
| Project Stage | CI              | Codecov                                   |
梦境迷离's avatar
梦境迷离 已提交
4
|---------------|-----------------|-------------------------------------------|
梦境迷离's avatar
梦境迷离 已提交
5
| ![Stage]      | ![CI][Badge-CI] | [![codecov][Badge-Codecov]][Link-Codecov] |
6

梦境迷离's avatar
梦境迷离 已提交
7 8 9
| Scaladex                                                      | Jetbrains Plugin                              | Nexus Snapshots                                                  |
|---------------------------------------------------------------|-----------------------------------------------|------------------------------------------------------------------|
| [![smt Scala version support][Badge-Scaladex]][Link-Scaladex] | [![Version][Badge-Jetbrains]][Link-Jetbrains] | [![Sonatype Nexus (Snapshots)][Badge-Snapshots]][Link-Snapshots] |
I
IceMimosa 已提交
10

梦境迷离's avatar
梦境迷离 已提交
11
[中文说明](./README_CN.md) | [English](./README.md)
12

梦境迷离's avatar
梦境迷离 已提交
13
# Environment
14

梦境迷离's avatar
梦境迷离 已提交
15
- Compile passed in Java 8、11
梦境迷离's avatar
梦境迷离 已提交
16
- Compile passed in Scala 2.11.12、2.12.14、2.13.8
17

梦境迷离's avatar
梦境迷离 已提交
18 19 20 21 22 23
# Document

[https://bitlap.org/en-US/lab/smt](https://bitlap.org/en-US/lab/smt)

# How to use

梦境迷离's avatar
梦境迷离 已提交
24 25 26 27 28 29 30 31 32 33 34 35
## cache

- Memory cache.
- Zero dependencies, type-safe.
- API and implementation are completely independent.
```scala
"org.bitlap" %% "smt-cache" % "<VERSION>" // since 0.6.0 
```

## common

- Some very general tool classes.
36 37 38 39 40
- `Transformer` Transform the case class`From`'s object to the case class`To`'s object.
- `Transformable` Automatically generate instances of`Transformer`.
- Two ways to map fields: 
  - 1.use`Transformer`and define`Transformer`implicitly in the companion object of the case class.
  - 2.use`Transformable`'s`mapField`method directly.
梦境迷离's avatar
梦境迷离 已提交
41
```scala
梦境迷离's avatar
fix  
梦境迷离 已提交
42
"org.bitlap" %% "smt-common" % "<VERSION>" // since 0.6.0 
梦境迷离's avatar
梦境迷离 已提交
43 44
```

梦境迷离's avatar
梦境迷离 已提交
45
## csv
梦境迷离's avatar
梦境迷离 已提交
46

梦境迷离's avatar
梦境迷离 已提交
47
- `Converter` A basic CSV converter.
梦境迷离's avatar
梦境迷离 已提交
48 49
- `CsvableBuilder` Support for converting Scala`case class`to one CSV line in a custom way.
- `ScalableBuilder` Support for converting one CSV line to Scala`case class`in a custom way.
梦境迷离's avatar
梦境迷离 已提交
50
- `CsvFormat` Custom format and TSV file support.
梦境迷离's avatar
梦境迷离 已提交
51 52 53
- Zero dependency, type-safe

```scala
梦境迷离's avatar
梦境迷离 已提交
54
"org.bitlap" %% "smt-csv" % "<VERSION>" // since 0.5.2
梦境迷离's avatar
梦境迷离 已提交
55 56 57
```

## csv-derive
58

梦境迷离's avatar
梦境迷离 已提交
59
- `DeriveCsvConverter` Automatically derive`Converter`instances for Scala`case class`
梦境迷离's avatar
梦境迷离 已提交
60 61

```scala
梦境迷离's avatar
梦境迷离 已提交
62
"org.bitlap" %% "smt-csv-derive" % "<VERSION>" // since 0.5.2
梦境迷离's avatar
梦境迷离 已提交
63 64
```

梦境迷离's avatar
梦境迷离 已提交
65
## annotations
66 67 68 69 70

- `@toString`
- `@builder`
- `@log`
- `@apply`
梦境迷离's avatar
梦境迷离 已提交
71
- `@constructor`
梦境迷离's avatar
梦境迷离 已提交
72
- `@equalsAndHashCode`
梦境迷离's avatar
梦境迷离 已提交
73
- `@elapsed`
74
- `@javaCompatible`
梦境迷离's avatar
梦境迷离 已提交
75

梦境迷离's avatar
梦境迷离 已提交
76
> The intellij plugin named `Scala-Macro-Tools` in marketplace.
77

梦境迷离's avatar
梦境迷离 已提交
78
```scala
梦境迷离's avatar
梦境迷离 已提交
79
"org.bitlap" %% "smt-annotations" % "<VERSION>" // named smt-annotations since 0.6.0 
梦境迷离's avatar
梦境迷离 已提交
80
```
81

82
## cacheable [Not available for production]
梦境迷离's avatar
梦境迷离 已提交
83

梦境迷离's avatar
梦境迷离 已提交
84
A cache like Spring `@Cacheable` and `@cacheEvict` based on zio. It has no implementation of storage media. (not support Scala2.11.x)
梦境迷离's avatar
梦境迷离 已提交
85 86 87

- `@cacheable` / `Cache.apply`
- `@cacheEvict` / `Cache.evict`
梦境迷离's avatar
梦境迷离 已提交
88 89

```scala
梦境迷离's avatar
梦境迷离 已提交
90
"org.bitlap" %% "smt-cacheable" % "<VERSION>"
梦境迷离's avatar
梦境迷离 已提交
91 92
```

93
## cacheable-redis [Not available for production]
梦境迷离's avatar
梦境迷离 已提交
94

梦境迷离's avatar
梦境迷离 已提交
95
A distributed cache based on zio and zio-redis. It depends on `cacheable` module.
梦境迷离's avatar
梦境迷离 已提交
96

梦境迷离's avatar
梦境迷离 已提交
97
> TODO Not unavailable
梦境迷离's avatar
梦境迷离 已提交
98 99

```scala
梦境迷离's avatar
FIX  
梦境迷离 已提交
100
"org.bitlap" %% "smt-cacheable-redis" % "<VERSION>" // not support Scala2.11.x
梦境迷离's avatar
梦境迷离 已提交
101 102
```

103
## cacheable-caffeine [Not available for production]
梦境迷离's avatar
梦境迷离 已提交
104

梦境迷离's avatar
梦境迷离 已提交
105
A memory cache based on zio and caffeine. It needs `cacheable` module. (not support Scala2.11.x)
梦境迷离's avatar
梦境迷离 已提交
106
```scala
梦境迷离's avatar
梦境迷离 已提交
107
"org.bitlap" %% "smt-cacheable-caffeine" % "<VERSION>"
梦境迷离's avatar
梦境迷离 已提交
108 109
```

梦境迷离's avatar
梦境迷离 已提交
110
The artefacts have been uploaded to Maven Central. Importing the library into your build system (e.g gradle, sbt), is not enough. You need to follow an extra step.
梦境迷离's avatar
梦境迷离 已提交
111

梦境迷离's avatar
梦境迷离 已提交
112
| Scala 2.11                   | Scala 2.12                   | Scala 2.13                                          |
113
|------------------------------|------------------------------|-----------------------------------------------------|
梦境迷离's avatar
梦境迷离 已提交
114
| Import macro paradise plugin | Import macro paradise plugin | Enable compiler flag `-Ymacro-annotations` required |
梦境迷离's avatar
梦境迷离 已提交
115 116 117 118 119

```scala
addCompilerPlugin("org.scalamacros" % "paradise_<your-scala-version>" % "<plugin-version>")
```

梦境迷离's avatar
梦境迷离 已提交
120
Where `<your-scala-version>` must be the full scala version. For example 2.12.13, and not 2.12.
梦境迷离's avatar
梦境迷离 已提交
121

梦境迷离's avatar
梦境迷离 已提交
122
If that doesn't work, google for alternatives.
梦境迷离's avatar
梦境迷离 已提交
123

梦境迷离's avatar
梦境迷离 已提交
124
In version scala`2.13.x`, the functionality of macro paradise has been included in the scala compiler directly. However,
梦境迷离's avatar
梦境迷离 已提交
125
you must still enable the compiler flag `-Ymacro-annotations`.
梦境迷离's avatar
梦境迷离 已提交
126

梦境迷离's avatar
梦境迷离 已提交
127
# Especially thanks
梦境迷离's avatar
梦境迷离 已提交
128 129 130 131 132 133 134

<img src="https://resources.jetbrains.com/storage/products/company/brand/logos/IntelliJ_IDEA.svg" alt="IntelliJ IDEA logo.">


This project is developed using JetBrains IDEA.
Thanks to JetBrains for providing me with a free license, which is a strong support for me.

梦境迷离's avatar
梦境迷离 已提交
135
[Stage]: https://img.shields.io/badge/Project%20Stage-Development-yellowgreen.svg
梦境迷离's avatar
梦境迷离 已提交
136
[Badge-CI]: https://github.com/bitlap/smt/actions/workflows/ScalaCI.yml/badge.svg
梦境迷离's avatar
up  
梦境迷离 已提交
137
[Badge-Scaladex]: https://index.scala-lang.org/bitlap/smt/smt-annotations/latest.svg?platform=jvm
梦境迷离's avatar
梦境迷离 已提交
138
[Badge-Jetbrains]: https://img.shields.io/jetbrains/plugin/v/17202-scala-macro-tools
梦境迷离's avatar
梦境迷离 已提交
139 140
[Badge-Codecov]: https://codecov.io/gh/bitlap/smt/branch/master/graph/badge.svg?token=IA596YRTOT
[Badge-Snapshots]: https://img.shields.io/nexus/s/org.bitlap/smt-annotations_2.13?server=https%3A%2F%2Fs01.oss.sonatype.org
梦境迷离's avatar
梦境迷离 已提交
141 142

[Link-Jetbrains]: https://plugins.jetbrains.com/plugin/17202-scala-macro-tools
梦境迷离's avatar
梦境迷离 已提交
143
[Link-Codecov]: https://codecov.io/gh/bitlap/smt
梦境迷离's avatar
up  
梦境迷离 已提交
144
[Link-Scaladex]: https://index.scala-lang.org/bitlap/smt/smt-annotations
梦境迷离's avatar
梦境迷离 已提交
145
[Link-Snapshots]: https://s01.oss.sonatype.org/content/repositories/snapshots/org/bitlap/