Skip to content

Commit 42c894e

Browse files
Ahmed Tawilapivovarit
authored andcommitted
BAEL-1307 Java Nested Classes (eugenp#3157)
* Evaluation article: Different Types of Bean Injection in Spring * added tests & changed configuration to Java-based config * removed xml config files * rename unit tests * BAEL-972 - Apache Commons Text * remove code from evaluation article * remove code from evaluation article * BAEL-972 - Apache Commons Text - added another example * BAEL-972 - Apache Commons Text - just indentation * BAEL-994 - TemporalAdjuster in Java * BAEL-994 - TemporalAdjuster in Java * BAEL-994 - TemporalAdjuster in Java * BAEL-994 - TemporalAdjuster in Java * BAEL-994 - TemporalAdjuster in Java - fix problems * BAEL-1033 Introduction to StreamUtils * BAEL-1033 Introduction to StreamUtils * BAEL-1033 Introduction to StreamUtils * fix formatting * BAEL-1033 minor refactor * BAEL-1035 Introduction to Eclipse Collections * format * BAEL-1035 Introduction to Eclipse Collections * BAEL-1035 Introduction to Eclipse Collections * BAEL-1035 Introduction to Eclipse Collections * cleanup * cleanup * BAEL-1109 Introduction to JCache * BAEL-1109 Introduction to JCache * remove unneeded property in pom.xml * fix formatting * close cache instances properly * remove latest commit * BAEL-1057 Introduction to rxjava-jdbc * refactor rxjava-jdbc * Refactor rxjava-jdbc * Refactoring rxjava-jdbc * BAEL-1171 java.lang.String API * refactor rxjava-jdbc * refactor String * String API - move multiple classes into a single class * move class into test package * BAEL-1171 String.lang.String API * BAEL-1171 java.lang.String API * BAEL-1250 Initializing Arrays in Java * BAEL-1250 Initializing Arrays in Java * BAEL-1250 Initializing Arrays in Java * small fix * BAEL-1171 java.lang.String API * BAEL-1263 Daemon Threads in Java * merge with fork * BAEL-1263 Daemon Threads in Java * fix compilation error * BAEL-1309 Append Data to a File with Java * fix build fails * fix test error * fix build failures * cleanup * fix Sneaky Runnable test * revert sneaky runnable fix attempt * fix test failure * fix test failure * fix all test failures * fix test failure * fix test failures * Nested Classes in Java * enhance nested classes
1 parent d45a891 commit 42c894e

12 files changed

Lines changed: 86 additions & 100 deletions

File tree

‎core-java/src/main/java/com/baeldung/nestedclass/Enclosing.java‎

Lines changed: 0 additions & 11 deletions
This file was deleted.

‎core-java/src/main/java/com/baeldung/nestedclass/Outer.java‎

Lines changed: 0 additions & 11 deletions
This file was deleted.

‎core-java/src/main/java/com/baeldung/nestedclass/SimpleAbstractClass.java‎

Lines changed: 0 additions & 5 deletions
This file was deleted.

core-java/src/test/java/com/baeldung/nestedclass/AnonymousInnerTest.java renamed to core-java/src/test/java/com/baeldung/nestedclass/AnonymousInner.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22

33
import org.junit.Test;
44

5-
public class AnonymousInnerTest {
5+
abstract class SimpleAbstractClass {
6+
abstract void run();
7+
}
8+
9+
public class AnonymousInner {
610

711
@Test
8-
public void whenRunAnonymousClass_thenCorrect() {
12+
public void run() {
913
SimpleAbstractClass simpleAbstractClass = new SimpleAbstractClass() {
1014
void run() {
1115
System.out.println("Running Anonymous Class...");
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.baeldung.nestedclass;
2+
3+
import org.junit.Test;
4+
5+
public class Enclosing {
6+
7+
private static int x = 1;
8+
9+
public static class StaticNested {
10+
11+
private void run() {
12+
System.out.println("x = " + x);
13+
}
14+
}
15+
16+
@Test
17+
public void test() {
18+
Enclosing.StaticNested nested = new Enclosing.StaticNested();
19+
nested.run();
20+
}
21+
}

‎core-java/src/test/java/com/baeldung/nestedclass/InnerClassTest.java‎

Lines changed: 0 additions & 13 deletions
This file was deleted.

‎core-java/src/test/java/com/baeldung/nestedclass/LocalClassTest.java‎

Lines changed: 0 additions & 12 deletions
This file was deleted.

‎core-java/src/test/java/com/baeldung/nestedclass/NestedClassTest.java‎

Lines changed: 0 additions & 12 deletions
This file was deleted.

core-java/src/main/java/com/baeldung/nestedclass/NewEnclosing.java renamed to core-java/src/test/java/com/baeldung/nestedclass/NewEnclosing.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
package com.baeldung.nestedclass;
22

3+
import org.junit.Test;
4+
35
public class NewEnclosing {
46

5-
void run() {
7+
private void run() {
68
class Local {
7-
89
void run() {
910
System.out.println("Welcome to Baeldung!");
1011
}
1112
}
1213
Local local = new Local();
1314
local.run();
1415
}
16+
17+
@Test
18+
public void test() {
19+
NewEnclosing newEnclosing = new NewEnclosing();
20+
newEnclosing.run();
21+
}
1522
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.baeldung.nestedclass;
2+
3+
import org.junit.Test;
4+
5+
public class NewOuter {
6+
7+
int a = 1;
8+
static int b = 2;
9+
10+
public class InnerClass {
11+
int a = 3;
12+
static final int b = 4;
13+
14+
public void run() {
15+
System.out.println("a = " + a);
16+
System.out.println("b = " + b);
17+
System.out.println("NewOuterTest.this.a = " + NewOuter.this.a);
18+
System.out.println("NewOuterTest.b = " + NewOuter.b);
19+
System.out.println("NewOuterTest.this.b = " + NewOuter.this.b);
20+
}
21+
}
22+
23+
@Test
24+
public void test() {
25+
NewOuter outer = new NewOuter();
26+
NewOuter.InnerClass inner = outer.new InnerClass();
27+
inner.run();
28+
29+
}
30+
}

0 commit comments

Comments
 (0)