com.dslplatform.json.runtime.ReadPropertyInfo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dsl-json-java8 Show documentation
Show all versions of dsl-json-java8 Show documentation
DSL Platform compatible Java JSON library (https://dsl-platform.com)
package com.dslplatform.json.runtime;
import java.util.HashSet;
class ReadPropertyInfo {
public final String name;
public final int hash;
public final boolean exactName;
public final T value;
ReadPropertyInfo(String name, boolean exactName, T value) {
this.name = name;
this.exactName = exactName;
this.value = value;
long hash = 0x811c9dc5;
for (int x = 0; x < name.length(); x++) {
hash ^= (byte) name.charAt(x);
hash *= 0x1000193;
}
this.hash = (int) hash;
}
static ReadPropertyInfo[] prepareReaders(ReadPropertyInfo[] initial) {
final ReadPropertyInfo[] readers = initial.clone();
final HashSet hashes = new HashSet();
for (final ReadPropertyInfo ri : readers) {
if (!hashes.add(ri.hash)) {
for (int j = 0; j < readers.length; j++) {
final ReadPropertyInfo si = readers[j];
if (si.hash == ri.hash && !si.exactName) {
readers[j] = new ReadPropertyInfo<>(ri.name, true, ri.value);
}
}
}
}
return readers;
}
}