Allow for placeholder configuration
This commit is contained in:
parent
10abe1d3f0
commit
ccc6c31cc9
58 changed files with 75 additions and 439 deletions
|
@ -30,15 +30,6 @@ import org.jetbrains.annotations.NotNull;
|
|||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public interface Placeholder {
|
||||
/**
|
||||
* Returns the placeholder's name.
|
||||
*
|
||||
* @return the placeholder name
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@NotNull
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Replaces the placeholder with it's appropriate content.
|
||||
*
|
||||
|
|
|
@ -40,16 +40,10 @@ public final class DateDay implements Placeholder {
|
|||
*/
|
||||
public DateDay() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "date_day";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", Miscellaneous.padNumbers(Calendar.getInstance().get(Calendar.DAY_OF_MONTH), 2));
|
||||
return text.replace("%date_day%", Miscellaneous.padNumbers(Calendar.getInstance().get(Calendar.DAY_OF_MONTH), 2));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,16 +40,10 @@ public final class DateMonth implements Placeholder {
|
|||
*/
|
||||
public DateMonth() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "date_month";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", Miscellaneous.padNumbers(Calendar.getInstance().get(Calendar.MONTH), 2));
|
||||
return text.replace("%date_month%", Miscellaneous.padNumbers(Calendar.getInstance().get(Calendar.MONTH), 2));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,16 +40,10 @@ public final class DateYear implements Placeholder {
|
|||
*/
|
||||
public DateYear() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "date_year";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", Miscellaneous.padNumbers(Calendar.getInstance().get(Calendar.YEAR), 4));
|
||||
return text.replace("%date_year%", Miscellaneous.padNumbers(Calendar.getInstance().get(Calendar.YEAR), 4));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,16 +38,10 @@ public final class EngineDependencyJansi implements Placeholder {
|
|||
*/
|
||||
public EngineDependencyJansi() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "engine_dependency_jansi";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", EngineInformation.getDependencyJansi());
|
||||
return text.replace("%engine_dependency_jansi%", EngineInformation.getDependencyJansi());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,16 +38,10 @@ public final class EngineDependencyJetbrainsAnnotations implements Placeholder {
|
|||
*/
|
||||
public EngineDependencyJetbrainsAnnotations() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "engine_dependency_jetbrains_annotations";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", EngineInformation.getDependencyJetbrainsAnnotations());
|
||||
return text.replace("%engine_dependency_jetbrains_annotations%", EngineInformation.getDependencyJetbrainsAnnotations());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,16 +38,10 @@ public final class EngineDependencyLombok implements Placeholder {
|
|||
*/
|
||||
public EngineDependencyLombok() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "engine_dependency_lombok";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", EngineInformation.getDependencyLombok());
|
||||
return text.replace("%engine_dependency_lombok%", EngineInformation.getDependencyLombok());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,16 +38,10 @@ public final class EngineDependencyLwjgl implements Placeholder {
|
|||
*/
|
||||
public EngineDependencyLwjgl() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "engine_dependency_lwjgl";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", EngineInformation.getDependencyLwjgl());
|
||||
return text.replace("%engine_dependency_lwjgl%", EngineInformation.getDependencyLwjgl());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,16 +38,10 @@ public final class EngineDependencyReflections implements Placeholder {
|
|||
*/
|
||||
public EngineDependencyReflections() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "engine_dependency_reflections";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", EngineInformation.getDependencyReflections());
|
||||
return text.replace("%engine_dependency_reflections%", EngineInformation.getDependencyReflections());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,16 +38,10 @@ public final class EngineDependencySlf4j implements Placeholder {
|
|||
*/
|
||||
public EngineDependencySlf4j() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "engine_dependency_slf4j";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", EngineInformation.getDependencySlf4j());
|
||||
return text.replace("%engine_dependency_slf4j%", EngineInformation.getDependencySlf4j());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,16 +38,10 @@ public final class EngineGitBranch implements Placeholder {
|
|||
*/
|
||||
public EngineGitBranch() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "engine_git_branch";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", EngineInformation.getGitBranch());
|
||||
return text.replace("%engine_git_branch%", EngineInformation.getGitBranch());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,16 +38,10 @@ public final class EngineGitCommitHeader implements Placeholder {
|
|||
*/
|
||||
public EngineGitCommitHeader() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "engine_git_commit_header";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", EngineInformation.getGitCommitHeader());
|
||||
return text.replace("%engine_git_commit_header%", EngineInformation.getGitCommitHeader());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,16 +38,10 @@ public final class EngineGitCommitIdLong implements Placeholder {
|
|||
*/
|
||||
public EngineGitCommitIdLong() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "engine_git_commit_id_long";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", EngineInformation.getGitCommitIdentifierLong());
|
||||
return text.replace("%engine_git_commit_id_long%", EngineInformation.getGitCommitIdentifierLong());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,16 +38,10 @@ public final class EngineGitCommitIdShort implements Placeholder {
|
|||
*/
|
||||
public EngineGitCommitIdShort() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "engine_git_commit_id_short";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", EngineInformation.getGitCommitIdentifierShort());
|
||||
return text.replace("%engine_git_commit_id_short%", EngineInformation.getGitCommitIdentifierShort());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,16 +38,10 @@ public final class EngineGitCommitTimeDay implements Placeholder {
|
|||
*/
|
||||
public EngineGitCommitTimeDay() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "engine_git_commit_time_day";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", String.valueOf(EngineInformation.getGitCommitTime().getDayOfMonth()));
|
||||
return text.replace("%engine_git_commit_time_day%", String.valueOf(EngineInformation.getGitCommitTime().getDayOfMonth()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,16 +38,10 @@ public final class EngineGitCommitTimeHour implements Placeholder {
|
|||
*/
|
||||
public EngineGitCommitTimeHour() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "engine_git_commit_time_hour";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", String.valueOf(EngineInformation.getGitCommitTime().getHour()));
|
||||
return text.replace("%engine_git_commit_time_hour%", String.valueOf(EngineInformation.getGitCommitTime().getHour()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,16 +38,10 @@ public final class EngineGitCommitTimeMinute implements Placeholder {
|
|||
*/
|
||||
public EngineGitCommitTimeMinute() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "engine_git_commit_time_minute";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", String.valueOf(EngineInformation.getGitCommitTime().getMinute()));
|
||||
return text.replace("%engine_git_commit_time_minute%", String.valueOf(EngineInformation.getGitCommitTime().getMinute()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,16 +38,10 @@ public final class EngineGitCommitTimeMonth implements Placeholder {
|
|||
*/
|
||||
public EngineGitCommitTimeMonth() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "engine_git_commit_time_month";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", String.valueOf(EngineInformation.getGitCommitTime().getMonth()));
|
||||
return text.replace("%engine_git_commit_time_month%", String.valueOf(EngineInformation.getGitCommitTime().getMonth()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,16 +38,10 @@ public final class EngineGitCommitTimeSecond implements Placeholder {
|
|||
*/
|
||||
public EngineGitCommitTimeSecond() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "engine_git_commit_time_second";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", String.valueOf(EngineInformation.getGitCommitTime().getSecond()));
|
||||
return text.replace("%engine_git_commit_time_second%", String.valueOf(EngineInformation.getGitCommitTime().getSecond()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,16 +38,10 @@ public final class EngineGitCommitTimeYear implements Placeholder {
|
|||
*/
|
||||
public EngineGitCommitTimeYear() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "engine_git_commit_time_year";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", String.valueOf(EngineInformation.getGitCommitTime().getYear()));
|
||||
return text.replace("%engine_git_commit_time_year%", String.valueOf(EngineInformation.getGitCommitTime().getYear()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,16 +38,10 @@ public final class EngineGitCommits implements Placeholder {
|
|||
*/
|
||||
public EngineGitCommits() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "engine_git_commits";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", String.valueOf(EngineInformation.getGitCommitCount()));
|
||||
return text.replace("%engine_git_commits%", String.valueOf(EngineInformation.getGitCommitCount()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,16 +38,10 @@ public final class EngineGitCommitterEmail implements Placeholder {
|
|||
*/
|
||||
public EngineGitCommitterEmail() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "engine_git_committer_email";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", EngineInformation.getGitCommitterEmail());
|
||||
return text.replace("%engine_git_committer_email%", EngineInformation.getGitCommitterEmail());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,16 +38,10 @@ public final class EngineGitCommitterName implements Placeholder {
|
|||
*/
|
||||
public EngineGitCommitterName() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "engine_git_committer_name";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", EngineInformation.getGitCommitterName());
|
||||
return text.replace("%engine_git_committer_name%", EngineInformation.getGitCommitterName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,16 +38,10 @@ public final class EngineGitDirty implements Placeholder {
|
|||
*/
|
||||
public EngineGitDirty() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "engine_git_dirty";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", String.valueOf(EngineInformation.getGitDirty()));
|
||||
return text.replace("%engine_git_dirty%", String.valueOf(EngineInformation.getGitDirty()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,16 +37,10 @@ public final class EngineVersion implements Placeholder {
|
|||
*/
|
||||
public EngineVersion() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "engine_version";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", "v%engine_version_version%-%engine_version_type%%engine_version_typerelease%%engine_version_fork%");
|
||||
return text.replace("%engine_version%", "v%engine_version_version%-%engine_version_type%%engine_version_typerelease%%engine_version_fork%");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,16 +38,10 @@ public final class EngineVersionFork implements Placeholder {
|
|||
*/
|
||||
public EngineVersionFork() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "engine_version_fork";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", EngineInformation.getVersioningFork());
|
||||
return text.replace("%engine_version_fork%", EngineInformation.getVersioningFork());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,16 +38,10 @@ public final class EngineVersionType implements Placeholder {
|
|||
*/
|
||||
public EngineVersionType() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "engine_version_type";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", EngineInformation.getVersioningType().name().toLowerCase());
|
||||
return text.replace("%engine_version_type%", EngineInformation.getVersioningType().name().toLowerCase());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,16 +38,10 @@ public final class EngineVersionTyperelease implements Placeholder {
|
|||
*/
|
||||
public EngineVersionTyperelease() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "engine_version_typerelease";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", String.valueOf(EngineInformation.getVersioningTyperelease()));
|
||||
return text.replace("%engine_version_typerelease%", String.valueOf(EngineInformation.getVersioningTyperelease()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,16 +38,10 @@ public final class EngineVersionVersion implements Placeholder {
|
|||
*/
|
||||
public EngineVersionVersion() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "engine_version_version";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", String.valueOf(EngineInformation.getVersioningVersion()));
|
||||
return text.replace("%engine_version_version%", String.valueOf(EngineInformation.getVersioningVersion()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,13 +38,6 @@ public final class JvmArguments implements Placeholder {
|
|||
*/
|
||||
public JvmArguments() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "jvm_arguments";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
|
@ -65,6 +58,6 @@ public final class JvmArguments implements Placeholder {
|
|||
.append("\"");
|
||||
}
|
||||
|
||||
return text.replace("%" + getName() + "%", arguments.toString());
|
||||
return text.replace("%jvm_arguments%", arguments.toString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,17 +38,10 @@ public final class JvmImplementationName implements Placeholder {
|
|||
*/
|
||||
public JvmImplementationName() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "jvm_implementation_name";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", JvmInformation.getImplementationName());
|
||||
return text.replace("%jvm_implementation_name%", JvmInformation.getImplementationName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,17 +38,10 @@ public final class JvmImplementationVendor implements Placeholder {
|
|||
*/
|
||||
public JvmImplementationVendor() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "jvm_implementation_vendor";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", JvmInformation.getImplementationVendor());
|
||||
return text.replace("%jvm_implementation_vendor%", JvmInformation.getImplementationVendor());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,17 +38,10 @@ public final class JvmImplementationVersion implements Placeholder {
|
|||
*/
|
||||
public JvmImplementationVersion() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "jvm_implementation_version";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", JvmInformation.getImplementationVersion());
|
||||
return text.replace("%jvm_implementation_version%", JvmInformation.getImplementationVersion());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,17 +38,10 @@ public final class JvmJava implements Placeholder {
|
|||
*/
|
||||
public JvmJava() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "jvm_java";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", String.valueOf(JvmInformation.getJavaVersion()));
|
||||
return text.replace("%jvm_java%", String.valueOf(JvmInformation.getJavaVersion()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,17 +38,10 @@ public final class JvmUptime implements Placeholder {
|
|||
*/
|
||||
public JvmUptime() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "jvm_uptime";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", String.valueOf(JvmInformation.getUptime()));
|
||||
return text.replace("%jvm_uptime%", String.valueOf(JvmInformation.getUptime()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,16 +39,10 @@ public final class TimeEpoch implements Placeholder {
|
|||
*/
|
||||
public TimeEpoch() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "time_epoch";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", Miscellaneous.padNumbers(System.currentTimeMillis(), String.valueOf(Long.MAX_VALUE).length()));
|
||||
return text.replace("%time_epoch%", Miscellaneous.padNumbers(System.currentTimeMillis(), String.valueOf(Long.MAX_VALUE).length()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,16 +40,10 @@ public final class TimeHour implements Placeholder {
|
|||
*/
|
||||
public TimeHour() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "time_hour";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", Miscellaneous.padNumbers(Calendar.getInstance().get(Calendar.HOUR_OF_DAY), 2));
|
||||
return text.replace("%time_hour%", Miscellaneous.padNumbers(Calendar.getInstance().get(Calendar.HOUR_OF_DAY), 2));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,16 +40,10 @@ public final class TimeMinute implements Placeholder {
|
|||
*/
|
||||
public TimeMinute() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "time_minute";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", Miscellaneous.padNumbers(Calendar.getInstance().get(Calendar.MINUTE), 2));
|
||||
return text.replace("%time_minute%", Miscellaneous.padNumbers(Calendar.getInstance().get(Calendar.MINUTE), 2));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,16 +40,10 @@ public final class TimeSecond implements Placeholder {
|
|||
*/
|
||||
public TimeSecond() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "time_second";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", Miscellaneous.padNumbers(Calendar.getInstance().get(Calendar.SECOND), 2));
|
||||
return text.replace("%time_second%", Miscellaneous.padNumbers(Calendar.getInstance().get(Calendar.SECOND), 2));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,16 +39,10 @@ public final class TimeZone implements Placeholder {
|
|||
*/
|
||||
public TimeZone() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "time_zone";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", java.util.TimeZone.getDefault().getDisplayName(false, java.util.TimeZone.SHORT, Locale.US));
|
||||
return text.replace("%time_zone%", java.util.TimeZone.getDefault().getDisplayName(false, java.util.TimeZone.SHORT, Locale.US));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,17 +49,10 @@ public final class IssuerClass implements Placeholder {
|
|||
this.logIssuer = logIssuer;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "issuer_class";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", logIssuer.getClazz().getName().replace(logIssuer.getClazz().getPackageName() + ".", ""));
|
||||
return text.replace("%issuer_class%", logIssuer.getClazz().getName().replace(logIssuer.getClazz().getPackageName() + ".", ""));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,17 +49,10 @@ public final class IssuerCodePart implements Placeholder {
|
|||
this.logIssuer = logIssuer;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "issuer_code_part";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", logIssuer.getCodePart().name());
|
||||
return text.replace("%issuer_code_part%", logIssuer.getCodePart().name());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,20 +49,15 @@ public final class IssuerInfo implements Placeholder {
|
|||
this.logIssuer = logIssuer;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "issuer_info";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
if (logIssuer.getAdditionalInformation() == null)
|
||||
return text.replace("%" + getName() + "%", "<none>");
|
||||
else
|
||||
return text.replace("%" + getName() + "%", logIssuer.getAdditionalInformation());
|
||||
String replacement = "<none>";
|
||||
|
||||
if (logIssuer.getAdditionalInformation() != null)
|
||||
replacement = logIssuer.getAdditionalInformation();
|
||||
|
||||
return text.replace("%issuer_info%", replacement);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,17 +48,10 @@ public final class IssuerMessage implements Placeholder {
|
|||
this.message = message;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "issuer_message";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", message);
|
||||
return text.replace("%issuer_message%", message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,17 +49,10 @@ public final class IssuerPackage implements Placeholder {
|
|||
this.logIssuer = logIssuer;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "issuer_package";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", logIssuer.getClazz().getPackageName());
|
||||
return text.replace("%issuer_package%", logIssuer.getClazz().getPackageName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,17 +49,10 @@ public final class IssuerPath implements Placeholder {
|
|||
this.logIssuer = logIssuer;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "issuer_path";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", logIssuer.getClazz().getName());
|
||||
return text.replace("%issuer_path%", logIssuer.getClazz().getName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,23 +50,17 @@ public final class Stacktrace implements Placeholder {
|
|||
this.throwable = throwable;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "stacktrace";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
if (throwable == null)
|
||||
return text.replace("%" + getName() + "%", "No stacktrace is available.");
|
||||
else {
|
||||
StackTraceParser stackTraceParser = new StackTraceParser(throwable);
|
||||
String replacement = "No stacktrace is available.";
|
||||
|
||||
return text.replace("%" + getName() + "%", stackTraceParser.getHeader() + "\n" + stackTraceParser.getStackTrace());
|
||||
if (throwable != null) {
|
||||
StackTraceParser stackTraceParser = new StackTraceParser(throwable);
|
||||
replacement = stackTraceParser.getHeader() + "\n" + stackTraceParser.getStackTrace();
|
||||
}
|
||||
|
||||
return text.replace("%stacktrace%", replacement);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,17 +49,10 @@ public final class LogClass implements Placeholder {
|
|||
this.logIssuer = logIssuer;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "log_class";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", logIssuer.getClazz().getName().replace(logIssuer.getClazz().getPackageName() + ".", ""));
|
||||
return text.replace("%log_class%", logIssuer.getClazz().getName().replace(logIssuer.getClazz().getPackageName() + ".", ""));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,17 +49,10 @@ public final class LogCodePart implements Placeholder {
|
|||
this.logIssuer = logIssuer;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "log_code_part";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", logIssuer.getCodePart().name());
|
||||
return text.replace("%log_code_part%", logIssuer.getCodePart().name());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,13 +49,6 @@ public final class LogColorPrimary implements Placeholder {
|
|||
this.level = level;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "log_color_primary";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
|
@ -71,6 +64,6 @@ public final class LogColorPrimary implements Placeholder {
|
|||
default -> color = "";
|
||||
}
|
||||
|
||||
return text.replace("%" + getName() + "%", color);
|
||||
return text.replace("%log_color_primary%", color);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,13 +49,6 @@ public final class LogColorSecondary implements Placeholder {
|
|||
this.level = level;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "log_color_secondary";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
|
@ -67,6 +60,6 @@ public final class LogColorSecondary implements Placeholder {
|
|||
default -> color = "";
|
||||
}
|
||||
|
||||
return text.replace("%" + getName() + "%", color);
|
||||
return text.replace("%log_color_secondary%", color);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,19 +49,15 @@ public final class LogInfo implements Placeholder {
|
|||
this.logIssuer = logIssuer;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "log_info";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
String replacement = "";
|
||||
|
||||
if (logIssuer.getAdditionalInformation() != null)
|
||||
return text.replace("%" + getName() + "%", "/" + logIssuer.getAdditionalInformation());
|
||||
return text.replace("%" + getName() + "%", "");
|
||||
replacement = "/" + logIssuer.getAdditionalInformation();
|
||||
|
||||
return text.replace("%log_info%", replacement);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,13 +48,6 @@ public final class LogLevel implements Placeholder {
|
|||
this.level = level;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "log_level";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
|
@ -68,6 +61,6 @@ public final class LogLevel implements Placeholder {
|
|||
default -> levelText = level.name().substring(0, 4);
|
||||
}
|
||||
|
||||
return text.replace("%" + getName() + "%", levelText);
|
||||
return text.replace("%log_level%", levelText);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,17 +48,10 @@ public final class LogMessage implements Placeholder {
|
|||
this.message = message;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "log_message";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", message);
|
||||
return text.replace("%log_message%", message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,17 +49,10 @@ public final class LogPackage implements Placeholder {
|
|||
this.logIssuer = logIssuer;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "log_package";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", logIssuer.getClazz().getPackageName());
|
||||
return text.replace("%log_package%", logIssuer.getClazz().getPackageName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,17 +49,10 @@ public final class LogPath implements Placeholder {
|
|||
this.logIssuer = logIssuer;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "log_path";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", logIssuer.getClazz().getName());
|
||||
return text.replace("%log_path%", logIssuer.getClazz().getName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -144,13 +144,11 @@ public final class PlaceholderEngine {
|
|||
public String process(@NotNull String text, List<@NotNull Placeholder> temporaryPlaceholders) {
|
||||
// Process temporary placeholders
|
||||
for (Placeholder temporaryPlaceholder : temporaryPlaceholders)
|
||||
if (text.contains("%" + temporaryPlaceholder.getName() + "%"))
|
||||
text = temporaryPlaceholder.replace(text);
|
||||
text = temporaryPlaceholder.replace(text);
|
||||
|
||||
// Process normal placeholders
|
||||
for (Placeholder placeholder : placeholders)
|
||||
if (text.contains("%" + placeholder.getName() + "%"))
|
||||
text = placeholder.replace(text);
|
||||
text = placeholder.replace(text);
|
||||
|
||||
return text;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ package de.staropensource.sosengine.base.srctests.utility;
|
|||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.exceptions.UnexpectedThrowableException;
|
||||
import de.staropensource.sosengine.base.exceptions.reflection.InvalidMethodException;
|
||||
import de.staropensource.sosengine.base.exceptions.reflection.NoAccessException;
|
||||
import de.staropensource.sosengine.base.reflection.Reflect;
|
||||
import de.staropensource.sosengine.base.utility.PlaceholderEngine;
|
||||
import de.staropensource.sosengine.unittests.UnitLogger;
|
||||
|
@ -61,7 +62,7 @@ class PlaceholderEngineTest {
|
|||
* Sets the {@link PlaceholderEngine}#{@code instance} to {@code null} after each test.
|
||||
*/
|
||||
@AfterEach
|
||||
void clearInstance() throws InvalidMethodException, UnexpectedThrowableException, InvocationTargetException {
|
||||
void clearInstance() throws InvalidMethodException, UnexpectedThrowableException, InvocationTargetException, NoAccessException {
|
||||
Reflect.reflectOn(PlaceholderEngine.class).getMethod("clearInstance").invoke();
|
||||
}
|
||||
|
||||
|
@ -80,23 +81,15 @@ class PlaceholderEngineTest {
|
|||
|
||||
List<@NotNull Placeholder> placeholders = new ArrayList<>();
|
||||
placeholders.add(new Placeholder() {
|
||||
@Override
|
||||
public @NotNull String getName() {
|
||||
return "test";
|
||||
}
|
||||
@Override
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", "TEST");
|
||||
return text.replace("%test%", "TEST");
|
||||
}
|
||||
});
|
||||
placeholders.add(new Placeholder() {
|
||||
@Override
|
||||
public @NotNull String getName() {
|
||||
return "status";
|
||||
}
|
||||
@Override
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%" + getName() + "%", "works");
|
||||
return text.replace("%status%", "works");
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue