mirror of
https://github.com/tiennm99/lombok.git
synced 2026-05-28 12:22:31 +00:00
Fixed issue 513: If equals is present but hashCode isn't, @Data now generates a warning to explain this strange situation.
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import lombok.*;
|
||||
import static lombok.AccessLevel.NONE;
|
||||
|
||||
@Data
|
||||
@Getter(NONE)
|
||||
@Setter(NONE)
|
||||
class EqualsAndHashCodeWithSomeExistingMethods {
|
||||
int x;
|
||||
|
||||
public int hashCode() {
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Getter(NONE)
|
||||
@Setter(NONE)
|
||||
class EqualsAndHashCodeWithSomeExistingMethods2 {
|
||||
int x;
|
||||
|
||||
public boolean canEqual(Object other) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Getter(NONE)
|
||||
@Setter(NONE)
|
||||
class EqualsAndHashCodeWithAllExistingMethods {
|
||||
int x;
|
||||
|
||||
public int hashCode() {
|
||||
return 42;
|
||||
}
|
||||
|
||||
public boolean equals(Object other) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Getter(AccessLevel.NONE)
|
||||
@Setter(lombok.AccessLevel.NONE)
|
||||
class EqualsAndHashCodeWithNoExistingMethods {
|
||||
int x;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user