/** * Method to read and object from the bytes tab * * @param pAnnotation all information data * @param pBit bytes tab * @return an object */ public static Object getObject(final AnnotationData pAnnotation, final BitUtils pBit) { Object obj = null; Class<?> clazz = pAnnotation.getField().getType(); if (clazz.equals(Integer.class)) { obj = getInteger(pAnnotation, pBit); } else if (clazz.equals(Float.class)) { obj = getFloat(pAnnotation, pBit); } else if (clazz.equals(String.class)) { obj = getString(pAnnotation, pBit); } else if (clazz.equals(Date.class)) { obj = getDate(pAnnotation, pBit); } else if (clazz.equals(Boolean.class)) { obj = pBit.getNextBoolean(); } else if (clazz.isEnum()) { obj = getEnum(pAnnotation, pBit); } return obj; }
/** * This method is used to get an enum with his key * * @param pAnnotation annotation * @param pBit bit array */ @SuppressWarnings("unchecked") private static IKeyEnum getEnum(final AnnotationData pAnnotation, final BitUtils pBit) { int val = Integer.parseInt(pBit.getNextHexaString(pAnnotation.getSize())); return EnumUtils.getValue(val, (Class<? extends IKeyEnum>) pAnnotation.getField().getType()); }