Skip to content

Commit 5481f9e

Browse files
committed
Address reviewer comments
1 parent dcacd32 commit 5481f9e

2 files changed

Lines changed: 10 additions & 12 deletions

File tree

  • hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema
  • hugegraph-struct/src/main/java/org/apache/hugegraph/struct/schema

hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema/PropertyKey.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,13 @@ public Object defaultValue() {
130130
// value (e.g. Date) comes back as a String. Normalize it to the
131131
// runtime type expected by this property key's data type. Idempotent
132132
// for values already of the expected type.
133-
Object normalized = this.validValueOrThrow(value);
134-
135-
// For SET cardinality, ensure we return a Set container and collapse duplicates
136-
if (this.cardinality == Cardinality.SET && normalized instanceof Collection) {
137-
return new LinkedHashSet<>((Collection<?>) normalized);
133+
Object raw = value;
134+
if (this.cardinality == Cardinality.SET && value instanceof Collection &&
135+
!(value instanceof Set)) {
136+
raw = new LinkedHashSet<>((Collection<?>) value);
138137
}
139138

140-
return normalized;
139+
return this.validValueOrThrow(raw);
141140
}
142141

143142
public boolean hasSameContent(PropertyKey other) {

hugegraph-struct/src/main/java/org/apache/hugegraph/struct/schema/PropertyKey.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,13 @@ public Object defaultValue() {
135135
// value (e.g. Date) comes back as a String. Normalize it to the
136136
// runtime type expected by this property key's data type. Idempotent
137137
// for values already of the expected type.
138-
Object normalized = this.validValueOrThrow(value);
139-
140-
// For SET cardinality, ensure we return a Set container and collapse duplicates
141-
if (this.cardinality == Cardinality.SET && normalized instanceof Collection) {
142-
return new LinkedHashSet<>((Collection<?>) normalized);
138+
Object raw = value;
139+
if (this.cardinality == Cardinality.SET && value instanceof Collection &&
140+
!(value instanceof Set)) {
141+
raw = new LinkedHashSet<>((Collection<?>) value);
143142
}
144143

145-
return normalized;
144+
return this.validValueOrThrow(raw);
146145
}
147146

148147
public boolean hasSameContent(PropertyKey other) {

0 commit comments

Comments
 (0)