Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 99b008e14c3736eb75781031854ab25cc19977fd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*******************************************************************************
 * Copyright (c) 2006, 2008 BEA Systems, Inc.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *    sbandow@bea.com - initial API and implementation
 *******************************************************************************/

package org.eclipse.jdt.apt.tests.annotations.exceptionhandling;

import com.sun.mirror.apt.AnnotationProcessorEnvironment;
import com.sun.mirror.declaration.AnnotationTypeDeclaration;
import com.sun.mirror.declaration.Declaration;

import java.util.Collection;
import java.util.Set;

import org.eclipse.jdt.apt.tests.annotations.BaseProcessor;
import org.eclipse.jdt.apt.tests.annotations.ProcessorTestStatus;
import org.eclipse.jdt.apt.tests.annotations.exceptionhandling.ExceptionHandlingAnnotation.EHAEnum;

public class ExceptionHandlingProcessor extends BaseProcessor {  

	private AnnotationTypeDeclaration _annotationType;
    
    public ExceptionHandlingProcessor(Set<AnnotationTypeDeclaration> declarationTypes, AnnotationProcessorEnvironment env) {
        super(env);
        assert declarationTypes.size() == 1;
        _annotationType = declarationTypes.iterator().next();
    }
    
    @SuppressWarnings("unused")
    public void process() {
		ProcessorTestStatus.setProcessorRan();
        Collection<Declaration> declarations = _env.getDeclarationsAnnotatedWith(_annotationType);     
        assert declarations.size() == 1;
        for (Declaration dec : declarations) {
        	ExceptionHandlingAnnotation annotation = dec.getAnnotation(ExceptionHandlingAnnotation.class);
        	boolean booleanValue = annotation.booleanValue();
        	String strValue = annotation.strValue();
        	String[] arrValue = annotation.arrValue();
        	EHAEnum[] enumsValue = annotation.enumsValue();
        }        
	}
}

Back to the top