Skip to content

Commit

Permalink
feat: switch to lombok constructor and add JavaDoc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jungwire committed May 3, 2024
1 parent af97e9e commit b497f09
Showing 1 changed file with 34 additions and 32 deletions.
66 changes: 34 additions & 32 deletions src/main/java/eu/bbmri_eric/negotiator/database/model/Network.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
@Setter
@Entity
@Builder
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class Network {

@Id
Expand All @@ -20,19 +22,48 @@ public class Network {

@NotNull private String uri;

Check warning on line 23 in src/main/java/eu/bbmri_eric/negotiator/database/model/Network.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/eu/bbmri_eric/negotiator/database/model/Network.java#L23

Added line #L23 was not covered by tests

/**
* The name of the network.
*
* @param name the name of the network
* @return the name of the network
*/
@Column(unique = true)
private String name;

Check warning on line 32 in src/main/java/eu/bbmri_eric/negotiator/database/model/Network.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/eu/bbmri_eric/negotiator/database/model/Network.java#L32

Added line #L32 was not covered by tests

/** A unique and persistent identifier issued by an appropriate institution. */
/**
* A unique and persistent identifier issued by an appropriate institution.
*
* @param externalId the external identifier of the network
* @return the external identifier of the network
*/
@NotNull
@Column(unique = true)
private String externalId;

Check warning on line 42 in src/main/java/eu/bbmri_eric/negotiator/database/model/Network.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/eu/bbmri_eric/negotiator/database/model/Network.java#L42

Added line #L42 was not covered by tests

/**
* The contact email of the network.
*
* @param contactEmail the contact email of the network
* @return the contact email of the network
*/
private String contactEmail;

Check warning on line 50 in src/main/java/eu/bbmri_eric/negotiator/database/model/Network.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/eu/bbmri_eric/negotiator/database/model/Network.java#L50

Added line #L50 was not covered by tests

/**
* The managers of the network.
*
* @param managers the managers of the network
* @return the managers of the network
*/
@ManyToMany(mappedBy = "networks")
private Set<Person> managers = new HashSet<>();

Check warning on line 59 in src/main/java/eu/bbmri_eric/negotiator/database/model/Network.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/eu/bbmri_eric/negotiator/database/model/Network.java#L59

Added line #L59 was not covered by tests

/**
* The resources of the network.
*
* @param resources the resources of the network
* @return the resources of the network
*/
@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@JoinTable(
name = "network_resources_link",
Expand All @@ -41,37 +72,6 @@ public class Network {
@Builder.Default
private Set<Resource> resources = new HashSet<>();

/** No-args constructor for JPA and other reflection-based tools. */
Network() {}

/**
* All-args constructor for creating new instances.
*
* @param id the network's ID
* @param uri the network's URI
* @param name the network's name
* @param externalId the network's external ID
* @param contactEmail the network's contact email
* @param managers the network's managers
* @param resources the network's resources
*/
Network(
Long id,
String uri,
String name,
String externalId,
String contactEmail,
Set<Person> managers,
Set<Resource> resources) {
this.id = id;
this.uri = uri;
this.name = name;
this.externalId = externalId;
this.contactEmail = contactEmail;
this.managers = managers;
this.resources = resources;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand All @@ -85,11 +85,13 @@ public int hashCode() {
return Objects.hash(externalId);
}

// ** Adds a resource to the network. */
public void addResource(Resource collection) {
resources.add(collection);
collection.getNetworks().add(this);
}

// ** Removes a resource from the network. */
public void removeResource(Resource collection) {
resources.remove(collection);
collection.getNetworks().remove(this);
Expand Down

0 comments on commit b497f09

Please sign in to comment.