com.google.common.collect.Maps.unmodifiableEntry()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(156)

本文整理了Java中com.google.common.collect.Maps.unmodifiableEntry()方法的一些代码示例,展示了Maps.unmodifiableEntry()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Maps.unmodifiableEntry()方法的具体详情如下:
包路径:com.google.common.collect.Maps
类名称:Maps
方法名:unmodifiableEntry

Maps.unmodifiableEntry介绍

[英]Returns an unmodifiable view of the specified map entry. The Entry#setValue operation throws an UnsupportedOperationException. This also has the side-effect of redefining equals to comply with the Entry contract, to avoid a possible nefarious implementation of equals.
[中]返回指定映射项的不可修改视图。条目#setValue操作抛出一个不支持的操作Exception。这还有一个副作用,即重新定义equals以遵守入境合同,避免equals可能的邪恶实施。

代码示例

代码示例来源:origin: google/guava

@Override
 public Entry<K, V> next() {
  return unmodifiableEntry(entryIterator.next());
 }
};

代码示例来源:origin: google/j2objc

static <K, V> UnmodifiableIterator<Entry<K, V>> unmodifiableEntryIterator(
  final Iterator<Entry<K, V>> entryIterator) {
 return new UnmodifiableIterator<Entry<K, V>>() {
  @Override
  public boolean hasNext() {
   return entryIterator.hasNext();
  }
  @Override
  public Entry<K, V> next() {
   return unmodifiableEntry(entryIterator.next());
  }
 };
}

代码示例来源:origin: google/guava

/**
 * Implements {@code Collection.remove} safely for forwarding collections of map entries. If
 * {@code o} is an instance of {@code Entry}, it is wrapped using {@link #unmodifiableEntry} to
 * protect against a possible nefarious equals method.
 *
 * <p>Note that {@code c} is backing (delegate) collection, rather than the forwarding collection.
 *
 * @param c the delegate (unwrapped) collection of map entries
 * @param o the object to remove from {@code c}
 * @return {@code true} if {@code c} was changed
 */
static <K, V> boolean removeEntryImpl(Collection<Entry<K, V>> c, Object o) {
 if (!(o instanceof Entry)) {
  return false;
 }
 return c.remove(unmodifiableEntry((Entry<?, ?>) o));
}

代码示例来源:origin: google/guava

/**
 * Implements {@code Collection.contains} safely for forwarding collections of map entries. If
 * {@code o} is an instance of {@code Entry}, it is wrapped using {@link #unmodifiableEntry} to
 * protect against a possible nefarious equals method.
 *
 * <p>Note that {@code c} is the backing (delegate) collection, rather than the forwarding
 * collection.
 *
 * @param c the delegate (unwrapped) collection of map entries
 * @param o the object that might be contained in {@code c}
 * @return {@code true} if {@code c} contains {@code o}
 */
static <K, V> boolean containsEntryImpl(Collection<Entry<K, V>> c, Object o) {
 if (!(o instanceof Entry)) {
  return false;
 }
 return c.contains(unmodifiableEntry((Entry<?, ?>) o));
}

代码示例来源:origin: wildfly/wildfly

@Override
 public Entry<K, V> next() {
  return unmodifiableEntry(entryIterator.next());
 }
};

代码示例来源:origin: wildfly/wildfly

/**
 * Implements {@code Collection.remove} safely for forwarding collections of map entries. If
 * {@code o} is an instance of {@code Entry}, it is wrapped using {@link #unmodifiableEntry} to
 * protect against a possible nefarious equals method.
 *
 * <p>Note that {@code c} is backing (delegate) collection, rather than the forwarding collection.
 *
 * @param c the delegate (unwrapped) collection of map entries
 * @param o the object to remove from {@code c}
 * @return {@code true} if {@code c} was changed
 */
static <K, V> boolean removeEntryImpl(Collection<Entry<K, V>> c, Object o) {
 if (!(o instanceof Entry)) {
  return false;
 }
 return c.remove(unmodifiableEntry((Entry<?, ?>) o));
}

代码示例来源:origin: wildfly/wildfly

/**
 * Implements {@code Collection.contains} safely for forwarding collections of map entries. If
 * {@code o} is an instance of {@code Entry}, it is wrapped using {@link #unmodifiableEntry} to
 * protect against a possible nefarious equals method.
 *
 * <p>Note that {@code c} is the backing (delegate) collection, rather than the forwarding
 * collection.
 *
 * @param c the delegate (unwrapped) collection of map entries
 * @param o the object that might be contained in {@code c}
 * @return {@code true} if {@code c} contains {@code o}
 */
static <K, V> boolean containsEntryImpl(Collection<Entry<K, V>> c, Object o) {
 if (!(o instanceof Entry)) {
  return false;
 }
 return c.contains(unmodifiableEntry((Entry<?, ?>) o));
}

代码示例来源:origin: google/guava

private static <K, V> @Nullable Entry<K, V> unmodifiableOrNull(
  @Nullable Entry<K, ? extends V> entry) {
 return (entry == null) ? null : Maps.unmodifiableEntry(entry);
}

代码示例来源:origin: wildfly/wildfly

@NullableDecl
private static <K, V> Entry<K, V> unmodifiableOrNull(@NullableDecl Entry<K, ? extends V> entry) {
 return (entry == null) ? null : Maps.unmodifiableEntry(entry);
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

@Override
 public Entry<K, V> next() {
  return unmodifiableEntry(entryIterator.next());
 }
};

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

@Override public Entry<K, V> next() {
  return unmodifiableEntry(delegate.next());
 }
};

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

@Override public Entry<K, V> next() {
  return unmodifiableEntry(delegate.next());
 }
};

代码示例来源:origin: com.diffplug.guava/guava-collect

@Override
  public Entry<K, V> next() {
    return unmodifiableEntry(entryIterator.next());
  }
};

代码示例来源:origin: org.kill-bill.billing/killbill-platform-osgi-bundles-logger

@Override
 public Entry<K, V> next() {
  return unmodifiableEntry(entryIterator.next());
 }
};

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

@Override public Entry<K, V> next() {
  return unmodifiableEntry(delegate.next());
 }
};

代码示例来源:origin: com.google.guava/guava-jdk5

@Override public Entry<K, V> next() {
  return unmodifiableEntry(delegate.next());
 }
};

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.google.guava

@Override public Entry<K, V> next() {
  return unmodifiableEntry(delegate.next());
 }
};

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

@Nullable private static <K, V> Entry<K, V> unmodifiableOrNull(@Nullable Entry<K, V> entry) {
 return (entry == null) ? null : Maps.unmodifiableEntry(entry);
}

代码示例来源:origin: com.diffplug.guava/guava-collect

@Nullable
private static <K, V> Entry<K, V> unmodifiableOrNull(@Nullable Entry<K, V> entry) {
  return (entry == null) ? null : Maps.unmodifiableEntry(entry);
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

@NullableDecl
private static <K, V> Entry<K, V> unmodifiableOrNull(@NullableDecl Entry<K, ? extends V> entry) {
 return (entry == null) ? null : Maps.unmodifiableEntry(entry);
}

相关文章