-
Notifications
You must be signed in to change notification settings - Fork 1
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
Sashir Estela
committed
Mar 19, 2024
1 parent
ecded63
commit c72c2aa
Showing
14 changed files
with
95 additions
and
94 deletions.
There are no files selected for viewing
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
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
31 changes: 10 additions & 21 deletions
31
src/main/java/io/github/sashirestela/cleverclient/support/CleverClientSSE.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
28 changes: 23 additions & 5 deletions
28
src/main/java/io/github/sashirestela/cleverclient/support/Configurator.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,37 +1,55 @@ | ||
package io.github.sashirestela.cleverclient.support; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.Singular; | ||
|
||
@Getter | ||
public class Configurator { | ||
|
||
private static Configurator configurator; | ||
private static final String EVENT_HEADER = "event: "; | ||
private static final String SEPARATOR = ""; | ||
|
||
private static Configurator configurator = new Configurator(); | ||
|
||
@Getter | ||
private List<String> eventsToRead; | ||
@Getter | ||
private List<String> endsOfStream; | ||
|
||
private List<String> linesToCheck; | ||
private boolean wasBuilt = false; | ||
|
||
private Configurator() { | ||
} | ||
|
||
@Builder | ||
public Configurator(@Singular("eventToRead") List<String> eventsToRead, | ||
@Singular("endOfStream") List<String> endsOfStream) { | ||
if (configurator != null) { | ||
if (configurator.wasBuilt) { | ||
return; | ||
} | ||
configurator = new Configurator(); | ||
configurator.eventsToRead = eventsToRead; | ||
configurator.endsOfStream = endsOfStream; | ||
configurator.wasBuilt = true; | ||
} | ||
|
||
public static Configurator one() { | ||
if (configurator == null) { | ||
if (!configurator.wasBuilt) { | ||
throw new CleverClientException("You have to call Configurator.builder() first."); | ||
} | ||
return configurator; | ||
} | ||
|
||
public List<String> getLinesToCheck() { | ||
if (linesToCheck == null) { | ||
linesToCheck = eventsToRead.stream().filter(etr -> !etr.isEmpty()).map(etr -> (EVENT_HEADER + etr)) | ||
.collect(Collectors.toList()); | ||
linesToCheck.add(SEPARATOR); | ||
} | ||
return linesToCheck; | ||
} | ||
|
||
} |
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
4 changes: 2 additions & 2 deletions
4
src/main/java/io/github/sashirestela/cleverclient/util/Constant.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
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