Похоже, что вы хотите связать тип с атрибутом в вашем классе Entity
, для которого в идеале вы можете использовать следующий подход:
class Entity<T> {
public T model;
public Entity(T m) {
this.model = m;
}
}
, который затем можно создать как:
var ent = new Entity<>(""); // T is inferred based on the attribute type in the c'tor call
// or also explicitly specified as
var ent = new Entity<String>(""); //redundant though
, а затем использовать его как:
ent.model.format(""); // in this example 'model' is a 'String' with empty value ""