mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-17 22:47:34 +01:00
Improvements to BookMeta API
* Added hasGeneration() * Fixed `applyHash()` (used by `CraftMetaItem.hashCode()`) not taking generation into account * Fixed `equalsCommon()` (used by `CraftMetaItem.equals()`) not taking generation into account
This commit is contained in:
parent
02f4218da5
commit
9856d8a183
@ -175,6 +175,10 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
||||
return !pages.isEmpty();
|
||||
}
|
||||
|
||||
public boolean hasGeneration() {
|
||||
return generation != null;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
@ -292,6 +296,9 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
||||
if (hasPages()) {
|
||||
hash = 61 * hash + 17 * this.pages.hashCode();
|
||||
}
|
||||
if (hasGeneration()) {
|
||||
hash = 61 * hash + 19 * this.generation.hashCode();
|
||||
}
|
||||
return original != hash ? CraftMetaBook.class.hashCode() ^ hash : hash;
|
||||
}
|
||||
|
||||
@ -305,7 +312,8 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
||||
|
||||
return (hasTitle() ? that.hasTitle() && this.title.equals(that.title) : !that.hasTitle())
|
||||
&& (hasAuthor() ? that.hasAuthor() && this.author.equals(that.author) : !that.hasAuthor())
|
||||
&& (hasPages() ? that.hasPages() && this.pages.equals(that.pages) : !that.hasPages());
|
||||
&& (hasPages() ? that.hasPages() && this.pages.equals(that.pages) : !that.hasPages())
|
||||
&& (hasGeneration() ? that.hasGeneration() && this.generation.equals(that.generation) : !that.hasGeneration());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user