-
Notifications
You must be signed in to change notification settings - Fork 4
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
21 changed files
with
151,798 additions
and
86 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package utils; | ||
|
||
import io.quarkus.logging.Log; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public final class NamesUtil { | ||
|
||
private static final int MAX_NAME_LENGTH = 4; | ||
public static final List<String> NAMES; | ||
|
||
static { | ||
try(final InputStream nameInputStream = NamesUtil.class.getClassLoader().getResourceAsStream("names.txt")) { | ||
if (nameInputStream == null) { | ||
throw new IOException("names list not found"); | ||
} | ||
try(BufferedReader reader = new BufferedReader(new InputStreamReader(nameInputStream))) { | ||
final List<String> names = new ArrayList<>(); | ||
while(reader.ready()) { | ||
names.add(reader.readLine()); | ||
} | ||
NAMES = names.stream().filter(s -> s.length() <= MAX_NAME_LENGTH).toList(); | ||
Log.infof("List of names initialized with %d items", NAMES.size()); | ||
} | ||
|
||
} catch (IOException e) { | ||
throw new IllegalStateException("Error while loading name list", e); | ||
} | ||
} | ||
|
||
public static String getNameById(int id) { | ||
if (id >= NAMES.size()) { | ||
throw new IllegalArgumentException("This name id is too big: " + id + "/" + NAMES.size()); | ||
} | ||
return NAMES.get(id); | ||
} | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
...main/java/qute/RockingDukeExtensions.java → ...ain/java/utils/RockingDukeExtensions.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,4 +1,4 @@ | ||
package qute; | ||
package utils; | ||
|
||
import io.quarkus.qute.TemplateExtension; | ||
|
||
|
Oops, something went wrong.