Squashed commit of the following: (#10709)
commit2347e8b21bAuthor: ashleyfrieze <ashley@incredible.org.uk> Date: Tue Apr 27 21:40:33 2021 +0100 Minor tweak to pom commit0497a9e3e8Merge:a7cf36704b58c06a67e3Author: Daniel Strmecki <daniel.strmecki@gmail.com> Date: Mon Apr 26 20:27:13 2021 +0200 Merge branch 'master' into feature/BAEL-4502-compile-time-const commita7cf36704bAuthor: Daniel Strmecki <daniel.strmecki@gmail.com> Date: Mon Apr 26 20:25:47 2021 +0200 BASE-4502: Update POM commit86bfe45c48Author: Daniel Strmecki <daniel.strmecki@gmail.com> Date: Sun Apr 25 20:32:35 2021 +0200 BASE-4502: Revert POM changes and comment out JDK9+ code commitb538d1cc19Author: Daniel Strmecki <daniel.strmecki@gmail.com> Date: Sun Apr 25 16:42:47 2021 +0200 BASE-4502: Change parent commitf608783de5Author: Daniel Strmecki <daniel.strmecki@gmail.com> Date: Sun Apr 25 16:38:00 2021 +0200 BASE-4502: Maven compiler version commitf15f2b8447Author: Daniel Strmecki <daniel.strmecki@gmail.com> Date: Sun Apr 25 16:13:05 2021 +0200 BASE-4502: Compile to Java 11 commit79e780667cAuthor: Daniel Strmecki <daniel.strmecki@gmail.com> Date: Sat Apr 24 08:53:53 2021 +0200 BASE-4502: wrong case commitfca2515c41Author: Daniel Strmecki <daniel.strmecki@gmail.com> Date: Sat Apr 10 11:32:59 2021 +0200 BASE-4502: Add space commit0407a1e409Merge:54f11d5f055621594056Author: Daniel Strmecki <daniel.strmecki@gmail.com> Date: Sat Apr 10 11:24:57 2021 +0200 Merge remote-tracking branch 'origin/feature/BAEL-4502-compile-time-const' into feature/BAEL-4502-compile-time-const # Conflicts: # core-java-modules/core-java-lang-4/src/main/java/com/baeldung/compiletimeconstants/ClassConstants.java # core-java-modules/core-java-lang-4/src/main/java/com/baeldung/compiletimeconstants/CompileTimeVariables.java commit54f11d5f05Author: Daniel Strmecki <daniel.strmecki@gmail.com> Date: Sat Apr 10 11:23:12 2021 +0200 BASE-4502: PR comments and annotation example commit5621594056Author: daniel.strmecki <daniel.strmecki@ecx.io> Date: Sun Apr 4 12:43:17 2021 +0200 BAEL-4502: Remove unused examples commitb11077e79bAuthor: Daniel Strmecki <daniel.strmecki@gmail.com> Date: Sat Apr 3 11:14:29 2021 +0200 BASE-4502: Update examples commit9fea197cd6Merge:f6e1f2fc46b45902f460Author: Daniel Strmecki <daniel.strmecki@gmail.com> Date: Sun Mar 28 17:41:46 2021 +0200 Merge branch 'master' into feature/BAEL-4502-compile-time-const commitf6e1f2fc46Author: Daniel Strmecki <daniel.strmecki@gmail.com> Date: Sun Mar 28 17:40:31 2021 +0200 BASE-4502: Compile time examples
This commit is contained in:
@@ -39,5 +39,4 @@
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.baeldung.compiletimeconstants;
|
||||
|
||||
public class Annotations {
|
||||
|
||||
private final String deprecatedDate = "20-02-14";
|
||||
private final String deprecatedTime = "22:00";
|
||||
|
||||
//@Deprecated(since = deprecatedDate + " " + deprecatedTime) //TODO: Required JDK 9+
|
||||
public void deprecatedMethod() {}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.baeldung.compiletimeconstants;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ClassConstants {
|
||||
|
||||
public static final int MAXIMUM_NUMBER_OF_USERS = 10;
|
||||
public static final String DEFAULT_USERNAME = "unknown";
|
||||
|
||||
public static final Logger log = LoggerFactory.getLogger(ClassConstants.class);
|
||||
public static final List<String> contributorGroups = Arrays.asList("contributor", "author");
|
||||
|
||||
public static final int MAXIMUM_NUMBER_OF_GUESTS = MAXIMUM_NUMBER_OF_USERS * 10;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.baeldung.compiletimeconstants;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
public class CompileTimeVariables {
|
||||
|
||||
public final String errorMessage = ClassConstants.DEFAULT_USERNAME + " not allowed here.";
|
||||
public final int maximumLoginAttempts = 5;
|
||||
|
||||
public static void main(String[] args) {
|
||||
PrintWriter printWriter = System.console().writer();
|
||||
printWriter.println(ClassConstants.DEFAULT_USERNAME);
|
||||
|
||||
CompileTimeVariables instance = new CompileTimeVariables();
|
||||
printWriter.println(instance.maximumLoginAttempts);
|
||||
|
||||
final String username = "baeldung" + "-" + "user";
|
||||
printWriter.println(username);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.baeldung.compiletimeconstants;
|
||||
|
||||
import java.io.Console;
|
||||
public class RuntimeVariables {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Console console = System.console();
|
||||
|
||||
final String input = console.readLine();
|
||||
console.writer().println(input);
|
||||
|
||||
final double random = Math.random();
|
||||
console.writer().println("Number: " + random);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.baeldung.compiletimeconstants;
|
||||
|
||||
public class SwitchStatement {
|
||||
|
||||
private static final String VALUE_ONE = "value-one";
|
||||
|
||||
public static void main(String[] args) {
|
||||
final String valueTwo = "value" + "-" + "two";
|
||||
switch (args[0]) {
|
||||
case VALUE_ONE:
|
||||
break;
|
||||
case valueTwo:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user