/*
 * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
package org.opendaylight.yangtools.yang.data.impl.codec;

import java.util.Map.Entry;
import java.util.Objects;
import org.opendaylight.yangtools.yang.common.QName;

public class ValueWithQName<V> implements Entry<QName, V>{
    final QName qname;
    final V value;

    public ValueWithQName(final QName qname, final V value) {
        super();
        this.qname = qname;
        this.value = value;
    }

    public QName getQname() {
        return qname;
    }

    @Override
    public V getValue() {
        return value;
    }

    @Override
    public QName getKey() {
        return qname;
    }

    @Override
    public V setValue(final V value) {
        throw new UnsupportedOperationException();
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + Objects.hashCode(qname);
        result = prime * result + Objects.hashCode(value);
        return result;
    }

    @Override
    public boolean equals(final Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        @SuppressWarnings("rawtypes")
        ValueWithQName other = (ValueWithQName) obj;
        if (qname == null) {
            if (other.qname != null) {
                return false;
            }
        } else if (!qname.equals(other.qname)) {
            return false;
        }
        if (value == null) {
            if (other.value != null) {
                return false;
            }
        } else if (!value.equals(other.value)) {
            return false;
        }
        return true;
    }
}

@@ -380,43 +380,40 @@
 til.
-Map.Entry;%0Aimport java.util.Objects
+AbstractMap.SimpleImmutableEntry
 ;%0Aim
@@ -499,19 +499,31 @@
 %3CV%3E 
-implements 
+extends SimpleImmutable
 Entr
@@ -537,50 +537,62 @@
 , V%3E
+ 
 %7B%0A    
-final QName qname;%0A    final V value
+private static final long serialVersionUID = 1L
 ;%0A%0A 
@@ -670,1397 +670,83 @@
 per(
-);%0A        this.qname = qname;%0A        this.value = value;%0A    %7D%0A%0A    public QName getQname() %7B%0A        return qname;%0A    %7D%0A%0A    @Override%0A    public V getValue() %7B%0A        return value;%0A    %7D%0A%0A    @Override%0A    public QName getKey() %7B%0A        return qname;%0A    %7D%0A%0A    @Override%0A    public V setValue(final V value) %7B%0A        throw new UnsupportedOperationException();%0A    %7D%0A%0A    @Override%0A    public int hashCode() %7B%0A        final int prime = 31;%0A        int result = 1;%0A        result = prime * result + Objects.hashCode(qname);%0A        result = prime * result + Objects.hashCode(value);%0A        return result;%0A    %7D%0A%0A    @Override%0A    public boolean equals(final Object obj) %7B%0A        if (this == obj) %7B%0A            return true;%0A        %7D%0A        if (obj == null) %7B%0A            return false;%0A        %7D%0A        if (getClass() != obj.getClass()) %7B%0A            return false;%0A        %7D%0A        @SuppressWarnings(%22rawtypes%22)%0A        ValueWithQName other = (ValueWithQName) obj;%0A        if (qname == null) %7B%0A            if (other.qname != null) %7B%0A                return false;%0A            %7D%0A        %7D else if (!qname.equals(other.qname)) %7B%0A            return false;%0A        %7D%0A        if (value == null) %7B%0A            if (other.value != null) %7B%0A                return false;%0A            %7D%0A        %7D else if (!value.equals(other.value)) %7B%0A            return false;%0A        %7D%0A        return true
+qname, value);%0A    %7D%0A%0A    public QName getQname() %7B%0A        return getKey()
 ;%0A  

Use SimpleImmutableEntry in ValueWithQName