public AnnotationProcessor()

in src/main/java/com/amazonaws/services/kinesis/aggregators/annotations/AnnotationProcessor.java [89:180]


    public AnnotationProcessor(@SuppressWarnings("rawtypes") Class clazz) throws Exception {
        this.clazz = clazz;
        boolean isAnnotated = false;

        // get the class annotations
        for (Annotation a : this.clazz.getAnnotations()) {
            if (a.annotationType().equals(Aggregate.class)) {
                isAnnotated = true;

                Aggregate annotatedObject = (Aggregate) a;
                this.namespace = annotatedObject.namespace();
                if (this.namespace.contains(" "))
                    throw new ClassNotAnnotatedException("Namespace may not contain spaces");

                this.type = annotatedObject.type();

                // process time horizon annotations
                int[] timeGranularities = annotatedObject.timeGranularity();
                TimeHorizon[] horizons = annotatedObject.timeHorizons();
                this.timeHorizons = new ArrayList<>();
                int i = 0;
                for (TimeHorizon h : horizons) {
                    if (h.equals(TimeHorizon.MINUTES_GROUPED)) {
                        try {
                            // prevent use of the default time granularity
                            if (timeGranularities[i] == -1) {
                                throw new ArrayIndexOutOfBoundsException();
                            }
                            h.setGranularity(timeGranularities[i]);
                        } catch (ArrayIndexOutOfBoundsException e) {
                            throw new InvalidConfigurationException(
                                    "Unable to generate a MINUTES_GROUPED Time Horizon without configuration of timeGranularity");
                        }
                    }
                    this.timeHorizons.add(h);
                    i++;
                }

                this.failOnDataExtractionErrors = annotatedObject.failOnDataExtractionErrors();

                this.emitMetrics = annotatedObject.emitMetrics();

                this.dataStore = annotatedObject.dataStore();

                this.metricsEmitter = annotatedObject.metricsEmitter();
            }
        }

        if (!isAnnotated)
            throw new ClassNotAnnotatedException(
                    "Cannot get Aggregator Config from non-Annotated Class");

        // process the method annotations
        if (isAnnotated) {
            for (Method m : this.clazz.getDeclaredMethods()) {
                // label method
                if (m.getAnnotation(Label.class) != null) {
                    this.labelMethodNames.add(m.getName());
                    m.setAccessible(true);
                    this.labelMethodMap.put(m.getName(), m);

                    this.labelSet.put(m.getName(), null);
                }

                // date method
                if (m.getAnnotation(DateValue.class) != null) {
                    this.dateMethodName = m.getName();
                    m.setAccessible(true);
                    this.dateMethod = m;
                }

                // summary methods
                Annotation summary = m.getAnnotation(Summary.class);
                if (summary != null) {
                    m.setAccessible(true);
                    this.summaryMethods.put(m.getName(), m);

                    // process the summary configuration
                    SummaryCalculation[] requestedCalcs = ((Summary) summary).type();

                    if (requestedCalcs != null) {
                        for (SummaryCalculation c : requestedCalcs) {
                            this.summaryConfig.add(m.getName(), new SummaryElement(m.getName(), c));
                        }
                    } else {
                        this.summaryConfig.add(m.getName(), new SummaryElement(m.getName(),
                                SummaryCalculation.SUM));
                    }
                }
            }
        }
    }