![JAR search and dependency download from the Maven repository](/logo.png)
com.github.devnied.emvnfccard.parser.apdu.annotation.AnnotationUtils Maven / Gradle / Ivy
package com.github.devnied.emvnfccard.parser.apdu.annotation;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import com.github.devnied.emvnfccard.iso7816emv.ITag;
import com.github.devnied.emvnfccard.model.EmvTransactionRecord;
import com.github.devnied.emvnfccard.parser.apdu.IFile;
/**
* Class used to manage all annotation
*
* @author MILLAU Julien
*
*/
public final class AnnotationUtils {
/**
* List of annoted class
*/
@SuppressWarnings("unchecked")
private static final Class extends IFile>[] LISTE_CLASS = new Class[] { EmvTransactionRecord.class };
/**
* AnnotationUtils singleton
*/
private static final AnnotationUtils INSTANCE = new AnnotationUtils();
/**
* Method to get the unique instance of the class
*
* @return AnnotationUtils instance
*/
public static AnnotationUtils getInstance() {
return INSTANCE;
}
/**
* Map which contain
*/
private final Map> map;
private final Map> mapSet;
/**
* Private default constructor
*/
private AnnotationUtils() {
map = new HashMap>();
mapSet = new HashMap>();
extractAnnotation();
}
/**
* Method to extract all annotation information and store them in the map
*/
private void extractAnnotation() {
for (Class extends IFile> clazz : LISTE_CLASS) {
Map maps = new HashMap();
Set set = new TreeSet();
Field[] fields = clazz.getDeclaredFields();
for (Field field : fields) {
AnnotationData param = new AnnotationData();
field.setAccessible(true);
param.setField(field);
Data annotation = field.getAnnotation(Data.class);
if (annotation != null) {
param.initFromAnnotation(annotation);
maps.put(param.getTag(), param);
try {
set.add((AnnotationData) param.clone());
} catch (CloneNotSupportedException e) {
// do nothing
}
}
}
mapSet.put(clazz.getName(), set);
map.put(clazz.getName(), maps);
}
}
/**
* Getter map set
*
* @return the map
*/
public Map> getMapSet() {
return mapSet;
}
/**
* Getter map
*
* @return the map
*/
public Map> getMap() {
return map;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy