35 lines
1009 B
Java
35 lines
1009 B
Java
package envoy.server.data;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import javax.persistence.*;
|
|
|
|
import envoy.data.User;
|
|
|
|
/**
|
|
* This class serves as a way to let Hibernate communicate with the server
|
|
* without bringing the dependency of JPA/Hibernate into the client.<br>
|
|
* It will be referenced as "database group" to clarify between the different
|
|
* group objects.<br>
|
|
* <br>
|
|
* Project: <strong>envoy-server-standalone</strong><br>
|
|
* File: <strong>Group.java</strong><br>
|
|
* Created: <strong>24.03.2020</strong><br>
|
|
*
|
|
* @author Maximilian Käfer
|
|
* @since Envoy Server Standalone v0.1-alpha
|
|
*/
|
|
@Entity
|
|
@Table(name = "groups")
|
|
@NamedQueries({ @NamedQuery(query = "SELECT g FROM Group g WHERE g.name = :name", name = "getGroupByName") })
|
|
public class Group extends Contact {
|
|
|
|
/**
|
|
* {@inheritDoc}
|
|
*/
|
|
@Override
|
|
public envoy.data.Group toCommon() {
|
|
return new envoy.data.Group(id, name, contacts.parallelStream().map(Contact::toCommon).map(User.class::cast).collect(Collectors.toSet()));
|
|
}
|
|
}
|