Source:
<code>protected List<OptionalParameter> createOptionalParametersByName(Map<String, String> optinalParamaters) { List<OptionalParameter> optParams = new ArrayList<OptionalParameter>(); for (Entry<String, String> entry : optinalParamaters.entrySet()) { OptionalParameter optParam = null; String value = entry.getValue(); try { Tag tag = Tag.valueOf(entry.getKey()); Class type = determineTypeClass(tag); Class superclass = type.getSuperclass(); <START> Class supersuperclass = superclass.getSuperclass(); <END> Set<Class> classes = new HashSet<Class>(Arrays.asList(superclass, supersuperclass)); if (classes.contains(OctetString.class)) { optParam = (OptionalParameter) type.getConstructor(byte[].class).newInstance(value.getBytes()); } else if (classes.contains(OptionalParameter.Byte.class)) { Byte byteValue = (value == null) ? 0 : Byte.valueOf(value); optParam = (OptionalParameter) type.getConstructor(byte.class).newInstance(byteValue); } else if (classes.contains(OptionalParameter.Int.class)) { Integer intValue = (value == null) ? 0 : Integer.valueOf(value); optParam = (OptionalParameter) type.getConstructor(int.class).newInstance(intValue); } else if (classes.contains(OptionalParameter.Short.class)) { Short shortValue = (value == null) ? 0 : Short.valueOf(value); optParam = (OptionalParameter) type.getConstructor(short.class).newInstance(shortValue); } optParams.add(optParam); } catch (Exception e) { log.info("Couldn't determine optional parameter for key and value {}. Skip this one.", entry.getKey(), value); } } return optParams; }</code><technical_language>If super class is java.lang.Object a super class. I need a check for that</technical_language>

Target:
protected List<OptionalParameter> createOptionalParametersByName(Map<String, String> optinalParamaters) { List<OptionalParameter> optParams = new ArrayList<OptionalParameter>(); for (Entry<String, String> entry : optinalParamaters.entrySet()) { OptionalParameter optParam = null; String value = entry.getValue(); try { Tag tag = Tag.valueOf(entry.getKey()); Class type = determineTypeClass(tag); Set<Class> ancestorClasses = new HashSet<Class>(2); Class superclass = type.getSuperclass(); ancestorClasses.add(superclass); if (superclass != Object.class) { ancestorClasses.add(superclass.getSuperclass()); } if (ancestorClasses.contains(OctetString.class)) { optParam = (OptionalParameter) type.getConstructor(byte[].class).newInstance(value.getBytes()); } else if (ancestorClasses.contains(OptionalParameter.Byte.class)) { Byte byteValue = (value == null) ? 0 : Byte.valueOf(value); optParam = (OptionalParameter) type.getConstructor(byte.class).newInstance(byteValue); } else if (ancestorClasses.contains(OptionalParameter.Int.class)) { Integer intValue = (value == null) ? 0 : Integer.valueOf(value); optParam = (OptionalParameter) type.getConstructor(int.class).newInstance(intValue); } else if (ancestorClasses.contains(OptionalParameter.Short.class)) { Short shortValue = (value == null) ? 0 : Short.valueOf(value); optParam = (OptionalParameter) type.getConstructor(short.class).newInstance(shortValue); } optParams.add(optParam); } catch (Exception e) { log.info("Couldn't determine optional parameter for key and value {}. Skip this one.", entry.getKey(), value); } } return optParams; }