Skip to content

Commit ec0ec38

Browse files
Adding marker interfaces files
1 parent 191039f commit ec0ec38

4 files changed

Lines changed: 48 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.baeldung.markerinterface;
2+
3+
public interface Deletable extends DeletableShape {
4+
5+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.baeldung.markerinterface;
2+
3+
public interface DeletableShape {
4+
double getArea();
5+
6+
double getCircumference();
7+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.baeldung.markerinterface;
2+
3+
public class Rectangle implements Deletable {
4+
5+
private double width;
6+
private double height;
7+
8+
public Rectangle(double width, double height) {
9+
this.width = width;
10+
this.height = height;
11+
}
12+
13+
@Override
14+
public double getArea() {
15+
return width * height;
16+
}
17+
18+
@Override
19+
public double getCircumference() {
20+
return 2 * (width + height);
21+
}
22+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.baeldung.markerinterface;
2+
3+
public class ShapeDao {
4+
5+
public boolean delete(Object object) {
6+
if (!(object instanceof Deletable)) {
7+
return false;
8+
}
9+
// Calling the code that deletes the entity from the database
10+
11+
return true;
12+
}
13+
14+
}

0 commit comments

Comments
 (0)