Skip to content

Commit cd731d4

Browse files
authored
Squashed commit of the following: (eugenp#10709)
commit 2347e8b Author: ashleyfrieze <[email protected]> Date: Tue Apr 27 21:40:33 2021 +0100 Minor tweak to pom commit 0497a9e Merge: a7cf367 58c06a6 Author: Daniel Strmecki <[email protected]> Date: Mon Apr 26 20:27:13 2021 +0200 Merge branch 'master' into feature/BAEL-4502-compile-time-const commit a7cf367 Author: Daniel Strmecki <[email protected]> Date: Mon Apr 26 20:25:47 2021 +0200 BASE-4502: Update POM commit 86bfe45 Author: Daniel Strmecki <[email protected]> Date: Sun Apr 25 20:32:35 2021 +0200 BASE-4502: Revert POM changes and comment out JDK9+ code commit b538d1c Author: Daniel Strmecki <[email protected]> Date: Sun Apr 25 16:42:47 2021 +0200 BASE-4502: Change parent commit f608783 Author: Daniel Strmecki <[email protected]> Date: Sun Apr 25 16:38:00 2021 +0200 BASE-4502: Maven compiler version commit f15f2b8 Author: Daniel Strmecki <[email protected]> Date: Sun Apr 25 16:13:05 2021 +0200 BASE-4502: Compile to Java 11 commit 79e7806 Author: Daniel Strmecki <[email protected]> Date: Sat Apr 24 08:53:53 2021 +0200 BASE-4502: wrong case commit fca2515 Author: Daniel Strmecki <[email protected]> Date: Sat Apr 10 11:32:59 2021 +0200 BASE-4502: Add space commit 0407a1e Merge: 54f11d5 5621594 Author: Daniel Strmecki <[email protected]> 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 commit 54f11d5 Author: Daniel Strmecki <[email protected]> Date: Sat Apr 10 11:23:12 2021 +0200 BASE-4502: PR comments and annotation example commit 5621594 Author: daniel.strmecki <[email protected]> Date: Sun Apr 4 12:43:17 2021 +0200 BAEL-4502: Remove unused examples commit b11077e Author: Daniel Strmecki <[email protected]> Date: Sat Apr 3 11:14:29 2021 +0200 BASE-4502: Update examples commit 9fea197 Merge: f6e1f2f b45902f Author: Daniel Strmecki <[email protected]> Date: Sun Mar 28 17:41:46 2021 +0200 Merge branch 'master' into feature/BAEL-4502-compile-time-const commit f6e1f2f Author: Daniel Strmecki <[email protected]> Date: Sun Mar 28 17:40:31 2021 +0200 BASE-4502: Compile time examples
1 parent 620605d commit cd731d4

6 files changed

Lines changed: 85 additions & 2 deletions

File tree

core-java-modules/core-java-lang-4/pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,4 @@
3939
</resource>
4040
</resources>
4141
</build>
42-
43-
</project>
42+
</project>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.baeldung.compiletimeconstants;
2+
3+
public class Annotations {
4+
5+
private final String deprecatedDate = "20-02-14";
6+
private final String deprecatedTime = "22:00";
7+
8+
//@Deprecated(since = deprecatedDate + " " + deprecatedTime) //TODO: Required JDK 9+
9+
public void deprecatedMethod() {}
10+
11+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.baeldung.compiletimeconstants;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
6+
import java.util.Arrays;
7+
import java.util.List;
8+
9+
public class ClassConstants {
10+
11+
public static final int MAXIMUM_NUMBER_OF_USERS = 10;
12+
public static final String DEFAULT_USERNAME = "unknown";
13+
14+
public static final Logger log = LoggerFactory.getLogger(ClassConstants.class);
15+
public static final List<String> contributorGroups = Arrays.asList("contributor", "author");
16+
17+
public static final int MAXIMUM_NUMBER_OF_GUESTS = MAXIMUM_NUMBER_OF_USERS * 10;
18+
19+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.baeldung.compiletimeconstants;
2+
3+
import java.io.PrintWriter;
4+
5+
public class CompileTimeVariables {
6+
7+
public final String errorMessage = ClassConstants.DEFAULT_USERNAME + " not allowed here.";
8+
public final int maximumLoginAttempts = 5;
9+
10+
public static void main(String[] args) {
11+
PrintWriter printWriter = System.console().writer();
12+
printWriter.println(ClassConstants.DEFAULT_USERNAME);
13+
14+
CompileTimeVariables instance = new CompileTimeVariables();
15+
printWriter.println(instance.maximumLoginAttempts);
16+
17+
final String username = "baeldung" + "-" + "user";
18+
printWriter.println(username);
19+
}
20+
21+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.baeldung.compiletimeconstants;
2+
3+
import java.io.Console;
4+
public class RuntimeVariables {
5+
6+
public static void main(String[] args) {
7+
Console console = System.console();
8+
9+
final String input = console.readLine();
10+
console.writer().println(input);
11+
12+
final double random = Math.random();
13+
console.writer().println("Number: " + random);
14+
}
15+
16+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.baeldung.compiletimeconstants;
2+
3+
public class SwitchStatement {
4+
5+
private static final String VALUE_ONE = "value-one";
6+
7+
public static void main(String[] args) {
8+
final String valueTwo = "value" + "-" + "two";
9+
switch (args[0]) {
10+
case VALUE_ONE:
11+
break;
12+
case valueTwo:
13+
break;
14+
}
15+
}
16+
17+
}

0 commit comments

Comments
 (0)