-
Notifications
You must be signed in to change notification settings - Fork 3
Service Layer interface
Wiki ▸ Service Layer Interface
The Service Layer interface is used as a template that enforces the implementation of common methods in service classes.
The interface is named ServiceInterface and it is located in the service package within the java-api folder.
Path:
/java-api/src/main/java/org/scoalaonline/api/service/ServiceInterface
The interface contains the following methods:
List<T> getAll()T getOneById( Long id );T add( T entry );T update( Long id, T object);void delete( Long id );
All the service classes will have to implement this interface. For example, given an
class Student and a service StudentService the implementation will look like this:
public class StudentService implements ServiceInterface<Student> {
...
}Afterwards, you will have to implement all the methods listed previously, acordingly to the explanations given in the comments of the ServiceInterface.
Note: The generic type T used in the representation of the methods, will be replaced by the
class you are making the service for. In our example this would be the Student class, so the
methods will become:
public class StudentService implements ServiceInterface<Student> {
public List<Student> getAll(){
...
}
public Student getOneById( Long id ){
...
}
public Student add( Student entry ){
...
}
public Student update( Long id, Student student){
...
}
public void delete( Long id ){
...
}
}Wiki | Site | Project Roadmap | Figma