All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ibm.icu.impl.ImmutableEntry Maven / Gradle / Ivy

Go to download

International Component for Unicode for Java (ICU4J) is a mature, widely used Java library providing Unicode and Globalization support

The newest version!
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
 *******************************************************************************
 * Copyright (C) 2009-2012, International Business Machines Corporation and         *
 * others. All Rights Reserved.                                                *
 *******************************************************************************
 */
package com.ibm.icu.impl;

import java.util.Map;

/**
 * @author markdavis
 *
 */
public class ImmutableEntry implements Map.Entry {
    final K k;
    final V v;

    ImmutableEntry(K key, V value) {
        k = key;
        v = value;
    }

    public K getKey()   {return k;}

    public V getValue() {return v;}

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

    public boolean equals(Object o) {
        try {
            Map.Entry e = (Map.Entry)o;
            return UnicodeMap.areEqual(e.getKey(), k) && UnicodeMap.areEqual(e.getValue(), v);
        } catch (ClassCastException e) {
            return false;
        }
    }

    public int hashCode() {
        return ((k==null ? 0 : k.hashCode()) ^ (v==null ? 0 : v.hashCode()));
    }

    public String toString() {
        return k+"="+v;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy