/*
 * Copyright 2013 MovingBlocks
 *
 * 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 org.terasology.persistence.typeHandling;

/**
 */
public abstract class TypeHandler<T> {

    /**
     * Serializes a single value.
     * This method should return null if the value cannot or should not be serialized. An example would be if value itself is null.
     *
     * @param value The value to serialize - may be null
     * @param serializer The serializer used to serialize simple values
     * @return The serialized value.
     */
    protected abstract PersistedData serializeNonNull(T value, PersistedDataSerializer serializer);

    public PersistedData serialize(T value, PersistedDataSerializer serializer) {
        if (value == null) {
            return serializer.serializeNull();
        }

        return serializeNonNull(value, serializer);
    }

    /**
     * Deserializes a single value.
     *
     * @param data The persisted data to deserialize from
     * @return The deserialized value.
     * @throws org.terasology.persistence.typeHandling.DeserializationException if there was an error deserializing the data
     */
    public abstract T deserialize(PersistedData data);
}

@@ -640,16 +640,93 @@
 g;%0A%0A/**%0A
+ * Serializes objects of type %7B@link T%7D to and from a %7B@link PersistedData%7D.%0A
  */%0Apubl
@@ -760,17 +760,16 @@
 er%3CT%3E %7B%0A
-%0A
     /**%0A
@@ -787,32 +787,41 @@
 alizes a single 
+non-null 
 value.%0A     * Th
@@ -821,132 +821,532 @@
    *
- This method should return null if the value cannot or should not be serialized. An example would be if
+%0A     * @param value      The value to serialize - will never be null.%0A     * @param serializer The serializer used to serialize simple values%0A     * @return The serialized value.%0A     */%0A    protected abstract PersistedData serializeNonNull(T value, PersistedDataSerializer serializer);%0A%0A    /**%0A     * Serializes a single value.%0A     *%0A     * The default implementation of this method returns %7B@link PersistedDataSerializer#serializeNull()%7D%0A     * if %7B@code
  value
+%7D
  i
-tself is n
+s null, otherwise delegates to %7B@link #serializeNonN
 ull
+%7D
 .%0A  
@@ -1528,109 +1528,8 @@
  */%0A
-    protected abstract PersistedData serializeNonNull(T value, PersistedDataSerializer serializer);%0A%0A
     

Update TypeHandler documentation