class ContentResourceConverter extends ResourceConverterImpl<ContentResource, ClientFile> {

    @Override
    protected ContentResource resourceSpecificFieldsToServer(ClientFile clientObject, ContentResource resultToUpdate, List<Exception> exceptions, ToServerConversionOptions options) throws IllegalParameterValueException {
        if(resultToUpdate.getFileType() != null &&
                (!resultToUpdate.getFileType().equals(clientObject.getType().name()) &&
                        !(ContentResource.TYPE_UNSPECIFIED.equals(resultToUpdate.getFileType()) && clientObject.getType().equals(ClientFile.FileType.unspecified)))){
            // it's not allowed to change resource type
            throw new IllegalParameterValueException("type", clientObject.getType().name());
        }
        if (ClientFile.FileType.unspecified.equals(clientObject.getType())){
            resultToUpdate.setFileType(ContentResource.TYPE_UNSPECIFIED);
        } else {
            resultToUpdate.setFileType(clientObject.getType().name());
        }

        if (clientObject.getContent() != null && !"".equals(clientObject.getContent())) {
            try {
                resultToUpdate.setData(DatatypeConverter.parseBase64Binary(clientObject.getContent()));
            } catch (IllegalArgumentException e) {
                throw new IllegalParameterValueException("content", "");
            }
        }

        return resultToUpdate;
    }

}