apoc.meta.tablesforlabels.PropertyTracker Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of apoc-common Show documentation
Show all versions of apoc-common Show documentation
Data types package for Neo4j Procedures
package apoc.meta.tablesforlabels;
import java.util.*;
public class PropertyTracker {
public Set types;
public boolean mandatory;
public long observations;
public long nulls;
public PropertyTracker() {
types = new HashSet<>(3);
mandatory = false;
observations = 0L;
nulls = 0L;
}
public void addObservation(Object value) {
observations++;
if (value == null) { nulls++; }
types.add(assignTypeName(value));
}
private String assignTypeName(Object value) {
String typeName = value.getClass().getCanonicalName();
if (typeMappings.containsKey(typeName)) {
return typeMappings.get(typeName);
}
return typeName.replace("java.lang.", "");
}
public List propertyTypes() {
List ret = new ArrayList<>(types);
Collections.sort(ret);
return ret;
}
public static final Map typeMappings = new HashMap();
static {
typeMappings.put("java.lang.String", "String");
typeMappings.put("java.lang.String[]", "StringArray");
typeMappings.put("java.lang.Double", "Double");
typeMappings.put("java.lang.Double[]", "DoubleArray");
typeMappings.put("double[]", "DoubleArray");
typeMappings.put("java.lang.Integer", "Integer");
typeMappings.put("java.lang.Integer[]", "IntegerArray");
typeMappings.put("int[]", "IntegerArray");
typeMappings.put("java.lang.Long", "Long");
typeMappings.put("java.lang.Long[]", "LongArray");
typeMappings.put("long[]", "LongArray");
typeMappings.put("org.neo4j.values.storable.PointValue", "Point");
typeMappings.put("org.neo4j.values.storable.PointValue[]", "PointArray");
typeMappings.put("java.time.ZonedDateTime", "DateTime");
typeMappings.put("java.time.ZonedDateTime[]", "DateTimeArray");
typeMappings.put("java.lang.Boolean", "Boolean");
typeMappings.put("java.lang.Boolean[]", "BooleanArray");
typeMappings.put("boolean", "Boolean");
typeMappings.put("boolean[]", "BooleanArray");
typeMappings.put("java.time.LocalDate", "Date");
typeMappings.put("java.time.LocalDate[]", "DateArray");
typeMappings.put("java.time.LocalDateTime", "LocalDateTime");
typeMappings.put("java.time.LocalDateTime[]", "LocalDateTimeArray");
typeMappings.put("java.time.LocalTime", "LocalTime");
typeMappings.put("java.time.LocalTime[]", "LocalTimeArray");
typeMappings.put("org.neo4j.values.storable.DurationValue", "Duration");
typeMappings.put("org.neo4j.values.storable.DurationValue[]", "DurationArray");
typeMappings.put("java.time.OffsetTime", "Time");
typeMappings.put("java.time.OffsetTime[]", "TimeArray");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy