mirror of
https://github.com/SKCraft/Launcher.git
synced 2024-11-24 12:16:28 +01:00
Change equals & hash code calculation for libraries
The two methods actually agree with each other now
This commit is contained in:
parent
f880192919
commit
9aced19edc
@ -13,6 +13,8 @@ import com.google.common.base.Splitter;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.skcraft.launcher.util.Environment;
|
import com.skcraft.launcher.util.Environment;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||||
|
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -122,19 +124,25 @@ public class Library {
|
|||||||
|
|
||||||
Library library = (Library) o;
|
Library library = (Library) o;
|
||||||
|
|
||||||
if (name != null ? !name.equals(library.name) : library.name != null)
|
EqualsBuilder builder = new EqualsBuilder();
|
||||||
return false;
|
builder.append(name, library.getName());
|
||||||
|
|
||||||
// If libraries have different natives lists, they should be separate.
|
// If libraries have different natives lists, they should be separate.
|
||||||
if (natives != null ? !natives.equals(library.natives) : library.natives != null)
|
builder.append(natives, library.getNatives());
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
return builder.isEquals();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return name != null ? name.hashCode() : 0;
|
HashCodeBuilder builder = new HashCodeBuilder(45, 23);
|
||||||
|
|
||||||
|
if (name != null)
|
||||||
|
builder.append(name);
|
||||||
|
|
||||||
|
if (natives != null)
|
||||||
|
builder.append(natives);
|
||||||
|
|
||||||
|
return builder.toHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
Loading…
Reference in New Issue
Block a user