bael-3119 (#7436)
This commit is contained in:
parent
ba31134cfd
commit
9b97533de7
@ -0,0 +1,9 @@
|
||||
package com.baeldung.relationships.aggregation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Car {
|
||||
|
||||
private List<Wheel> wheels;
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.baeldung.relationships.aggregation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CarWithStaticInnerWheel {
|
||||
|
||||
private List<Wheel> wheels;
|
||||
|
||||
public static class Wheel {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.baeldung.relationships.aggregation;
|
||||
|
||||
public class Wheel {
|
||||
|
||||
private Car car;
|
||||
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.baeldung.relationships.association;
|
||||
|
||||
public class Child {
|
||||
|
||||
private Mother mother;
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.baeldung.relationships.association;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Mother {
|
||||
|
||||
private List<Child> children;
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.baeldung.relationships.composition;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Building {
|
||||
|
||||
private String address;
|
||||
private List<Room> rooms;
|
||||
|
||||
public class Room {
|
||||
|
||||
public String getBuildingAddress() {
|
||||
return Building.this.address;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.baeldung.relationships.composition;
|
||||
|
||||
public class BuildingWithDefinitionRoomInMethod {
|
||||
|
||||
public Room createAnonymousRoom() {
|
||||
return new Room() {
|
||||
@Override
|
||||
public void doInRoom() {}
|
||||
};
|
||||
}
|
||||
|
||||
public Room createInlineRoom() {
|
||||
class InlineRoom implements Room {
|
||||
@Override
|
||||
public void doInRoom() {}
|
||||
}
|
||||
return new InlineRoom();
|
||||
}
|
||||
|
||||
public Room createLambdaRoom() {
|
||||
return () -> {};
|
||||
}
|
||||
|
||||
public interface Room {
|
||||
void doInRoom();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.baeldung.relationships.university;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Department {
|
||||
|
||||
private List<Professor> professors;
|
||||
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.baeldung.relationships.university;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Professor {
|
||||
|
||||
private List<Department> department;
|
||||
private List<Professor> friends;
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.baeldung.relationships.university;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class University {
|
||||
|
||||
private List<Department> department;
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user