Adding marker interfaces files
This commit is contained in:
parent
191039ffc6
commit
ec0ec38b06
|
@ -0,0 +1,5 @@
|
|||
package com.baeldung.markerinterface;
|
||||
|
||||
public interface Deletable extends DeletableShape {
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.baeldung.markerinterface;
|
||||
|
||||
public interface DeletableShape {
|
||||
double getArea();
|
||||
|
||||
double getCircumference();
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.baeldung.markerinterface;
|
||||
|
||||
public class Rectangle implements Deletable {
|
||||
|
||||
private double width;
|
||||
private double height;
|
||||
|
||||
public Rectangle(double width, double height) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getArea() {
|
||||
return width * height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getCircumference() {
|
||||
return 2 * (width + height);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.baeldung.markerinterface;
|
||||
|
||||
public class ShapeDao {
|
||||
|
||||
public boolean delete(Object object) {
|
||||
if (!(object instanceof Deletable)) {
|
||||
return false;
|
||||
}
|
||||
// Calling the code that deletes the entity from the database
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue