/** * Returns an immutable map containing a single entry. This map behaves and * performs comparably to {@link Collections#singletonMap} but will not accept * a null key or value. It is preferable mainly for consistency and * maintainability of your code. */ public static <K, V> ImmutableMap<K, V> of(K k1, V v1) { return new SingletonImmutableMap<K, V>( checkNotNull(k1), checkNotNull(v1)); }
@Override public ImmutableSet<Entry<K, V>> entrySet() { ImmutableSet<Entry<K, V>> es = entrySet; return (es == null) ? (entrySet = ImmutableSet.of(entry())) : es; }
/** * Returns an immutable map containing a single entry. This map behaves and * performs comparably to {@link Collections#singletonMap} but will not accept * a null key or value. It is preferable mainly for consistency and * maintainability of your code. */ public static <K, V> ImmutableMap<K, V> of(K k1, V v1) { return new SingletonImmutableMap<K, V>( checkNotNull(k1), checkNotNull(v1)); }
@Override public ImmutableSet<Entry<K, V>> entrySet() { ImmutableSet<Entry<K, V>> es = entrySet; return (es == null) ? (entrySet = ImmutableSet.of(entry())) : es; }
/** * Returns an immutable map containing a single entry. This map behaves and * performs comparably to {@link Collections#singletonMap} but will not accept * a null key or value. It is preferable mainly for consistency and * maintainability of your code. */ public static <K, V> ImmutableMap<K, V> of(K k1, V v1) { return new SingletonImmutableMap<K, V>( checkNotNull(k1), checkNotNull(v1)); }
@Override public ImmutableSet<Entry<K, V>> entrySet() { ImmutableSet<Entry<K, V>> es = entrySet; return (es == null) ? (entrySet = ImmutableSet.of(entry())) : es; }
/** * Returns an immutable map containing a single entry. This map behaves and * performs comparably to {@link Collections#singletonMap} but will not accept * a null key or value. It is preferable mainly for consistency and * maintainability of your code. */ public static <K, V> ImmutableMap<K, V> of(K k1, V v1) { return new SingletonImmutableMap<K, V>( checkNotNull(k1), checkNotNull(v1)); }
@Override public ImmutableSet<Entry<K, V>> entrySet() { ImmutableSet<Entry<K, V>> es = entrySet; return (es == null) ? (entrySet = ImmutableSet.of(entry())) : es; }
/** * Returns an immutable map containing a single entry. This map behaves and * performs comparably to {@link Collections#singletonMap} but will not accept * a null key or value. It is preferable mainly for consistency and * maintainability of your code. */ public static <K, V> ImmutableMap<K, V> of(K k1, V v1) { return new SingletonImmutableMap<K, V>( checkNotNull(k1), checkNotNull(v1)); }
@Override public ImmutableSet<Entry<K, V>> entrySet() { ImmutableSet<Entry<K, V>> es = entrySet; return (es == null) ? (entrySet = ImmutableSet.of(entry())) : es; }
private static <K, V> ImmutableMap<K, V> fromEntryList( List<Entry<K, V>> entries) { int size = entries.size(); switch (size) { case 0: return of(); case 1: return new SingletonImmutableMap<K, V>(getOnlyElement(entries)); default: Entry<?, ?>[] entryArray = entries.toArray(new Entry<?, ?>[entries.size()]); return new RegularImmutableMap<K, V>(entryArray); } } }
private static <K, V> ImmutableMap<K, V> fromEntryList( List<Entry<K, V>> entries) { int size = entries.size(); switch (size) { case 0: return of(); case 1: return new SingletonImmutableMap<K, V>(getOnlyElement(entries)); default: Entry<?, ?>[] entryArray = entries.toArray(new Entry<?, ?>[entries.size()]); return new RegularImmutableMap<K, V>(entryArray); } } }
private static <K, V> ImmutableMap<K, V> fromEntryList( List<Entry<K, V>> entries) { int size = entries.size(); switch (size) { case 0: return of(); case 1: return new SingletonImmutableMap<K, V>(getOnlyElement(entries)); default: Entry<?, ?>[] entryArray = entries.toArray(new Entry<?, ?>[entries.size()]); return new RegularImmutableMap<K, V>(entryArray); } } }
private static <K, V> ImmutableMap<K, V> fromEntryList( List<Entry<K, V>> entries) { int size = entries.size(); switch (size) { case 0: return of(); case 1: return new SingletonImmutableMap<K, V>(getOnlyElement(entries)); default: Entry<?, ?>[] entryArray = entries.toArray(new Entry<?, ?>[entries.size()]); return new RegularImmutableMap<K, V>(entryArray); } } }
private static <K, V> ImmutableMap<K, V> fromEntryList( List<Entry<K, V>> entries) { int size = entries.size(); switch (size) { case 0: return of(); case 1: return new SingletonImmutableMap<K, V>(getOnlyElement(entries)); default: Entry<?, ?>[] entryArray = entries.toArray(new Entry<?, ?>[entries.size()]); return new RegularImmutableMap<K, V>(entryArray); } } }
return of(); case 1: return new SingletonImmutableMap<K, V>(entryOf( entries[0].getKey(), entries[0].getValue())); default:
return of(); case 1: return new SingletonImmutableMap<K, V>(entryOf( entries[0].getKey(), entries[0].getValue())); default:
return of(); case 1: return new SingletonImmutableMap<K, V>(entryOf( entries[0].getKey(), entries[0].getValue())); default:
return of(); case 1: return new SingletonImmutableMap<K, V>(entryOf( entries[0].getKey(), entries[0].getValue())); default:
return of(); case 1: return new SingletonImmutableMap<K, V>(entryOf( entries[0].getKey(), entries[0].getValue())); default: