use of io.strimzi.crdgenerator.annotations.Example 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;
}
use of io.strimzi.crdgenerator.annotations.Example 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;
}
Aggregations