in core/src/main/java/com/jetbrains/youtrackdb/internal/core/metadata/schema/ImmutableSchemaProperty.java [80:219]
public ImmutableSchemaProperty(@Nonnull DatabaseSessionInternal session,
@Nonnull SchemaPropertyImpl property,
SchemaImmutableClass owner) {
name = property.getName();
fullName = property.getFullName(session);
type = PropertyTypeInternal.convertFromPublicType(property.getType());
description = property.getDescription();
if (property.getLinkedClass(session) != null) {
linkedClassName = property.getLinkedClass(session).getName();
} else {
linkedClassName = null;
}
linkedType = property.getLinkedType();
notNull = property.isNotNull();
collate = property.getCollate();
mandatory = property.isMandatory();
min = property.getMin();
max = property.getMax();
defaultValue = property.getDefaultValue();
regexp = property.getRegexp();
customProperties = new HashMap<String, String>();
for (var key : property.getCustomKeys()) {
customProperties.put(key, property.getCustom(key));
}
this.owner = owner;
id = property.getId();
readOnly = property.isReadonly();
Comparable<Object> minComparable = null;
if (min != null) {
if (type.equals(PropertyTypeInternal.STRING)) {
var conv = safeConvert(session, min, Integer.class, "min");
if (conv != null) {
minComparable = new ValidationStringComparable(conv);
}
} else if (type.equals(PropertyTypeInternal.BINARY)) {
var conv = safeConvert(session, min, Integer.class, "min");
if (conv != null) {
minComparable = new ValidationBinaryComparable(conv);
}
} else if (type.equals(PropertyTypeInternal.DATE)
|| type.equals(PropertyTypeInternal.BYTE)
|| type.equals(PropertyTypeInternal.SHORT)
|| type.equals(PropertyTypeInternal.INTEGER)
|| type.equals(PropertyTypeInternal.LONG)
|| type.equals(PropertyTypeInternal.FLOAT)
|| type.equals(PropertyTypeInternal.DOUBLE)
|| type.equals(PropertyTypeInternal.DECIMAL)
|| type.equals(PropertyTypeInternal.DATETIME)) {
minComparable = (Comparable<Object>) safeConvert(session, min, type.getDefaultJavaType(),
"min");
} else if (type.equals(PropertyTypeInternal.EMBEDDEDLIST)
|| type.equals(PropertyTypeInternal.EMBEDDEDSET)
|| type.equals(PropertyTypeInternal.LINKLIST)
|| type.equals(PropertyTypeInternal.LINKSET)) {
var conv = safeConvert(session, min, Integer.class, "min");
if (conv != null) {
minComparable = new ValidationCollectionComparable(conv);
}
} else if (type.equals(PropertyTypeInternal.LINKBAG)) {
var conv = safeConvert(session, min, Integer.class, "min");
if (conv != null) {
minComparable = new ValidationLinkbagComparable(conv);
}
} else if (type.equals(PropertyTypeInternal.EMBEDDEDMAP) || type.equals(
PropertyTypeInternal.LINKMAP)) {
var conv = safeConvert(session, min, Integer.class, "min");
if (conv != null) {
minComparable = new ValidationMapComparable(conv);
}
}
}
this.minComparable = minComparable;
Comparable<Object> maxComparable = null;
if (max != null) {
if (type.equals(PropertyTypeInternal.STRING)) {
var conv = safeConvert(session, max, Integer.class, "max");
if (conv != null) {
maxComparable = new ValidationStringComparable(conv);
}
} else if (type.equals(PropertyTypeInternal.BINARY)) {
var conv = safeConvert(session, max, Integer.class, "max");
if (conv != null) {
maxComparable = new ValidationBinaryComparable(conv);
}
} else if (type.equals(PropertyTypeInternal.DATE)) {
// This is needed because a date is valid in any time range of the day.
var maxDate = (Date) safeConvert(session, max, type.getDefaultJavaType(), "max");
if (maxDate != null) {
var cal = Calendar.getInstance();
cal.setTime(maxDate);
cal.add(Calendar.DAY_OF_MONTH, 1);
maxDate = new Date(cal.getTime().getTime() - 1);
maxComparable = (Comparable) maxDate;
}
} else if (type.equals(PropertyTypeInternal.BYTE)
|| type.equals(PropertyTypeInternal.SHORT)
|| type.equals(PropertyTypeInternal.INTEGER)
|| type.equals(PropertyTypeInternal.LONG)
|| type.equals(PropertyTypeInternal.FLOAT)
|| type.equals(PropertyTypeInternal.DOUBLE)
|| type.equals(PropertyTypeInternal.DECIMAL)
|| type.equals(PropertyTypeInternal.DATETIME)) {
maxComparable = (Comparable<Object>) safeConvert(session, max, type.getDefaultJavaType(),
"max");
} else if (type.equals(PropertyTypeInternal.EMBEDDEDLIST)
|| type.equals(PropertyTypeInternal.EMBEDDEDSET)
|| type.equals(PropertyTypeInternal.LINKLIST)
|| type.equals(PropertyTypeInternal.LINKSET)) {
var conv = safeConvert(session, max, Integer.class, "max");
if (conv != null) {
maxComparable = new ValidationCollectionComparable(conv);
}
} else if (type.equals(PropertyTypeInternal.LINKBAG)) {
var conv = safeConvert(session, max, Integer.class, "max");
if (conv != null) {
maxComparable = new ValidationLinkbagComparable(conv);
}
} else if (type.equals(PropertyTypeInternal.EMBEDDEDMAP) || type.equals(
PropertyTypeInternal.LINKMAP)) {
var conv = safeConvert(session, max, Integer.class, "max");
if (conv != null) {
maxComparable = new ValidationMapComparable(conv);
}
}
}
this.maxComparable = maxComparable;
this.allIndexes = property.getAllIndexesInternal(session);
}