enter abstract parameter in interfaces

0

Good evening, I have a question. How do I add an abstract class in a method done in an interface as parameter? this in order to call implementing the interface can add any type of abstract class. My interface is this

public interface DBM {

String STRING_TYPE = "text";
String INT_TYPE = "integer";
String BOOLEAN_TYPE = "boolean";
String FLOAT_TYPE = "float";
String POINT_TYPE = "point";

String TABLA_BAR="bar";
String CAMPO_ID_BAR="id_bar";
String CAMPO_NOMBRE_BAR="nom_bar";
String CAMPO_CALIFICACION_BAR="cal_bar";

String CREAR_BAR="CREATE TABLE "+TABLA_BAR+"" +
        "("+CAMPO_ID_BAR+" "+INT_TYPE+" "+CAMPO_NOMBRE_BAR+" " +
        ""+STRING_TYPE+" "+CAMPO_CALIFICACION_BAR+" "+FLOAT_TYPE+")";
String ELIMINAR_BAR="DROP TABLE IF EXISTS "+TABLA_BAR;


boolean add(**aquí quiero ingresar la clase abstracta**);
boolean delete(**aquí quiero ingresar la clase abstracta**);
boolean update(**aquí quiero ingresar la clase abstracta**);
ArrayList getAll(**aquí quiero ingresar la clase abstracta**);

}

and when the implement can use a class for example

boolean add(Clientes cliente){ return true; }

    
asked by Matthew Seidel 26.12.2017 в 01:59
source

2 answers

1

A more elegant solution would be, using Generics:

public interface DBM<T extends Object> {
...
   boolean add(T objeto);
   boolean delete(T objeto);
   boolean update(T objeto);
   List<T> getAll(T objeto);
}

And to implement it:

  public class ClienteDBM implements DBM<Cliente> {
           public boolean add(Cliente objeto){
               ....
           }

           public boolean delete(Cliente cliente)
               ....
           }
           public boolean update(Cliente cliente)
               ....
           }
           public List<Cliente> getAll(Cliente cliente)
               ....
           }
    }
    
answered by 26.12.2017 / 12:23
source
0

I found a momentary solution

boolean add(Object [] objeto);

when invoking the function, all the values of the abstract class must be entered as an object and finally, this object is entered in the function

    
answered by 26.12.2017 в 03:03