Program: 13352
Project: 13352
Buggy source:
/** 
 * Coerce the   {@code source} object to an object of {@code clazz} type.<p/>
 * @param < T >
 * @param source
 * @param clazz
 * @return
 * @throws NumberFormatException
 * @throws URISyntaxException
 * @throws UnsupportedOperationException
 */
@SuppressWarnings("String_Node_Str") public static <T>T coercedTypeCasting(Object source,Class<T> clazz) throws IllegalArgumentException {
  if (null == clazz) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Class<T> targetClazz=clazz;
  Class sourceClass=(source == null ? null : source.getClass());
  boolean coerced=false;
  T result=null;
  try {
    if (source == null) {
      return null;
    }
    if (targetClazz.equals(Object.class)) {
      if ((Number.class.isAssignableFrom(sourceClass)) || (int.class == clazz) || (double.class == clazz)|| (float.class == clazz)|| (long.class == clazz)) {
        return (T)source;
      }
 else       if ((Boolean.class.isAssignableFrom(sourceClass)) || (boolean.class == clazz)) {
        return (T)source;
      }
 else       if (String.class.isAssignableFrom(sourceClass)) {
        return (T)source;
      }
 else       if (Map.class.isAssignableFrom(sourceClass)) {
        return (T)source;
      }
 else       if (List.class.isAssignableFrom(sourceClass)) {
        return (T)source;
      }
 else       if (sourceClass == QualifiedUid.class) {
        Map<String,Object> v=new HashMap<String,Object>(2);
        v.put("String_Node_Str",((QualifiedUid)source).getUid().getUidValue());
        v.put("String_Node_Str",((QualifiedUid)source).getObjectClass().getObjectClassValue());
        return (T)v;
      }
 else       if (sourceClass == Script.class) {
        Map<String,Object> v=new HashMap<String,Object>(2);
        v.put("String_Node_Str",((Script)source).getScriptLanguage());
        v.put("String_Node_Str",((Script)source).getScriptText());
        return (T)v;
      }
 else {
        targetClazz=(Class<T>)String.class;
      }
    }
    if (targetClazz.isAssignableFrom(sourceClass)) {
      return (T)source;
    }
 else     if (targetClazz == sourceClass) {
      return (T)source;
    }
 else     if (targetClazz.equals(java.math.BigDecimal.class)) {
      if (Double.class.isAssignableFrom(sourceClass) || sourceClass == double.class) {
        result=(T)BigDecimal.valueOf((Double)source);
        coerced=true;
      }
 else       if (Integer.class.isAssignableFrom(sourceClass) || sourceClass == int.class) {
        result=(T)BigDecimal.valueOf((Integer)source);
        coerced=true;
      }
 else       if (Long.class.isAssignableFrom(sourceClass) || sourceClass == long.class) {
        result=(T)BigDecimal.valueOf((Long)source);
        coerced=true;
      }
 else       if (sourceClass == String.class) {
        java.math.BigDecimal v=new java.math.BigDecimal((String)source);
        result=targetClazz.cast(v);
        coerced=true;
      }
    }
 else     if (targetClazz.equals(java.math.BigInteger.class)) {
      if (Long.class.isAssignableFrom(sourceClass) || sourceClass == long.class) {
        result=(T)BigInteger.valueOf((Long)source);
        coerced=true;
      }
 else       if (sourceClass == String.class) {
        java.math.BigInteger v=new java.math.BigInteger((String)source);
        result=targetClazz.cast(v);
        coerced=true;
      }
 else {
        result=(T)BigInteger.valueOf(coercedTypeCasting(source,Long.class));
        coerced=true;
      }
    }
 else     if (targetClazz.equals(boolean.class) || targetClazz.equals(Boolean.class)) {
      if (sourceClass == Boolean.class) {
        result=(T)source;
        coerced=true;
      }
 else       if (sourceClass == Integer.class) {
        int val=((Integer)source).intValue();
        if (val == 0) {
          result=targetClazz.cast(Boolean.FALSE);
          coerced=true;
        }
 else         if (val == 1) {
          result=targetClazz.cast(Boolean.TRUE);
          coerced=true;
        }
      }
 else       if (sourceClass == String.class) {
        String s=(String)source;
        if (s.equalsIgnoreCase("String_Node_Str") || s.equalsIgnoreCase("String_Node_Str")) {
          result=targetClazz.cast(Boolean.valueOf((String)source));
          coerced=true;
        }
      }
    }
 else     if (targetClazz.equals(byte[].class)) {
      if (sourceClass == String.class) {
        result=targetClazz.cast(((String)source).getBytes());
        coerced=true;
      }
 else       if (sourceClass == String.class) {
        result=targetClazz.cast(Base64.decode((String)source));
        coerced=true;
      }
 else       if (sourceClass == GuardedByteArray.class) {
        GuardedByteArray gba=(GuardedByteArray)source;
        byte[] byteArray=decrypt(gba);
        result=targetClazz.cast(byteArray);
        coerced=true;
      }
    }
 else     if ((targetClazz.equals(Character.class)) || (targetClazz.equals(char.class))) {
      if (sourceClass == String.class) {
        Character v=((String)source).charAt(0);
        result=(T)v;
        coerced=true;
      }
    }
 else     if (targetClazz.equals(Character[].class)) {
      if (sourceClass == String.class) {
        char[] charArray=((String)source).toCharArray();
        Character[] characterArray=new Character[charArray.length];
        for (int i=0; i < charArray.length; i++) {
          characterArray[i]=new Character(charArray[i]);
        }
        result=targetClazz.cast(characterArray);
        coerced=true;
      }
    }
 else     if (targetClazz.equals(char[].class)) {
      if (sourceClass == String.class) {
        char[] charArray=((String)source).toCharArray();
        result=targetClazz.cast(charArray);
        coerced=true;
      }
    }
 else     if (targetClazz.equals(Date.class)) {
      if (sourceClass == String.class) {
      }
    }
 else     if (targetClazz.equals(double.class)) {
      if (sourceClass == Double.class) {
        result=(T)source;
        coerced=true;
      }
 else       if (sourceClass == int.class) {
        result=(T)Double.valueOf((Integer.valueOf((Integer)source).doubleValue()));
        coerced=true;
      }
 else       if (sourceClass == Integer.class) {
        result=(T)Double.valueOf(((Integer)source).doubleValue());
        coerced=true;
      }
 else       if (sourceClass == String.class) {
        result=targetClazz.cast(Double.valueOf((String)source));
        coerced=true;
      }
    }
 else     if (targetClazz.equals(Double.class)) {
      if (sourceClass == double.class) {
        result=(T)source;
        coerced=true;
      }
 else       if (sourceClass == int.class) {
        result=(T)Double.valueOf((Integer.valueOf((Integer)source).doubleValue()));
        coerced=true;
      }
 else       if (sourceClass == Integer.class) {
        result=(T)Double.valueOf(((Integer)source).doubleValue());
        coerced=true;
      }
 else       if (sourceClass == String.class) {
        result=targetClazz.cast(Double.valueOf((String)source));
        coerced=true;
      }
    }
 else     if (targetClazz.equals(java.io.File.class)) {
      if (sourceClass == String.class) {
        File file=new File((String)source);
        result=targetClazz.cast(file);
        coerced=true;
      }
    }
 else     if (targetClazz.equals(float.class) || targetClazz.equals(Float.class)) {
      if (sourceClass == Float.class || sourceClass == float.class) {
        result=(T)source;
        coerced=true;
      }
 else       if (sourceClass == Double.class || sourceClass == double.class) {
        result=(T)new Float((Double)source);
        coerced=true;
      }
 else       if (sourceClass == int.class) {
        result=(T)Float.valueOf((Integer.valueOf((Integer)source).floatValue()));
        coerced=true;
      }
 else       if (sourceClass == Integer.class) {
        result=(T)Float.valueOf(((Integer)source).floatValue());
        coerced=true;
      }
 else       if (sourceClass == String.class) {
        result=targetClazz.cast(Float.valueOf((String)source));
        coerced=true;
      }
    }
 else     if (targetClazz.equals(GuardedByteArray.class)) {
      if (sourceClass == String.class) {
        byte[] byteArray=((String)source).getBytes();
        GuardedByteArray v=new GuardedByteArray(byteArray);
        result=targetClazz.cast(v);
        coerced=true;
      }
    }
 else     if (targetClazz.equals(GuardedString.class)) {
      if (sourceClass == String.class) {
        char[] charArray=((String)source).toCharArray();
        GuardedString v=new GuardedString(charArray);
        result=targetClazz.cast(v);
        coerced=true;
      }
    }
 else     if (targetClazz.equals(int.class) || targetClazz.equals(Integer.class)) {
      if (sourceClass == Integer.class || sourceClass == int.class) {
        result=(T)source;
        coerced=true;
      }
 else       if (sourceClass == String.class) {
        result=(T)Integer.valueOf((String)source);
        coerced=true;
      }
 else       if (sourceClass == Float.class) {
        result=targetClazz.cast(new Integer(((Float)source).intValue()));
        coerced=true;
      }
 else       if (sourceClass == Long.class) {
        Long l=(Long)source;
        if (l.longValue() <= Integer.MAX_VALUE) {
          result=targetClazz.cast(new Integer(l.intValue()));
          coerced=true;
        }
      }
 else       if (sourceClass == Boolean.class) {
        boolean val=((Boolean)source).booleanValue();
        if (val) {
          result=targetClazz.cast(new Integer(1));
        }
 else {
          result=targetClazz.cast(new Integer(0));
        }
        coerced=true;
      }
    }
 else     if (targetClazz.equals(long.class) || targetClazz.equals(Long.class)) {
      if (sourceClass == int.class) {
        result=(T)Long.valueOf((Integer.valueOf((Integer)source).longValue()));
        coerced=true;
      }
 else       if (sourceClass == Integer.class) {
        result=(T)Long.valueOf(((Integer)source).longValue());
        coerced=true;
      }
 else       if (sourceClass == Long.class || sourceClass == long.class) {
        result=(T)source;
        coerced=true;
      }
 else       if (sourceClass == String.class) {
        result=targetClazz.cast(Long.valueOf((String)source));
        coerced=true;
      }
    }
 else     if (targetClazz.equals(Name.class)) {
      if (sourceClass == String.class) {
        result=targetClazz.cast(new Name((String)source));
        coerced=true;
      }
    }
 else     if (targetClazz.equals(ObjectClass.class)) {
      if (sourceClass == String.class) {
        ScriptBuilder sb=new ScriptBuilder();
        sb.setScriptLanguage("String_Node_Str");
        sb.setScriptText("String_Node_Str");
        result=targetClazz.cast(sb.build());
        coerced=true;
      }
    }
 else     if (targetClazz.equals(QualifiedUid.class)) {
      if (sourceClass == String.class) {
        ScriptBuilder sb=new ScriptBuilder();
        sb.setScriptLanguage("String_Node_Str");
        sb.setScriptText("String_Node_Str");
        result=targetClazz.cast(sb.build());
        coerced=true;
      }
    }
 else     if (targetClazz.equals(Script.class)) {
      if (sourceClass == String.class) {
        ScriptBuilder sb=new ScriptBuilder();
        sb.setScriptLanguage("String_Node_Str");
        sb.setScriptText("String_Node_Str");
        result=targetClazz.cast(sb.build());
        coerced=true;
      }
 else       if (Map.class.isAssignableFrom(sourceClass)) {
        ScriptBuilder sb=new ScriptBuilder();
        sb.setScriptLanguage((String)((Map)source).get("String_Node_Str"));
        sb.setScriptText((String)((Map)source).get("String_Node_Str"));
        result=targetClazz.cast(sb.build());
        coerced=true;
      }
    }
 else     if (targetClazz.equals(String.class)) {
      if (sourceClass == byte[].class) {
        result=(T)new String((byte[])source);
        coerced=true;
      }
 else       if (sourceClass == char.class) {
        result=(T)new String((char[])source);
        coerced=true;
      }
 else       if (sourceClass == Character[].class) {
        Character[] characterArray=(Character[])source;
        char[] charArray=new char[characterArray.length];
        for (int i=0; i < characterArray.length; i++) {
          charArray[i]=characterArray[i];
        }
        result=(T)new String(charArray);
        coerced=true;
      }
 else       if (sourceClass == Double.class) {
        String s=((Double)source).toString();
        result=targetClazz.cast(s);
        coerced=true;
      }
 else       if (sourceClass == Float.class) {
        String s=((Float)source).toString();
        result=targetClazz.cast(s);
        coerced=true;
      }
 else       if (sourceClass == Boolean.class) {
        Boolean b=(Boolean)source;
        result=targetClazz.cast(Boolean.toString(b.booleanValue()));
        coerced=true;
      }
 else       if (sourceClass == Long.class) {
        String s=((Long)source).toString();
        result=targetClazz.cast(s);
        coerced=true;
      }
 else       if (sourceClass == Integer.class) {
        String s=((Integer)source).toString();
        result=targetClazz.cast(s);
        coerced=true;
      }
 else       if (sourceClass == java.math.BigInteger.class) {
        String s=((java.math.BigInteger)source).toString();
        result=targetClazz.cast(s);
        coerced=true;
      }
 else       if (sourceClass == java.math.BigDecimal.class) {
        String s=((java.math.BigDecimal)source).toString();
        result=targetClazz.cast(s);
        coerced=true;
      }
 else       if (sourceClass == java.io.File.class) {
        File file=(File)source;
        String s=file.getPath();
        result=targetClazz.cast(s);
        coerced=true;
      }
 else       if (sourceClass == java.net.URI.class) {
        java.net.URI uri=(java.net.URI)source;
        String s=uri.toString();
        result=targetClazz.cast(s);
        coerced=true;
      }
 else       if (sourceClass == Character.class) {
        Character c=(Character)source;
        char[] charArray=new char[1];
        charArray[0]=c.charValue();
        String s=new String(charArray);
        result=targetClazz.cast(s);
        coerced=true;
      }
 else       if (sourceClass == GuardedString.class) {
        String s=decrypt((GuardedString)source);
        result=targetClazz.cast(s);
        coerced=true;
      }
 else       if (sourceClass == GuardedByteArray.class) {
        byte[] s=decrypt((GuardedByteArray)source);
        result=targetClazz.cast(new String(s));
        coerced=true;
      }
    }
 else     if (targetClazz.equals(Uid.class)) {
      if (sourceClass == String.class) {
        Uid v=new Uid((String)source);
        result=targetClazz.cast(v);
        coerced=true;
      }
    }
 else     if (targetClazz.equals(java.net.URI.class)) {
      if (sourceClass == String.class) {
        try {
          java.net.URI v=new java.net.URI((String)source);
          result=targetClazz.cast(v);
          coerced=true;
        }
 catch (        URISyntaxException e) {
          throw new IOException(e);
        }
      }
    }
  }
 catch (  Exception e) {
    throw new IllegalArgumentException(source.getClass().getCanonicalName() + "String_Node_Str" + targetClazz.getCanonicalName(),e);
  }
  if (coerced == false) {
    throw new IllegalArgumentException(source.getClass().getCanonicalName() + "String_Node_Str" + targetClazz.getCanonicalName());
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Coerce the   {@code source} object to an object of {@code clazz} type.<p/>
 * @param < T >
 * @param source
 * @param clazz
 * @return
 * @throws NumberFormatException
 * @throws URISyntaxException
 * @throws UnsupportedOperationException
 */
@SuppressWarnings("String_Node_Str") public static <T>T coercedTypeCasting(Object source,Class<T> clazz) throws IllegalArgumentException {
  if (null == clazz) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Class<T> targetClazz=clazz;
  Class sourceClass=(source == null ? null : source.getClass());
  boolean coerced=false;
  T result=null;
  try {
    if (source == null) {
      return null;
    }
    if (targetClazz.equals(Object.class)) {
      if ((Number.class.isAssignableFrom(sourceClass)) || (int.class == clazz) || (double.class == clazz)|| (float.class == clazz)|| (long.class == clazz)) {
        return (T)source;
      }
 else       if ((Boolean.class.isAssignableFrom(sourceClass)) || (boolean.class == clazz)) {
        return (T)source;
      }
 else       if (String.class.isAssignableFrom(sourceClass)) {
        return (T)source;
      }
 else       if (Map.class.isAssignableFrom(sourceClass)) {
        return (T)source;
      }
 else       if (List.class.isAssignableFrom(sourceClass)) {
        return (T)source;
      }
 else       if (sourceClass == QualifiedUid.class) {
        Map<String,Object> v=new HashMap<String,Object>(2);
        v.put("String_Node_Str",((QualifiedUid)source).getUid().getUidValue());
        v.put("String_Node_Str",((QualifiedUid)source).getObjectClass().getObjectClassValue());
        return (T)v;
      }
 else       if (sourceClass == Script.class) {
        Map<String,Object> v=new HashMap<String,Object>(2);
        v.put("String_Node_Str",((Script)source).getScriptLanguage());
        v.put("String_Node_Str",((Script)source).getScriptText());
        return (T)v;
      }
 else {
        targetClazz=(Class<T>)String.class;
      }
    }
    if (targetClazz.isAssignableFrom(sourceClass)) {
      return (T)source;
    }
 else     if (targetClazz == sourceClass) {
      return (T)source;
    }
 else     if (targetClazz.equals(java.math.BigDecimal.class)) {
      if (Double.class.isAssignableFrom(sourceClass) || sourceClass == double.class) {
        result=(T)BigDecimal.valueOf((Double)source);
        coerced=true;
      }
 else       if (Integer.class.isAssignableFrom(sourceClass) || sourceClass == int.class) {
        result=(T)BigDecimal.valueOf((Integer)source);
        coerced=true;
      }
 else       if (Long.class.isAssignableFrom(sourceClass) || sourceClass == long.class) {
        result=(T)BigDecimal.valueOf((Long)source);
        coerced=true;
      }
 else       if (sourceClass == String.class) {
        java.math.BigDecimal v=new java.math.BigDecimal((String)source);
        result=targetClazz.cast(v);
        coerced=true;
      }
    }
 else     if (targetClazz.equals(java.math.BigInteger.class)) {
      if (Long.class.isAssignableFrom(sourceClass) || sourceClass == long.class) {
        result=(T)BigInteger.valueOf((Long)source);
        coerced=true;
      }
 else       if (sourceClass == String.class) {
        java.math.BigInteger v=new java.math.BigInteger((String)source);
        result=targetClazz.cast(v);
        coerced=true;
      }
 else {
        result=(T)BigInteger.valueOf(coercedTypeCasting(source,Long.class));
        coerced=true;
      }
    }
 else     if (targetClazz.equals(boolean.class) || targetClazz.equals(Boolean.class)) {
      if (sourceClass == Boolean.class) {
        result=(T)source;
        coerced=true;
      }
 else       if (sourceClass == Integer.class) {
        int val=((Integer)source).intValue();
        if (val == 0) {
          result=targetClazz.cast(Boolean.FALSE);
          coerced=true;
        }
 else         if (val == 1) {
          result=targetClazz.cast(Boolean.TRUE);
          coerced=true;
        }
      }
 else       if (sourceClass == String.class) {
        String s=(String)source;
        if (s.equalsIgnoreCase("String_Node_Str") || s.equalsIgnoreCase("String_Node_Str")) {
          result=targetClazz.cast(Boolean.valueOf((String)source));
          coerced=true;
        }
      }
    }
 else     if (targetClazz.equals(byte[].class)) {
      if (sourceClass == String.class) {
        result=targetClazz.cast(((String)source).getBytes());
        coerced=true;
      }
 else       if (sourceClass == String.class) {
        result=targetClazz.cast(Base64.decode((String)source));
        coerced=true;
      }
 else       if (sourceClass == GuardedByteArray.class) {
        GuardedByteArray gba=(GuardedByteArray)source;
        byte[] byteArray=decrypt(gba);
        result=targetClazz.cast(byteArray);
        coerced=true;
      }
    }
 else     if ((targetClazz.equals(Character.class)) || (targetClazz.equals(char.class))) {
      if (sourceClass == String.class) {
        Character v=((String)source).charAt(0);
        result=(T)v;
        coerced=true;
      }
    }
 else     if (targetClazz.equals(Character[].class)) {
      if (sourceClass == String.class) {
        char[] charArray=((String)source).toCharArray();
        Character[] characterArray=new Character[charArray.length];
        for (int i=0; i < charArray.length; i++) {
          characterArray[i]=new Character(charArray[i]);
        }
        result=targetClazz.cast(characterArray);
        coerced=true;
      }
    }
 else     if (targetClazz.equals(char[].class)) {
      if (sourceClass == String.class) {
        char[] charArray=((String)source).toCharArray();
        result=targetClazz.cast(charArray);
        coerced=true;
      }
    }
 else     if (targetClazz.equals(Date.class)) {
      if (sourceClass == String.class) {
      }
    }
 else     if (targetClazz.equals(double.class)) {
      if (sourceClass == Double.class) {
        result=(T)source;
        coerced=true;
      }
 else       if (sourceClass == int.class) {
        result=(T)Double.valueOf((Integer.valueOf((Integer)source).doubleValue()));
        coerced=true;
      }
 else       if (sourceClass == Integer.class) {
        result=(T)Double.valueOf(((Integer)source).doubleValue());
        coerced=true;
      }
 else       if (sourceClass == String.class) {
        result=targetClazz.cast(Double.valueOf((String)source));
        coerced=true;
      }
    }
 else     if (targetClazz.equals(Double.class)) {
      if (sourceClass == double.class) {
        result=(T)source;
        coerced=true;
      }
 else       if (sourceClass == int.class) {
        result=(T)Double.valueOf((Integer.valueOf((Integer)source).doubleValue()));
        coerced=true;
      }
 else       if (sourceClass == Integer.class) {
        result=(T)Double.valueOf(((Integer)source).doubleValue());
        coerced=true;
      }
 else       if (sourceClass == String.class) {
        result=targetClazz.cast(Double.valueOf((String)source));
        coerced=true;
      }
    }
 else     if (targetClazz.equals(java.io.File.class)) {
      if (sourceClass == String.class) {
        result=(T)new File((String)source);
        coerced=true;
      }
    }
 else     if (targetClazz.equals(float.class) || targetClazz.equals(Float.class)) {
      if (sourceClass == Float.class || sourceClass == float.class) {
        result=(T)source;
        coerced=true;
      }
 else       if (sourceClass == Double.class || sourceClass == double.class) {
        result=(T)new Float((Double)source);
        coerced=true;
      }
 else       if (sourceClass == int.class) {
        result=(T)Float.valueOf((Integer.valueOf((Integer)source).floatValue()));
        coerced=true;
      }
 else       if (sourceClass == Integer.class) {
        result=(T)Float.valueOf(((Integer)source).floatValue());
        coerced=true;
      }
 else       if (sourceClass == String.class) {
        result=targetClazz.cast(Float.valueOf((String)source));
        coerced=true;
      }
    }
 else     if (targetClazz.equals(GuardedByteArray.class)) {
      if (sourceClass == String.class) {
        byte[] byteArray=((String)source).getBytes();
        GuardedByteArray v=new GuardedByteArray(byteArray);
        result=targetClazz.cast(v);
        coerced=true;
      }
    }
 else     if (targetClazz.equals(GuardedString.class)) {
      if (sourceClass == String.class) {
        char[] charArray=((String)source).toCharArray();
        GuardedString v=new GuardedString(charArray);
        result=targetClazz.cast(v);
        coerced=true;
      }
    }
 else     if (targetClazz.equals(int.class) || targetClazz.equals(Integer.class)) {
      if (sourceClass == Integer.class || sourceClass == int.class) {
        result=(T)source;
        coerced=true;
      }
 else       if (sourceClass == String.class) {
        result=(T)Integer.valueOf((String)source);
        coerced=true;
      }
 else       if (sourceClass == Float.class) {
        result=targetClazz.cast(new Integer(((Float)source).intValue()));
        coerced=true;
      }
 else       if (sourceClass == Long.class) {
        Long l=(Long)source;
        if (l.longValue() <= Integer.MAX_VALUE) {
          result=targetClazz.cast(new Integer(l.intValue()));
          coerced=true;
        }
      }
 else       if (sourceClass == Boolean.class) {
        boolean val=((Boolean)source).booleanValue();
        if (val) {
          result=targetClazz.cast(new Integer(1));
        }
 else {
          result=targetClazz.cast(new Integer(0));
        }
        coerced=true;
      }
    }
 else     if (targetClazz.equals(long.class) || targetClazz.equals(Long.class)) {
      if (sourceClass == int.class) {
        result=(T)Long.valueOf((Integer.valueOf((Integer)source).longValue()));
        coerced=true;
      }
 else       if (sourceClass == Integer.class) {
        result=(T)Long.valueOf(((Integer)source).longValue());
        coerced=true;
      }
 else       if (sourceClass == Long.class || sourceClass == long.class) {
        result=(T)source;
        coerced=true;
      }
 else       if (sourceClass == String.class) {
        result=targetClazz.cast(Long.valueOf((String)source));
        coerced=true;
      }
    }
 else     if (targetClazz.equals(Name.class)) {
      if (sourceClass == String.class) {
        result=targetClazz.cast(new Name((String)source));
        coerced=true;
      }
    }
 else     if (targetClazz.equals(ObjectClass.class)) {
      if (sourceClass == String.class) {
        ScriptBuilder sb=new ScriptBuilder();
        sb.setScriptLanguage("String_Node_Str");
        sb.setScriptText("String_Node_Str");
        result=targetClazz.cast(sb.build());
        coerced=true;
      }
    }
 else     if (targetClazz.equals(QualifiedUid.class)) {
      if (sourceClass == String.class) {
        ScriptBuilder sb=new ScriptBuilder();
        sb.setScriptLanguage("String_Node_Str");
        sb.setScriptText("String_Node_Str");
        result=targetClazz.cast(sb.build());
        coerced=true;
      }
    }
 else     if (targetClazz.equals(Script.class)) {
      if (sourceClass == String.class) {
        ScriptBuilder sb=new ScriptBuilder();
        sb.setScriptLanguage("String_Node_Str");
        sb.setScriptText("String_Node_Str");
        result=targetClazz.cast(sb.build());
        coerced=true;
      }
 else       if (Map.class.isAssignableFrom(sourceClass)) {
        ScriptBuilder sb=new ScriptBuilder();
        sb.setScriptLanguage((String)((Map)source).get("String_Node_Str"));
        sb.setScriptText((String)((Map)source).get("String_Node_Str"));
        result=targetClazz.cast(sb.build());
        coerced=true;
      }
    }
 else     if (targetClazz.equals(String.class)) {
      if (sourceClass == byte[].class) {
        result=(T)new String((byte[])source);
        coerced=true;
      }
 else       if (sourceClass == char.class) {
        result=(T)new String((char[])source);
        coerced=true;
      }
 else       if (sourceClass == Character[].class) {
        Character[] characterArray=(Character[])source;
        char[] charArray=new char[characterArray.length];
        for (int i=0; i < characterArray.length; i++) {
          charArray[i]=characterArray[i];
        }
        result=(T)new String(charArray);
        coerced=true;
      }
 else       if (sourceClass == Double.class) {
        String s=((Double)source).toString();
        result=targetClazz.cast(s);
        coerced=true;
      }
 else       if (sourceClass == Float.class) {
        String s=((Float)source).toString();
        result=targetClazz.cast(s);
        coerced=true;
      }
 else       if (sourceClass == Boolean.class) {
        Boolean b=(Boolean)source;
        result=targetClazz.cast(Boolean.toString(b.booleanValue()));
        coerced=true;
      }
 else       if (sourceClass == Long.class) {
        String s=((Long)source).toString();
        result=targetClazz.cast(s);
        coerced=true;
      }
 else       if (sourceClass == Integer.class) {
        String s=((Integer)source).toString();
        result=targetClazz.cast(s);
        coerced=true;
      }
 else       if (sourceClass == java.math.BigInteger.class) {
        String s=((java.math.BigInteger)source).toString();
        result=targetClazz.cast(s);
        coerced=true;
      }
 else       if (sourceClass == java.math.BigDecimal.class) {
        String s=((java.math.BigDecimal)source).toString();
        result=targetClazz.cast(s);
        coerced=true;
      }
 else       if (sourceClass == java.io.File.class) {
        File file=(File)source;
        String s=file.getPath();
        result=targetClazz.cast(s);
        coerced=true;
      }
 else       if (sourceClass == java.net.URI.class) {
        java.net.URI uri=(java.net.URI)source;
        String s=uri.toString();
        result=targetClazz.cast(s);
        coerced=true;
      }
 else       if (sourceClass == Character.class) {
        Character c=(Character)source;
        char[] charArray=new char[1];
        charArray[0]=c.charValue();
        String s=new String(charArray);
        result=targetClazz.cast(s);
        coerced=true;
      }
 else       if (sourceClass == GuardedString.class) {
        String s=decrypt((GuardedString)source);
        result=targetClazz.cast(s);
        coerced=true;
      }
 else       if (sourceClass == GuardedByteArray.class) {
        byte[] s=decrypt((GuardedByteArray)source);
        result=targetClazz.cast(new String(s));
        coerced=true;
      }
    }
 else     if (targetClazz.equals(Uid.class)) {
      if (sourceClass == String.class) {
        Uid v=new Uid((String)source);
        result=targetClazz.cast(v);
        coerced=true;
      }
    }
 else     if (targetClazz.equals(java.net.URI.class)) {
      if (sourceClass == String.class) {
        try {
          java.net.URI v=new java.net.URI((String)source);
          result=targetClazz.cast(v);
          coerced=true;
        }
 catch (        URISyntaxException e) {
          throw new IOException(e);
        }
      }
    }
  }
 catch (  Exception e) {
    throw new IllegalArgumentException(source.getClass().getCanonicalName() + "String_Node_Str" + targetClazz.getCanonicalName(),e);
  }
  if (coerced == false) {
    throw new IllegalArgumentException(source.getClass().getCanonicalName() + "String_Node_Str" + targetClazz.getCanonicalName());
  }
  return result;
}