private void checkAggregateType()

in hugegraph-core/src/main/java/org/apache/hugegraph/schema/builder/PropertyKeyBuilder.java [404:439]


    private void checkAggregateType() {
        if (this.aggregateType.isNone()) {
            return;
        }

        if (this.aggregateType.isSet() &&
            this.cardinality == Cardinality.SET ||
            this.aggregateType.isList() &&
            this.cardinality == Cardinality.LIST) {
            return;
        }

        if (this.cardinality != Cardinality.SINGLE ||
            this.aggregateType.isUnion()) {
            throw new NotAllowException("Not allowed to set aggregate type " +
                                        "'%s' for property key '%s' with " +
                                        "cardinality '%s'",
                                        this.aggregateType, this.name,
                                        this.cardinality);
        }

        if (this.aggregateType.isSum() && this.dataType.isDate()) {
            throw new NotAllowException(
                      "Not allowed to set aggregate type '%s' for " +
                      "property key '%s' with data type '%s'",
                      this.aggregateType, this.name, this.dataType);
        }

        if (this.aggregateType.isNumber() &&
            !this.dataType.isNumber() && !this.dataType.isDate()) {
            throw new NotAllowException(
                      "Not allowed to set aggregate type '%s' for " +
                      "property key '%s' with data type '%s'",
                      this.aggregateType, this.name, this.dataType);
        }
    }