Fix hashcodes
This commit is contained in:
parent
81762197bb
commit
320ec98cab
@ -31,6 +31,9 @@ public class ClassConfiguration {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(stringRepresenter, data);
|
||||
int hash = 0;
|
||||
hash += ConfigUtils.hashCode(stringRepresenter);
|
||||
hash += ConfigUtils.hashCode(data);
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
26
src/main/java/it/cavallium/data/generator/ConfigUtils.java
Normal file
26
src/main/java/it/cavallium/data/generator/ConfigUtils.java
Normal file
@ -0,0 +1,26 @@
|
||||
package it.cavallium.data.generator;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
class ConfigUtils {
|
||||
|
||||
static int hashCode(Map<?, ?> map) {
|
||||
if (map == null) return 0;
|
||||
return map
|
||||
.entrySet()
|
||||
.stream()
|
||||
.map(e -> ConfigUtils.hashCode(e.getKey()) + ConfigUtils.hashCode(e.getValue()))
|
||||
.reduce(0, Integer::sum);
|
||||
}
|
||||
|
||||
static int hashCode(Collection<?> collection) {
|
||||
if (collection == null) return 0;
|
||||
return collection.stream().map(ConfigUtils::hashCode).reduce(0, Integer::sum);
|
||||
}
|
||||
|
||||
static int hashCode(Object collection) {
|
||||
return Objects.hashCode(collection);
|
||||
}
|
||||
}
|
@ -45,6 +45,9 @@ public class CustomTypesConfiguration {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(javaClass, serializer);
|
||||
int hash = 0;
|
||||
hash += ConfigUtils.hashCode(javaClass);
|
||||
hash += ConfigUtils.hashCode(serializer);
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,8 @@ public class DetailsConfiguration {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(changelog);
|
||||
int hash = 0;
|
||||
hash += ConfigUtils.hashCode(changelog);
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,10 @@ public class InterfaceDataConfiguration {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(extendInterfaces, commonData, commonGetters);
|
||||
int hash = 0;
|
||||
hash += ConfigUtils.hashCode(extendInterfaces);
|
||||
hash += ConfigUtils.hashCode(commonData);
|
||||
hash += ConfigUtils.hashCode(commonGetters);
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,10 @@ public class MoveDataConfiguration implements TransformationConfiguration {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(transformClass, from, to);
|
||||
int hash = 0;
|
||||
hash += ConfigUtils.hashCode(transformClass);
|
||||
hash += ConfigUtils.hashCode(from);
|
||||
hash += ConfigUtils.hashCode(to);
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,10 @@ public class NewDataConfiguration implements TransformationConfiguration {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(transformClass, to, initializer);
|
||||
int hash = 0;
|
||||
hash += ConfigUtils.hashCode(transformClass);
|
||||
hash += ConfigUtils.hashCode(to);
|
||||
hash += ConfigUtils.hashCode(initializer);
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,9 @@ public class RemoveDataConfiguration implements TransformationConfiguration {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(transformClass, from);
|
||||
int hash = 0;
|
||||
hash += ConfigUtils.hashCode(transformClass);
|
||||
hash += ConfigUtils.hashCode(from);
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,10 @@ public class SerializeCodeBlockGenerator {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(before, after);
|
||||
int hash = 0;
|
||||
hash += ConfigUtils.hashCode(before);
|
||||
hash += ConfigUtils.hashCode(after);
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
||||
|
@ -24,6 +24,11 @@ public class SourcesGeneratorConfiguration {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(currentVersion, interfacesData, versions, refs);
|
||||
int hash = 0;
|
||||
hash += ConfigUtils.hashCode(currentVersion);
|
||||
hash += ConfigUtils.hashCode(interfacesData);
|
||||
hash += ConfigUtils.hashCode(versions);
|
||||
hash += ConfigUtils.hashCode(refs);
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,11 @@ public class SourcesGeneratorConfigurationRefs {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(superTypes, customTypes, classes, transformations);
|
||||
int hash = 0;
|
||||
hash += ConfigUtils.hashCode(superTypes);
|
||||
hash += ConfigUtils.hashCode(customTypes);
|
||||
hash += ConfigUtils.hashCode(classes);
|
||||
hash += ConfigUtils.hashCode(transformations);
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,10 @@ public class UpgradeDataConfiguration implements TransformationConfiguration {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(transformClass, from, upgrader);
|
||||
int hash = 0;
|
||||
hash += ConfigUtils.hashCode(transformClass);
|
||||
hash += ConfigUtils.hashCode(from);
|
||||
hash += ConfigUtils.hashCode(upgrader);
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,12 @@ public class VersionConfiguration {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(details, superTypes, customTypes, classes, transformations);
|
||||
int hash = 0;
|
||||
hash += ConfigUtils.hashCode(details);
|
||||
hash += ConfigUtils.hashCode(superTypes);
|
||||
hash += ConfigUtils.hashCode(customTypes);
|
||||
hash += ConfigUtils.hashCode(classes);
|
||||
hash += ConfigUtils.hashCode(transformations);
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
@ -79,6 +79,11 @@ public class VersionTransformation {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(moveData, removeData, upgradeData, newData);
|
||||
int hash = 0;
|
||||
hash += ConfigUtils.hashCode(moveData);
|
||||
hash += ConfigUtils.hashCode(removeData);
|
||||
hash += ConfigUtils.hashCode(upgradeData);
|
||||
hash += ConfigUtils.hashCode(newData);
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user