Search in sources :

Example 1 with Pattern

use of io.strimzi.crdgenerator.annotations.Pattern in project strimzi by strimzi.

the class CrdGenerator method addSimpleTypeConstraints.

@SuppressWarnings("unchecked")
private ObjectNode addSimpleTypeConstraints(ApiVersion crApiVersion, ObjectNode result, Property property) {
    Example example = property.getAnnotation(Example.class);
    // TODO make support versions
    if (example != null) {
        result.put("example", example.value());
    }
    Minimum minimum = selectVersion(crApiVersion, property, Minimum.class);
    if (minimum != null) {
        result.put("minimum", minimum.value());
    }
    Maximum maximum = selectVersion(crApiVersion, property, Maximum.class);
    if (maximum != null) {
        result.put("maximum", maximum.value());
    }
    Pattern first = selectVersion(crApiVersion, property, Pattern.class);
    if (first != null) {
        result.put("pattern", first.value());
    }
    if (property.getType().isEnum()) {
        result.set("enum", enumCaseArray(property.getType().getEnumElements()));
    }
    if (property.getDeclaringClass().isAnnotationPresent(JsonTypeInfo.class) && property.getName().equals(property.getDeclaringClass().getAnnotation(JsonTypeInfo.class).property())) {
        result.set("enum", stringArray(Property.subtypeNames(property.getDeclaringClass())));
    }
    return result;
}
Also used : Pattern(io.strimzi.crdgenerator.annotations.Pattern) Minimum(io.strimzi.crdgenerator.annotations.Minimum) Maximum(io.strimzi.crdgenerator.annotations.Maximum) Example(io.strimzi.crdgenerator.annotations.Example) JsonTypeInfo(com.fasterxml.jackson.annotation.JsonTypeInfo)

Example 2 with Pattern

use of io.strimzi.crdgenerator.annotations.Pattern in project strimzi-kafka-operator by strimzi.

the class CrdGenerator method addSimpleTypeConstraints.

@SuppressWarnings("unchecked")
private ObjectNode addSimpleTypeConstraints(ApiVersion crApiVersion, ObjectNode result, Property property) {
    Example example = property.getAnnotation(Example.class);
    // TODO make support versions
    if (example != null) {
        result.put("example", example.value());
    }
    Minimum minimum = selectVersion(crApiVersion, property, Minimum.class);
    if (minimum != null) {
        result.put("minimum", minimum.value());
    }
    Maximum maximum = selectVersion(crApiVersion, property, Maximum.class);
    if (maximum != null) {
        result.put("maximum", maximum.value());
    }
    Pattern first = selectVersion(crApiVersion, property, Pattern.class);
    if (first != null) {
        result.put("pattern", first.value());
    }
    if (property.getType().isEnum()) {
        result.set("enum", enumCaseArray(property.getType().getEnumElements()));
    }
    if (property.getDeclaringClass().isAnnotationPresent(JsonTypeInfo.class) && property.getName().equals(property.getDeclaringClass().getAnnotation(JsonTypeInfo.class).property())) {
        result.set("enum", stringArray(Property.subtypeNames(property.getDeclaringClass())));
    }
    return result;
}
Also used : Pattern(io.strimzi.crdgenerator.annotations.Pattern) Minimum(io.strimzi.crdgenerator.annotations.Minimum) Maximum(io.strimzi.crdgenerator.annotations.Maximum) Example(io.strimzi.crdgenerator.annotations.Example) JsonTypeInfo(com.fasterxml.jackson.annotation.JsonTypeInfo)

Aggregations

JsonTypeInfo (com.fasterxml.jackson.annotation.JsonTypeInfo)2 Example (io.strimzi.crdgenerator.annotations.Example)2 Maximum (io.strimzi.crdgenerator.annotations.Maximum)2 Minimum (io.strimzi.crdgenerator.annotations.Minimum)2 Pattern (io.strimzi.crdgenerator.annotations.Pattern)2