Search in sources :

Example 1 with AdvancedOption

use of edu.uci.ics.texera.dataflow.annotation.AdvancedOption in project textdb by TextDB.

the class JsonSchemaHelper method getAdvancedOptionProperties.

public static List<String> getAdvancedOptionProperties(Class<? extends PredicateBase> predicateClass) {
    ArrayList<String> advancedProperties = new ArrayList<>();
    Constructor<?> constructor = getJsonCreatorConstructor(predicateClass);
    for (Annotation[] annotations : Arrays.asList(constructor.getParameterAnnotations())) {
        // find the @AdvancedOption annotation for each parameter
        Optional<Annotation> findAdvancedOptionAnnotation = Arrays.asList(annotations).stream().filter(annotation -> annotation.annotationType().equals(AdvancedOption.class)).findAny();
        if (!findAdvancedOptionAnnotation.isPresent()) {
            continue;
        }
        AdvancedOption advancedOptionAnnotation = (AdvancedOption) findAdvancedOptionAnnotation.get();
        // find the @JsonProperty annotation
        Optional<Annotation> findJsonProperty = Arrays.asList(annotations).stream().filter(annotation -> annotation.annotationType().equals(JsonProperty.class)).findAny();
        if (!findJsonProperty.isPresent()) {
            continue;
        }
        JsonProperty jsonProperty = (JsonProperty) findJsonProperty.get();
        if (advancedOptionAnnotation.isAdvancedOption()) {
            advancedProperties.add(jsonProperty.value());
        }
    }
    return advancedProperties;
}
Also used : JsonProperty(com.fasterxml.jackson.annotation.JsonProperty) java.util(java.util) OperatorArityConstants(edu.uci.ics.texera.dataflow.plangen.OperatorArityConstants) Files(java.nio.file.Files) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonSchema(com.fasterxml.jackson.module.jsonSchema.JsonSchema) TexeraException(edu.uci.ics.texera.api.exception.TexeraException) Constructor(java.lang.reflect.Constructor) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) AnnotatedClass(com.fasterxml.jackson.databind.introspect.AnnotatedClass) Utils(edu.uci.ics.texera.api.utils.Utils) JsonSchemaGenerator(com.fasterxml.jackson.module.jsonSchema.JsonSchemaGenerator) Annotation(java.lang.annotation.Annotation) JsonCreator(com.fasterxml.jackson.annotation.JsonCreator) NamedType(com.fasterxml.jackson.databind.jsontype.NamedType) AdvancedOption(edu.uci.ics.texera.dataflow.annotation.AdvancedOption) JsonNode(com.fasterxml.jackson.databind.JsonNode) DataConstants(edu.uci.ics.texera.api.constants.DataConstants) Path(java.nio.file.Path) JsonProperty(com.fasterxml.jackson.annotation.JsonProperty) AdvancedOption(edu.uci.ics.texera.dataflow.annotation.AdvancedOption) Annotation(java.lang.annotation.Annotation)

Aggregations

JsonCreator (com.fasterxml.jackson.annotation.JsonCreator)1 JsonProperty (com.fasterxml.jackson.annotation.JsonProperty)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 AnnotatedClass (com.fasterxml.jackson.databind.introspect.AnnotatedClass)1 NamedType (com.fasterxml.jackson.databind.jsontype.NamedType)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 JsonSchema (com.fasterxml.jackson.module.jsonSchema.JsonSchema)1 JsonSchemaGenerator (com.fasterxml.jackson.module.jsonSchema.JsonSchemaGenerator)1 DataConstants (edu.uci.ics.texera.api.constants.DataConstants)1 TexeraException (edu.uci.ics.texera.api.exception.TexeraException)1 Utils (edu.uci.ics.texera.api.utils.Utils)1 AdvancedOption (edu.uci.ics.texera.dataflow.annotation.AdvancedOption)1 OperatorArityConstants (edu.uci.ics.texera.dataflow.plangen.OperatorArityConstants)1 Annotation (java.lang.annotation.Annotation)1 Constructor (java.lang.reflect.Constructor)1 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1 java.util (java.util)1