Search in sources :

Example 1 with ExecNodeMetadata

use of org.apache.flink.table.planner.plan.nodes.exec.ExecNodeMetadata in project flink by apache.

the class ExecNodeMetadataUtil method extractMetadataFromAnnotation.

private static <T extends ExecNode<?>> List<ExecNodeMetadata> extractMetadataFromAnnotation(Class<T> execNodeClass) {
    List<ExecNodeMetadata> metadata = new ArrayList<>();
    ExecNodeMetadata annotation = execNodeClass.getDeclaredAnnotation(ExecNodeMetadata.class);
    if (annotation != null) {
        metadata.add(annotation);
    }
    MultipleExecNodeMetadata annotations = execNodeClass.getDeclaredAnnotation(MultipleExecNodeMetadata.class);
    if (annotations != null) {
        if (metadata.isEmpty()) {
            for (ExecNodeMetadata annot : annotations.value()) {
                if (annot != null) {
                    metadata.add(annot);
                }
            }
        } else {
            throw new IllegalStateException(String.format("ExecNode: %s is annotated both with %s and %s. Please use only " + "%s or multiple %s", execNodeClass.getCanonicalName(), ExecNodeMetadata.class, MultipleExecNodeMetadata.class, MultipleExecNodeMetadata.class, ExecNodeMetadata.class));
        }
    }
    return metadata;
}
Also used : MultipleExecNodeMetadata(org.apache.flink.table.planner.plan.nodes.exec.MultipleExecNodeMetadata) ArrayList(java.util.ArrayList) MultipleExecNodeMetadata(org.apache.flink.table.planner.plan.nodes.exec.MultipleExecNodeMetadata) ExecNodeMetadata(org.apache.flink.table.planner.plan.nodes.exec.ExecNodeMetadata)

Aggregations

ArrayList (java.util.ArrayList)1 ExecNodeMetadata (org.apache.flink.table.planner.plan.nodes.exec.ExecNodeMetadata)1 MultipleExecNodeMetadata (org.apache.flink.table.planner.plan.nodes.exec.MultipleExecNodeMetadata)1