jeck猫
看源码就一清二楚了[code="java"] private static class UnmodifiableMapimplements Map, Serializable{static class UnmodifiableEntrySet extends UnmodifiableSet{private static class UnmodifiableEntryimplements Map.Entry{ public Object getKey()
{
return e.getKey();
}
public Object getValue()
{
return e.getValue();
}
public Object setValue(Object obj)
{
throw new UnsupportedOperationException();
}
public int hashCode()
{
return e.hashCode();
}
public boolean equals(Object obj)
{
if(!(obj instanceof Map.Entry))
{
return false;
} else
{
Map.Entry entry = (Map.Entry)obj;
return Collections.eq(e.getKey(), entry.getKey()) && Collections.eq(e.getValue(), entry.getValue());
}
}
public String toString()
{
return e.toString();
}
private Map.Entry e;
UnmodifiableEntry(Map.Entry entry)
{
e = entry;
}
}
public Iterator iterator()
{
return new Iterator() {
public boolean hasNext()
{
return i.hasNext();
}
public Map.Entry next()
{
return new UnmodifiableEntry((Map.Entry)i.next());
}
public void remove()
{
throw new UnsupportedOperationException();
}
public volatile Object next()
{
return next();
}
private final Iterator i;
final UnmodifiableEntrySet this$0;
{
this$0 = UnmodifiableEntrySet.this;
super();
i = c.iterator();
}
};} public Object[] toArray()
{
Object aobj[] = c.toArray();
for(int i = 0; i < aobj.length; i++)
aobj[i] = new UnmodifiableEntry((Map.Entry)aobj[i]);
return aobj;
}
public Object[] toArray(Object aobj[])
{
Object aobj1[] = c.toArray(aobj.length != 0 ? Arrays.copyOf(aobj, 0) : aobj);
for(int i = 0; i < aobj1.length; i++)
aobj1[i] = new UnmodifiableEntry((Map.Entry)aobj1[i]);
if(aobj1.length > aobj.length)
return (Object[])aobj1;
System.arraycopy(((Object) (aobj1)), 0, ((Object) (aobj)), 0, aobj1.length);
if(aobj.length > aobj1.length)
aobj[aobj1.length] = null;
return aobj;
}
public boolean contains(Object obj)
{
if(!(obj instanceof Map.Entry))
return false;
else
return c.contains(new UnmodifiableEntry((Map.Entry)obj));
}
public boolean containsAll(Collection collection)
{
for(Iterator iterator1 = collection.iterator(); iterator1.hasNext();)
{
Object obj = iterator1.next();
if(!contains(obj))
return false;
}
return true;
}
public boolean equals(Object obj)
{
if(obj == this)
return true;
if(!(obj instanceof Set))
return false;
Set set = (Set)obj;
if(set.size() != c.size())
return false;
else
return containsAll(set);
}
private static final long serialVersionUID = 7854390611657943733L;
UnmodifiableEntrySet(Set set)
{
super(set);
}
}
public int size()
{
return m.size();
}
public boolean isEmpty()
{
return m.isEmpty();
}
public boolean containsKey(Object obj)
{
return m.containsKey(obj);
}
public boolean containsValue(Object obj)
{
return m.containsValue(obj);
}
public Object get(Object obj)
{
return m.get(obj);
}
public Object put(Object obj, Object obj1)
{
throw new UnsupportedOperationException();
}
public Object remove(Object obj)
{
throw new UnsupportedOperationException();
}
public void putAll(Map map)
{
throw new UnsupportedOperationException();
}
public void clear()
{
throw new UnsupportedOperationException();
}
public Set keySet()
{
if(keySet == null)
keySet = Collections.unmodifiableSet(m.keySet());
return keySet;
}
public Set entrySet()
{
if(entrySet == null)
entrySet = new UnmodifiableEntrySet(m.entrySet());
return entrySet;
}
public Collection values()
{
if(values == null)
values = Collections.unmodifiableCollection(m.values());
return values;
}
public boolean equals(Object obj)
{
return obj == this || m.equals(obj);
}
public int hashCode()
{
return m.hashCode();
}
public String toString()
{
return m.toString();
}
private static final long serialVersionUID = -1034234728574286014L;
private final Map m;
private transient Set keySet;
private transient Set entrySet;
private transient Collection values;
UnmodifiableMap(Map map)
{
keySet = null;
entrySet = null;
values = null;
if(map == null)
{
throw new NullPointerException();
} else
{
m = map;
return;
}
}
}