Adding marker interfaces files

This commit is contained in:
soufiane-cheouati 2019-02-01 20:16:40 +00:00 committed by GitHub
parent 191039ffc6
commit ec0ec38b06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,5 @@
package com.baeldung.markerinterface;
public interface Deletable extends DeletableShape {
}

View File

@ -0,0 +1,7 @@
package com.baeldung.markerinterface;
public interface DeletableShape {
double getArea();
double getCircumference();
}

View File

@ -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);
}
}

View File

@ -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;
}
}