Lets say I have the following structure in java:
@MappedSuperClass
public class User extends AbstractEntity { ... }
@Entity
public class SuperUser extends User { ... }
@Entity
public class RegularUser extends User { ... }
This project is structured in RESTful endpoints with 3 layers (Resources, Services and Repositories) with generic abstractions:
public class AbstractRepository<T extends AbstractEntity> { ... }
now I want to have some DB methods executed over all types of User
, so I created this Repository layer:
public class UserRepository extends AbstractRepository<User> { ... }
Can it be called an Adapter or maybe Bridge, since its executing logic that kinda encapsulate the funcionality of two other classes ( RegularUserRepository
and SuperUserRepository
)?
There is no Gang-of-Four Design Pattern here. There are two kinds of polymorphism.
User
and its child classes.AbstractRepository
and AbstractEntity
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.