[Docs] Fix wrong syntax using paradox directives (#29876)
* Fix wrong syntax using paradox directives * Simplify collection.md - Only available for Scala, so hide most of the page for Java
This commit is contained in:
parent
374d55cd34
commit
64c27e435b
3 changed files with 23 additions and 34 deletions
|
|
@ -3,7 +3,7 @@ project.description: Data immutability using Project Lombok
|
||||||
---
|
---
|
||||||
# Immutability using Lombok
|
# Immutability using Lombok
|
||||||
|
|
||||||
A preferred best practise in Akka is to have immutable messages. Scala provides case class which makes it extremely easy
|
A preferred best practice in Akka is to have immutable messages. Scala provides case class which makes it extremely easy
|
||||||
to have short and clean classes for creating immutable objects, but no such facility is easily available in Java. We can make use
|
to have short and clean classes for creating immutable objects, but no such facility is easily available in Java. We can make use
|
||||||
of several third party libraries which help is achieving this. One good example is Lombok.
|
of several third party libraries which help is achieving this. One good example is Lombok.
|
||||||
|
|
||||||
|
|
@ -17,29 +17,17 @@ Lombok handles the following details for you. It:
|
||||||
* creates correct `equals`, `hashCode` and a human-friendly `toString`
|
* creates correct `equals`, `hashCode` and a human-friendly `toString`
|
||||||
* creates a constructor requiring all fields.
|
* creates a constructor requiring all fields.
|
||||||
|
|
||||||
|
|
||||||
### Adding Lombok to your project
|
### Adding Lombok to your project
|
||||||
|
|
||||||
To add Lombok to a Maven project, declare it as a simple dependency:
|
To add Lombok to a Maven project, declare it as a simple dependency:
|
||||||
|
|
||||||
Maven
|
@@dependency[Maven,Gradle] {
|
||||||
: @@dependency {
|
group="org.projectlombok"
|
||||||
<dependency>
|
artifact="lombok"
|
||||||
<groupId>org.projectlombok</groupId>
|
version=1.18.10
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<version>1.18.10</version>
|
|
||||||
</dependency>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Gradle
|
# Using lombok
|
||||||
: @@dependency {
|
|
||||||
dependencies {
|
|
||||||
compileOnly 'org.projectlombok:lombok:1.18.10'
|
|
||||||
annotationProcessor 'org.projectlombok:lombok:1.18.10'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Using lombok
|
|
||||||
|
|
||||||
@Value
|
@Value
|
||||||
public class LombokUser {
|
public class LombokUser {
|
||||||
|
|
@ -48,15 +36,15 @@ Gradle
|
||||||
|
|
||||||
String email;
|
String email;
|
||||||
}
|
}
|
||||||
|
|
||||||
The example does not demonstrate other useful Lombok features like `@Builder` or `@Wither` which will help
|
The example does not demonstrate other useful Lombok features like `@Builder` or `@Wither` which will help
|
||||||
you create builder and copy methods. Be aware that Lombok is not an immutability library but a
|
you create builder and copy methods. Be aware that Lombok is not an immutability library but a
|
||||||
code generation library which means some setups might not create immutable objects.
|
code generation library which means some setups might not create immutable objects.
|
||||||
For example, Lombok’s @Data is equivalent to Lombok’s @Value but will also synthesize mutable methods.
|
For example, Lombok’s @Data is equivalent to Lombok’s @Value but will also synthesize mutable methods.
|
||||||
Don’t use Lombok’s @Data when creating immutable classes.
|
Don’t use Lombok’s @Data when creating immutable classes.
|
||||||
|
|
||||||
Using Lombok for creating a message class for actors is quite simple. In following example, Message class
|
Using Lombok for creating a message class for actors is quite simple. In following example, Message class
|
||||||
just defines the member variable and Lombok annotation '@Value' takes care of creating methods like
|
just defines the member variable and Lombok annotation '@Value' takes care of creating methods like
|
||||||
getter, toString, hashCode, equals.
|
getter, toString, hashCode, equals.
|
||||||
|
|
||||||
public class MyActor extends AbstractActor {
|
public class MyActor extends AbstractActor {
|
||||||
|
|
@ -82,6 +70,8 @@ getter, toString, hashCode, equals.
|
||||||
}
|
}
|
||||||
|
|
||||||
### Integrating Lombok with an IDE
|
### Integrating Lombok with an IDE
|
||||||
|
|
||||||
Lombok integrates with popular IDEs:
|
Lombok integrates with popular IDEs:
|
||||||
|
|
||||||
* To use Lombok in IntelliJ IDEA you'll need the [Lombok Plugin for IntelliJ IDEA](https://plugins.jetbrains.com/plugin/6317-lombok) and you'll also need to enable Annotation Processing (`Settings / Build,Execution,Deployment / Compiler / Annotation Processors` and tick `Enable annotation processing`)
|
* To use Lombok in IntelliJ IDEA you'll need the [Lombok Plugin for IntelliJ IDEA](https://plugins.jetbrains.com/plugin/6317-lombok) and you'll also need to enable Annotation Processing (`Settings / Build,Execution,Deployment / Compiler / Annotation Processors` and tick `Enable annotation processing`)
|
||||||
* To Use Lombok in Eclipse, run `java -jar lombok.jar` (see the video at [Project Lombok](https://projectlombok.org/)).
|
* To Use Lombok in Eclipse, run `java -jar lombok.jar` (see the video at [Project Lombok](https://projectlombok.org/)).
|
||||||
|
|
|
||||||
|
|
@ -4,14 +4,15 @@
|
||||||
|
|
||||||
@ref[Sink operators](../index.md#sink-operators)
|
@ref[Sink operators](../index.md#sink-operators)
|
||||||
|
|
||||||
|
@@@div { .group-scala }
|
||||||
|
|
||||||
## Signature
|
## Signature
|
||||||
|
|
||||||
@apidoc[Sink.collection](Sink$) { scala="#collection[T,That](implicitcbf:akka.util.ccompat.Factory[T,Thatwithscala.collection.immutable.Iterable[_]]):akka.stream.scaladsl.Sink[T,scala.concurrent.Future[That]]" }
|
@apidoc[Sink.collection](Sink$) { scala="#collection[T,That](implicitcbf:akka.util.ccompat.Factory[T,Thatwithscala.collection.immutable.Iterable[_]]):akka.stream.scaladsl.Sink[T,scala.concurrent.Future[That]]" }
|
||||||
|
|
||||||
|
|
||||||
## Description
|
## Description
|
||||||
|
|
||||||
@scala[Collect values emitted from the stream into an arbitrary collection `That`. The resulting collection is available through a `Future[That]` or when the stream completes. Note that the collection boundaries are those defined in the `CanBuildFrom` associated with the chosen collection. See [The Architecture of Scala 2.13's Collections](https://docs.scala-lang.org/overviews/core/architecture-of-scala-213-collections.html) for more info. The [`seq`](seq.html) operator is a shorthand for `Sink.collection[T, Vector[T]]`.]@java[Operator only available in the Scala API. The closest operator in the Java API is [`Sink.seq`](seq.html).]
|
Collect values emitted from the stream into an arbitrary collection `That`. The resulting collection is available through a `Future[That]` or when the stream completes. Note that the collection boundaries are those defined in the `CanBuildFrom` associated with the chosen collection. See [The Architecture of Scala 2.13's Collections](https://docs.scala-lang.org/overviews/core/architecture-of-scala-213-collections.html) for more info. The [`seq`](seq.html) operator is a shorthand for `Sink.collection[T, Vector[T]]`.
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
|
|
@ -22,10 +23,10 @@ Scala
|
||||||
|
|
||||||
## Reactive Streams semantics
|
## Reactive Streams semantics
|
||||||
|
|
||||||
@@@
|
@@@@div { .callout }
|
||||||
|
|
||||||
@@@div { .group-scala .callout }
|
|
||||||
|
|
||||||
**cancels** If too many values are collected
|
**cancels** If too many values are collected
|
||||||
|
|
||||||
|
@@@@
|
||||||
|
|
||||||
@@@
|
@@@
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,7 @@ Never emit any elements, never complete and never fail.
|
||||||
|
|
||||||
## Signature
|
## Signature
|
||||||
|
|
||||||
@@signature [Source.scala](/akka-stream/src/main/scala/akka/stream/scaladsl/Source.scala) { #never }
|
@apidoc[Source.never](Source$) { scala="#never[T]:akka.stream.scaladsl.Source[T,akka.NotUsed]" java="#never()" }
|
||||||
|
|
||||||
@@@
|
|
||||||
|
|
||||||
## Description
|
## Description
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue