Skip to content

Commit

Permalink
Add @Serial annotation to all serialVersionUID fields.
Browse files Browse the repository at this point in the history
- Enhance code readability and maintainability
- Improve static analysis capabilities
- Ensure proper declaration of serialVersionUID fields

Closes #3584
  • Loading branch information
Seol-JY authored and mp911de committed Aug 20, 2024
1 parent ccbe208 commit 2e6e1cf
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@

import static com.querydsl.core.types.PathMetadataFactory.forVariable;

import java.io.Serial;

/**
* Query class for Country domain.
*
* @author Dmytro Iaroslavskyi
*/
public class QCountry extends EntityPathBase<Country> {

private static final long serialVersionUID = -936338527;
@Serial private static final long serialVersionUID = -936338527;

private static final PathInits INITS = PathInits.DIRECT2;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;

import java.io.Serial;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand All @@ -39,7 +40,7 @@
*/
public class JpaSort extends Sort {

private static final long serialVersionUID = 1L;
@Serial private static final long serialVersionUID = 1L;

private JpaSort(Direction direction, List<Path<?, ?>> paths) {
this(Collections.<Order>emptyList(), direction, paths);
Expand Down Expand Up @@ -316,7 +317,7 @@ public String toString() {
*/
public static class JpaOrder extends Order {

private static final long serialVersionUID = 1L;
@Serial private static final long serialVersionUID = 1L;

private final boolean unsafe;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root;

import java.io.Serial;
import java.io.Serializable;
import java.util.Arrays;
import java.util.stream.StreamSupport;
Expand All @@ -40,7 +41,7 @@
*/
public interface Specification<T> extends Serializable {

long serialVersionUID = 1L;
@Serial long serialVersionUID = 1L;

/**
* Negates the given {@link Specification}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package org.springframework.data.jpa.repository.query;

import java.io.Serial;

/**
* Signals that we encountered an invalid query method.
*
Expand All @@ -23,7 +25,7 @@
*/
public class InvalidJpaQueryMethodException extends RuntimeException {

private static final long serialVersionUID = 1L;
@Serial private static final long serialVersionUID = 1L;

/**
* Creates a new {@link InvalidJpaQueryMethodException} with the given message.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root;

import java.io.Serial;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -952,7 +953,7 @@ private static long executeCountQuery(TypedQuery<Long> query) {
@SuppressWarnings("rawtypes")
private static final class ByIdsSpecification<T> implements Specification<T> {

private static final long serialVersionUID = 1L;
@Serial private static final long serialVersionUID = 1L;

private final JpaEntityInformation<T, ?> entityInformation;

Expand Down Expand Up @@ -981,7 +982,7 @@ public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuild
*/
private static class ExampleSpecification<T> implements Specification<T> {

private static final long serialVersionUID = 1L;
@Serial private static final long serialVersionUID = 1L;

private final Example<T> example;
private final EscapeCharacter escapeCharacter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package org.springframework.data.jpa.domain.sample;

import java.io.Serial;

import jakarta.persistence.Entity;

import org.springframework.data.jpa.domain.AbstractPersistable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.springframework.data.jpa.domain.sample;

import java.io.Serial;
import java.io.Serializable;

import jakarta.persistence.Column;
Expand All @@ -25,7 +26,7 @@
*/
@Embeddable
public class EmbeddedIdExampleEmployeePK implements Serializable {
private static final long serialVersionUID = 1L;
@Serial private static final long serialVersionUID = 1L;

@Column(nullable = false) private Long employeeId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
*/
package org.springframework.data.jpa.domain.sample;

import java.io.Serial;
import java.io.Serializable;

/**
* @author Thomas Darimont
*/
public class IdClassExampleEmployeePK implements Serializable {
private static final long serialVersionUID = 1L;
@Serial private static final long serialVersionUID = 1L;

private long empId;
private long department;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.springframework.data.jpa.domain.sample;

import java.io.Serial;
import java.io.Serializable;

/**
Expand All @@ -25,7 +26,7 @@
*/
public class ItemId implements Serializable {

private static final long serialVersionUID = -2986871112875450036L;
@Serial private static final long serialVersionUID = -2986871112875450036L;

private Integer id;
private Integer manufacturerId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.springframework.data.jpa.domain.sample;

import java.io.Serial;
import java.io.Serializable;

/**
Expand All @@ -25,7 +26,7 @@
*/
public class ItemSiteId implements Serializable {

private static final long serialVersionUID = 1822540289216799357L;
@Serial private static final long serialVersionUID = 1822540289216799357L;

private ItemId item;
private Integer site;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import static org.springframework.util.ObjectUtils.*;

import java.io.Serial;
import java.io.Serializable;

/**
Expand All @@ -25,7 +26,7 @@
*/
public class PersistableWithIdClassPK implements Serializable {

private static final long serialVersionUID = 23126782341L;
@Serial private static final long serialVersionUID = 23126782341L;

private Long first;
private Long second;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@

import static org.springframework.util.ObjectUtils.*;

import java.io.Serial;
import java.io.Serializable;

/**
* @author Mark Paluch
*/
public class PersistableWithSingleIdClassPK implements Serializable {

private static final long serialVersionUID = 23126782341L;
@Serial private static final long serialVersionUID = 23126782341L;

private Long first;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.springframework.data.jpa.domain.sample;

import java.io.Serial;
import java.io.Serializable;

import jakarta.persistence.Column;
Expand All @@ -25,7 +26,7 @@
@Embeddable
public class SampleEntityPK implements Serializable {

private static final long serialVersionUID = 231060947L;
@Serial private static final long serialVersionUID = 231060947L;

@Column(nullable = false)
private String first;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package org.springframework.data.jpa.domain.sample;

import java.io.Serial;

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
Expand All @@ -31,7 +33,7 @@
@Table
public class Site implements java.io.Serializable {

private static final long serialVersionUID = 1L;
@Serial private static final long serialVersionUID = 1L;

@Id @GeneratedValue Integer id;

Expand Down

0 comments on commit 2e6e1cf

Please sign in to comment.