/*
 * Orika - simpler, better and faster Java bean mapping
 *
 * Copyright (C) 2011-2013 Orika authors
 *
 * 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 ma.glasnost.orika.converter.builtin;

import ma.glasnost.orika.converter.BidirectionalConverter;
import ma.glasnost.orika.metadata.TypeFactory;

/**
 * BidirectionalConverter which describes itself as builtin
 *
 * @param <C>
 * @param <D>
 */
abstract class BuiltinBidirectionalConverter<C, D> extends
		BidirectionalConverter<C, D> {

	private final String description;
	private volatile Reversed<D, C> reversed;
	
	public BuiltinBidirectionalConverter() {
	    super();
	    String srcName = TypeFactory.nameOf(sourceType, destinationType);
	    String dstName = TypeFactory.nameOf(destinationType, sourceType); 
	    description = "builtin:" + getClass().getSimpleName() + "<"
        + srcName + ", " + dstName + ">";
	}
	
	public String toString() {
		return description;
	}
	
	public BidirectionalConverter<D, C> reverse() {
	    if (reversed == null) {
	        synchronized(this) {
	            if (reversed == null) {
	                reversed = new Reversed<D, C>(this);
	            }
	        }
	    }
	    return reversed;
	}
	
	public static class Reversed<D, C> extends BidirectionalConverter.Reversed<D, C> {

	    private final String description;
	    
        public Reversed(BidirectionalConverter<C, D> bidi) {
            super(bidi);
            String srcName = TypeFactory.nameOf(getAType(), getBType());
            String dstName = TypeFactory.nameOf(getBType(), getAType());
            description = "builtin:reversed:" + bidi.getClass().getSimpleName() + "<"
            + srcName + ", " + dstName + ">";
        }
	    
        public String toString() {
            return description;
        }
	}
}

@@ -969,19 +969,17 @@
  extends
-%0A%09%09
+ 
 Bidirect
@@ -1397,63 +1397,8 @@
 %7D%0A%09%0A
-%09public String toString() %7B%0A%09%09return description;%0A%09%7D%0A%09%0A
 %09pub
@@ -1646,25 +1646,24 @@
 eversed;%0A%09%7D%0A
-%09
 %0A%09public sta
@@ -1659,16 +1659,434 @@
 %09public 
+String toString() %7B%0A%09%09return description;%0A%09%7D%0A%0A%09@Override%0A%09public boolean equals(Object o) %7B%0A%09%09if (this == o) return true;%0A%09%09if (o == null %7C%7C getClass() != o.getClass()) return false;%0A%09%09if (!super.equals(o)) return false;%0A%0A%09%09BuiltinBidirectionalConverter%3C?, ?%3E that = (BuiltinBidirectionalConverter%3C?, ?%3E) o;%0A%0A%09%09return description != null ? description.equals(that.description) : that.description == null;%0A%09%7D%0A%0A%09private 
 static c

Add equal methods for BuiltinBidirectionalConverter