code: public Object toObject(Entity entity, Class targetClass) {
          if (registry == null) {
              LOG.warn("No ResourceRegistry set, using default which "
                      + "will scan the entire classpath. It would be better to set your own registry that filters by packages.");
              try {
                  registry = ResourceRegistryImpl.newInstance((String[]) null);
              } catch (Siren4JException e) {
                  throw new Siren4JRuntimeException(e);
              }
          }
          Resource resource = null;
          if (entity != null) {
              String sirenClass = targetClass != null
                      ? targetClass.getName()
                      : (String) entity.getProperties().get(Siren4J.CLASS_RESERVED_PROPERTY);
              String[] eClass = entity.getComponentClass();
              if (StringUtils.isBlank(sirenClass) && (eClass == null || eClass.length == 0)) {
                  throw new Siren4JConversionException(
                          "No entity class defined, won't be able to match to Java class. Can't go on.");
              }
  
              if (StringUtils.isBlank(sirenClass)) {
                  sirenClass = eClass[0];
              }
              if (!registry.containsEntityEntry(sirenClass)) {
                  throw new Siren4JConversionException("No matching resource found in the registry. Can't go on.");
              }
              Class<?> clazz = registry.getClassByEntityName(sirenClass);
              List<ReflectedInfo> fieldInfo = ReflectionUtils.getExposedFieldInfo(clazz);
              Object obj = null;
              try {
                  obj = clazz.newInstance();
              } catch (Exception e) {
                  throw new Siren4JConversionException(e);
              }
  
              // Set properties
              handleSetProperties(obj, clazz, entity, fieldInfo);
              // Set sub entities
              handleSetSubEntities(obj, clazz, entity, fieldInfo);
  
              resource = (Resource) obj;
          }
          return resource;
      }
docs: /* (non-Javadoc)
  @see com.google.code.siren4j.converter.ResourceConverter#toObject(com.google.code.siren4j.component.Entity)