You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Have you considered adding the @Singular and @EqualsAndHashCode annotations to the Property and WeaviateClass (and other objects that perform similar roles)?
You could use the following code as an example:
packageio.weaviate.client.v1.schema.model;
@Getter@Builder@ToString@EqualsAndHashCode// <--- like this@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
publicclassProperty {
@Singular// <--- like thisList<String> dataType;
}
@Getter@Builder@ToString@EqualsAndHashCode// <--- like this@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
publicclassWeaviateClass {
@Singular// <--- like thisList<Property> properties;
}
By using the @Singular annotation, you can use the following code:
classTest {
voidtest() {
Property.builder()
.dataType("string")
.dataType("number")
.build();
WeaviateClass
.builder()
.property(Property.builder().dataType("string").build())
.property(Property.builder().dataType("number").build())
.build();
// and Can use thisWeaviateClass
.builder()
.properties(List.of(
Property.builder().dataType("string").build(),
Property.builder().dataType("number").build()
))
.build();
}
}
The text was updated successfully, but these errors were encountered:
Indeed @EqualsAndHashCode annotation is missing in multiple data classes. We will add it soon.
As for @Singular annotation: it definitely is a nice feature and makes interface simpler and easier to use, though in our case it would be considered as breaking change.
Builder will use the same method name for providing collection to its instance (properties in your example), but its behaviour will change. Instead of setting/replacing builder's collection with provided one, with @Singular in place it will copy elements from provided collection to builder's one.
If builder is reused to create multiple instances of data classes, collections fields may contain much more elements than user intended to put. clearXYZ (clearProperties in your example) method would have to be called before setter to prevent mentioned scenario to happen.
We may add @Singular support in the future along with other breaking change features and create proper migration guide.
Have you considered adding the @Singular and @EqualsAndHashCode annotations to the Property and WeaviateClass (and other objects that perform similar roles)?
You could use the following code as an example:
By using the @Singular annotation, you can use the following code:
The text was updated successfully, but these errors were encountered: