Unmarshals the given map source into a bean.
@param source the source
@return the API version
177851
@SuppressWarnings("unchecked")
    public static ApiVersionBean unmarshallApiVersion(Map<String, Object> source) {
        if (source == null) {
            return null;
        }
        ApiVersionBean bean = new ApiVersionBean();
        bean.setVersion(asString(source.get("version")));
        bean.setStatus(asEnum(source.get("status"), ApiStatus.class));
        bean.setCreatedBy(asString(source.get("createdBy")));
        bean.setCreatedOn(asDate(source.get("createdOn")));
        bean.setModifiedBy(asString(source.get("modifiedBy")));
        bean.setModifiedOn(asDate(source.get("modifiedOn")));
        bean.setPublishedOn(asDate(source.get("publishedOn")));
        bean.setRetiredOn(asDate(source.get("retiredOn")));
        bean.setEndpoint(asString(source.get("endpoint")));
        bean.setEndpointType(asEnum(source.get("endpointType"), EndpointType.class));
        bean.setEndpointContentType(asEnum(source.get("endpointContentType"), EndpointContentType.class));
        bean.setPublicAPI(asBoolean(source.get("publicAPI")));
        bean.setDefinitionType(asEnum(source.get("definitionType"), ApiDefinitionType.class));
        bean.setParsePayload(asBool(source.get("parsePayload")));
        bean.setGateways(new HashSet<>());
        List<Map<String, Object>> gateways = (List<Map<String, Object>>) source.get("gateways");
        if (gateways != null) {
            for (Map<String, Object> gatewayMap : gateways) {
                ApiGatewayBean gatewayBean = new ApiGatewayBean();
                gatewayBean.setGatewayId(asString(gatewayMap.get("gatewayId")));
                bean.getGateways().add(gatewayBean);
            }
        }
        bean.setPlans(new HashSet<>());
        List<Map<String, Object>> plans = (List<Map<String, Object>>) source.get("plans");
        if (plans != null) {
            for (Map<String, Object> planMap : plans) {
                ApiPlanBean planBean = new ApiPlanBean();
                planBean.setPlanId(asString(planMap.get("planId")));
                planBean.setVersion(asString(planMap.get("version")));
                bean.getPlans().add(planBean);
            }
        }
        Map<String, Object> endpointProperties = (Map<String, Object>) source.get("endpointProperties");
        if (endpointProperties != null) {
            bean.setEndpointProperties(new HashMap<>());
            for (Entry<String, Object> entry : endpointProperties.entrySet()) {
                bean.getEndpointProperties().put(entry.getKey(), String.valueOf(entry.getValue()));
            }
        }
        postMarshall(bean);
        return bean;
    }
1266949
public static Map<?, ?> toMap(String xml, String encoding) throws UnmarshalException {
		Map<?, ?> map = (Map<?, ?>)toObject(xml, encoding, Map.class);
		return map;
	}
528010
public static Object unmarshal (Class<?> type, String source)
        throws Exception
    {
        if (type.isEnum()) {
            // we need to use a dummy enum type here as there's no way to ask Enum.valueOf to
            // execute on an existentially typed enum; it all works out under the hood
            @SuppressWarnings("unchecked") Class<Dummy> etype = (Class<Dummy>)type;
            return Enum.valueOf(etype, source); // may throw an exception
        }
        // look up an argument parser for the field type
        Parser parser = _parsers.get(type);
        if (parser == null) {
            throw new Exception(
                "Don't know how to convert strings into values of type '" + type + "'.");
        }
        return parser.parse(source);
    }
489592
public static <T> Map<String, Object> toMap(T bean) {
        Map<String, Object> map = null;
        try {
            map = PropertyUtils.describe(bean);
            map.remove("class");
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return map;
    }
542031
public static OrganizationBean unmarshallOrganization(Map<String, Object> source) {
        if (source == null) {
            return null;
        }
        OrganizationBean bean = new OrganizationBean();
        bean.setId(asString(source.get("id")));
        bean.setName(asString(source.get("name")));
        bean.setDescription(asString(source.get("description")));
        bean.setCreatedOn(asDate(source.get("createdOn")));
        bean.setCreatedBy(asString(source.get("createdBy")));
        bean.setModifiedOn(asDate(source.get("modifiedOn")));
        bean.setModifiedBy(asString(source.get("modifiedBy")));
        postMarshall(bean);
        return bean;
    }
452189
public T deserialize(Source source) {
    try {
      Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
      JAXBElement<T> jaxbElement = unmarshaller.unmarshal(source, clazz);
      return jaxbElement.getValue();
    } catch (JAXBException e) {
      throw new SerializationException(
          String.format("Could not deserialize %s object from source %s.", clazz, source), e);
    }
  }
402435
public static ApiSummaryBean unmarshallApiSummary(Map<String, Object> source) {
        if (source == null) {
            return null;
        }
        ApiSummaryBean bean = new ApiSummaryBean();
        bean.setOrganizationId(asString(source.get("organizationId")));
        bean.setOrganizationName(asString(source.get("organizationName")));
        bean.setId(asString(source.get("id")));
        bean.setName(asString(source.get("name")));
        bean.setDescription(asString(source.get("description")));
        bean.setCreatedOn(asDate(source.get("createdOn")));
        postMarshall(bean);
        return bean;
    }
1075120
public Object javaToSql(Object source)
    {
        if (source == null)
            return null;
        try
        {
            ByteArrayOutputStream bao = new ByteArrayOutputStream();
            GZIPOutputStream gos = new GZIPOutputStream(bao);
            ObjectOutputStream oos = new ObjectOutputStream(gos);
            oos.writeObject(source);
            oos.close();
            gos.close();
            bao.close();
            byte[] result = bao.toByteArray();
            return result;
        }
        catch (Throwable t)
        {
            throw new ConversionException(t);
        }
    }
474268
public static OrganizationSummaryBean unmarshallOrganizationSummary(Map<String, Object> source) {
        if (source == null) {
            return null;
        }
        OrganizationSummaryBean bean = new OrganizationSummaryBean();
        bean.setId(asString(source.get("id")));
        bean.setName(asString(source.get("name")));
        bean.setDescription(asString(source.get("description")));
        postMarshall(bean);
        return bean;
    }
1077295
@Override
    public ByteBuffer fromStringCQL2(String source) throws MarshalException
    {
        // Return an empty ByteBuffer for an empty string.
        if (source.isEmpty())
            return ByteBufferUtil.EMPTY_BYTE_BUFFER;

        ByteBuffer idBytes = null;

        // ffffffff-ffff-ffff-ffff-ffffffffff
        if (regexPattern.matcher(source).matches())
        {
            UUID uuid = null;
            try
            {
                uuid = UUID.fromString(source);
                idBytes = decompose(uuid);
            }
            catch (IllegalArgumentException e)
            {
                throw new MarshalException(String.format("unable to make UUID from '%s'", source), e);
            }

            if (uuid.version() != 1)
                throw new MarshalException("TimeUUID supports only version 1 UUIDs");
        }
        else
        {
            idBytes = ByteBuffer.wrap(UUIDGen.getTimeUUIDBytes(TimestampSerializer.dateStringToTimestamp(source)));
        }

        return idBytes;
    }
849909
public static GatewaySummaryBean unmarshallGatewaySummary(Map<String, Object> map) {
        GatewaySummaryBean bean = new GatewaySummaryBean();
        bean.setId(asString(map.get("id")));
        bean.setName(asString(map.get("name")));
        if (map.containsKey("description")) {
            bean.setDescription(asString(map.get("description")));
        }
        bean.setType(asEnum(map.get("type"), GatewayType.class));
        postMarshall(bean);
        return bean;
    }
662493
public static PluginSummaryBean unmarshallPluginSummary(Map<String, Object> map) {
        PluginSummaryBean bean = new PluginSummaryBean();
        bean.setId(asLong(map.get("id")));
        bean.setName(asString(map.get("name")));
        if (map.containsKey("description")) {
            bean.setDescription(asString(map.get("description")));
        }
        bean.setGroupId(asString(map.get("groupId")));
        bean.setArtifactId(asString(map.get("artifactId")));
        bean.setVersion(asString(map.get("version")));
        if (map.containsKey("type")) {
            bean.setType(asString(map.get("type")));
        }
        if (map.containsKey("classifier")) {
            bean.setClassifier(asString(map.get("classifier")));
        }
        bean.setCreatedBy(asString(map.get("createdBy")));
        bean.setCreatedOn(asDate(map.get("createdOn")));

        postMarshall(bean);
        return bean;
    }
778554
public static RoleBean unmarshallRole(Map<String, Object> source) {
        if (source == null) {
            return null;
        }
        RoleBean bean = new RoleBean();
        bean.setId(asString(source.get("id")));
        bean.setName(asString(source.get("name")));
        bean.setDescription(asString(source.get("description")));
        bean.setCreatedBy(asString(source.get("createdBy")));
        bean.setCreatedOn(asDate(source.get("createdOn")));
        bean.setAutoGrant(asBoolean(source.get("autoGrant")));
        @SuppressWarnings("unchecked")
        List<Object> permissions = (List<Object>) source.get("permissions");
        if (permissions != null && !permissions.isEmpty()) {
            bean.setPermissions(new HashSet<>());
            for (Object permission : permissions) {
                bean.getPermissions().add(asEnum(permission, PermissionType.class));
            }
        }
        postMarshall(bean);
        return bean;
    }
689449
public static Object unmarshall(HttpResponse response) throws JAXBException, IOException {
        String xml = EntityUtils.toString(response.getEntity());
        Unmarshaller unmarshaller = ctx.createUnmarshaller();
        return unmarshaller.unmarshal(new StringReader(xml));
    }
1289628
public static ContractBean unmarshallContract(Map<String, Object> source) {
        if (source == null) {
            return null;
        }
        ContractBean bean = new ContractBean();
        bean.setId(asLong(source.get("id")));
        bean.setCreatedBy(asString(source.get("createdBy")));
        bean.setCreatedOn(asDate(source.get("createdOn")));
        postMarshall(bean);
        return bean;
    }
743195
public static PlanSummaryBean unmarshallPlanSummary(Map<String, Object> source) {
        if (source == null) {
            return null;
        }
        PlanSummaryBean bean = new PlanSummaryBean();
        bean.setOrganizationId(asString(source.get("organizationId")));
        bean.setOrganizationName(asString(source.get("organizationName")));
        bean.setId(asString(source.get("id")));
        bean.setName(asString(source.get("name")));
        bean.setDescription(asString(source.get("description")));
        postMarshall(bean);
        return bean;
    }
855627
public <S, T> FromUnmarshaller<S, T> findUnmarshaller(Class<S> source, Class<T> target) {
		return findUnmarshaller(new ConverterKey<S,T>(source, target, DefaultBinding.class));
	}