-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
118 additions
and
48 deletions.
There are no files selected for viewing
49 changes: 27 additions & 22 deletions
49
docs/src/main/java-jdk-21/docs/actors/classical/OptimizedActorWithJava21.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,38 @@ | ||
|
||
package docs.actors.classical; | ||
// #pattern-matching | ||
|
||
static class OptimizedActorWithJava21 extends UntypedAbstractActor { | ||
public static class Msg1 {} | ||
import org.apache.pekko.actor.UntypedAbstractActor; | ||
|
||
public class OptimizedActorWithJava21 extends UntypedAbstractActor { | ||
public static class Msg1 { | ||
} | ||
|
||
public static class Msg2 {} | ||
public static class Msg2 { | ||
} | ||
|
||
public static class Msg3 {} | ||
public static class Msg3 { | ||
} | ||
|
||
@Override | ||
public void onReceive(Object msg) throws Exception { | ||
switch(msg) { | ||
case Msg1 msg -> receiveMsg1((Msg1) msg); | ||
case Msg2 msg -> receiveMsg2((Msg2) msg); | ||
case Msg3 msg -> receiveMsg3((Msg3) msg); | ||
default _ -> unhandled(msg); | ||
@Override | ||
public void onReceive(Object msg) throws Exception { | ||
switch (msg) { | ||
case Msg1 msg1 -> receiveMsg1(msg1); | ||
case Msg2 msg2 -> receiveMsg2(msg2); | ||
case Msg3 msg3 -> receiveMsg3(msg3); | ||
default -> unhandled(msg); | ||
} | ||
} | ||
} | ||
|
||
private void receiveMsg1(Msg1 msg) { | ||
// actual work | ||
} | ||
private void receiveMsg1(Msg1 msg) { | ||
// actual work | ||
} | ||
|
||
private void receiveMsg2(Msg2 msg) { | ||
// actual work | ||
} | ||
private void receiveMsg2(Msg2 msg) { | ||
// actual work | ||
} | ||
|
||
private void receiveMsg3(Msg3 msg) { | ||
// actual work | ||
} | ||
private void receiveMsg3(Msg3 msg) { | ||
// actual work | ||
} | ||
} | ||
// #pattern-matching |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters