/* Copyright (c) 2016, Effektif GmbH.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License. */
package com.effektif.workflow.impl.json.types;

import java.lang.reflect.Type;
import java.net.URI;
import java.net.URISyntaxException;

import com.effektif.workflow.impl.json.JsonObjectWriter;
import com.effektif.workflow.impl.json.JsonReader;
import com.effektif.workflow.impl.json.JsonTypeMapper;
import com.effektif.workflow.impl.json.JsonTypeMapperFactory;
import com.effektif.workflow.impl.json.JsonWriter;
import com.effektif.workflow.impl.json.Mappings;

/**
 * Maps a {@link URI} to its {@link String} representation.
 *
 * @author Peter Hilton
 */
public class UriMapper extends AbstractTypeMapper<URI> implements JsonTypeMapperFactory {

  @Override
  public JsonTypeMapper createTypeMapper(Type type, Class<?> clazz, Mappings mappings) {
    if (clazz==URI.class) {
      return this;
    }
    return null;
  }

  @Override
  public void write(URI objectValue, JsonWriter jsonWriter) {
    jsonWriter.writeString(objectValue.toString());
  }

  @Override
  public URI read(Object jsonValue, JsonReader jsonReader) {
    try {
      return jsonValue == null ? null : new URI(jsonValue.toString());
    } catch (URISyntaxException | ClassCastException e) {
      return null;
    }
  }
}

@@ -729,65 +729,8 @@
 n;%0A%0A
-import com.effektif.workflow.impl.json.JsonObjectWriter;%0A
 impo
@@ -1426,24 +1426,104 @@
 onWriter) %7B%0A
+    if (objectValue == null) %7B%0A      jsonWriter.writeNull();%0A    %7D%0A    else %7B%0A  
     jsonWrit
@@ -1562,16 +1562,22 @@
 ing());%0A
+    %7D%0A
   %7D%0A%0A  @

Add null check