java.util.Collections.emptyNavigableMap()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(13.3k)|赞(0)|评价(0)|浏览(197)

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

Collections.emptyNavigableMap介绍

暂无

代码示例

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

@Override
 protected NavigableMap<String, String> create(Entry<String, String>[] entries) {
  return Collections.emptyNavigableMap();
 }
})

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

classes.add(Collections.checkedList(nonRandomAccessList, Void.class).getClass());
classes.add(Collections.checkedMap(Collections.emptyMap(), Void.class, Void.class).getClass());
classes.add(Collections.checkedNavigableMap(Collections.emptyNavigableMap(), Void.class, Void.class).getClass());
classes.add(Collections.checkedNavigableSet(Collections.emptyNavigableSet(), Void.class).getClass());
classes.add(Collections.checkedQueue(new LinkedList<>(), Void.class).getClass());
classes.add(Collections.synchronizedList(nonRandomAccessList).getClass());
classes.add(Collections.synchronizedMap(Collections.emptyMap()).getClass());
classes.add(Collections.synchronizedNavigableMap(Collections.emptyNavigableMap()).getClass());
classes.add(Collections.synchronizedNavigableSet(Collections.emptyNavigableSet()).getClass());
classes.add(Collections.synchronizedSet(Collections.emptySet()).getClass());
classes.add(Collections.unmodifiableList(nonRandomAccessList).getClass());
classes.add(Collections.unmodifiableMap(Collections.emptyMap()).getClass());
classes.add(Collections.unmodifiableNavigableMap(Collections.emptyNavigableMap()).getClass());
classes.add(Collections.unmodifiableNavigableSet(Collections.emptyNavigableSet()).getClass());
classes.add(Collections.unmodifiableSet(Collections.emptySet()).getClass());

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

assertTrue(immutability.test(Collections.emptyListIterator()));
assertTrue(immutability.test(Collections.emptyMap()));
assertTrue(immutability.test(Collections.emptyNavigableMap()));
assertTrue(immutability.test(Collections.emptyNavigableSet()));
assertTrue(immutability.test(Collections.emptySet()));

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

@Override
 protected NavigableMap<String, String> create(Entry<String, String>[] entries) {
  return Collections.emptyNavigableMap();
 }
})

代码示例来源:origin: org.apache.sshd/sshd-osgi

/**
   * @param <I> The {@link KeyTypeIndicator}
   * @param indicators The indicators to group
   * @return A {@link NavigableMap} where key=the case <U>insensitive</U> {@link #getKeyType() key type},
   * value = the {@link List} of all indicators having the same key type
   */
  static <I extends KeyTypeIndicator> NavigableMap<String, List<I>> groupByKeyType(Collection<? extends I> indicators) {
    return GenericUtils.isEmpty(indicators)
       ? Collections.emptyNavigableMap()
       : indicators.stream()
         .collect(Collectors.groupingBy(
           KeyTypeIndicator::getKeyType, () -> new TreeMap<>(String.CASE_INSENSITIVE_ORDER), Collectors.toList()));
  }
}

代码示例来源:origin: MartinHaeusler/chronos

protected static NavigableMap<String, byte[]> getMapReadOnly(final MapDBTransaction tx, final String mapName) {
  checkNotNull(tx, "Precondition violation - argument 'tx' must not be NULL!");
  checkNotNull(mapName, "Precondition violation - argument 'mapName' must not be NULL!");
  if (tx.exists(mapName) == false) {
    return Collections.emptyNavigableMap();
  } else {
    return tx.treeMap(mapName, Serializer.STRING, Serializer.BYTE_ARRAY);
  }
}

代码示例来源:origin: MartinHaeusler/chronos

protected static NavigableMap<String, Boolean> getMapInverseReadOnly(final MapDBTransaction tx,
    final String mapName) {
  checkNotNull(tx, "Precondition violation - argument 'tx' must not be NULL!");
  checkNotNull(mapName, "Precondition violation - argument 'mapName' must not be NULL!");
  String inverseMapName = mapName + INVERSE_MATRIX_SUFFIX;
  if (tx.exists(inverseMapName) == false) {
    return Collections.emptyNavigableMap();
  } else {
    return tx.treeMap(inverseMapName, Serializer.STRING, Serializer.BOOLEAN);
  }
}

代码示例来源:origin: org.apache.sshd/sshd-sftp

public static NavigableMap<String, String> toStringExtensions(Map<String, ?> extensions) {
  if (GenericUtils.isEmpty(extensions)) {
    return Collections.emptyNavigableMap();
  }
  // NOTE: even though extensions are probably case sensitive we do not allow duplicate name that differs only in case
  NavigableMap<String, String> map = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
  extensions.forEach((key, value) -> {
    ValidateUtils.checkNotNull(value, "No value for extension=%s", key);
    String prev = map.put(key, (value instanceof byte[]) ? new String((byte[]) value, StandardCharsets.UTF_8) : value.toString());
    ValidateUtils.checkTrue(prev == null, "Multiple values for extension=%s", key);
  });
  return map;
}

代码示例来源:origin: org.apache.sshd/sshd-sftp

public static NavigableMap<String, byte[]> toBinaryExtensions(Map<String, String> extensions) {
  if (GenericUtils.isEmpty(extensions)) {
    return Collections.emptyNavigableMap();
  }
  // NOTE: even though extensions are probably case sensitive we do not allow duplicate name that differs only in case
  NavigableMap<String, byte[]> map = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
  extensions.forEach((key, value) -> {
    ValidateUtils.checkNotNull(value, "No value for extension=%s", key);
    byte[] prev = map.put(key, value.getBytes(StandardCharsets.UTF_8));
    ValidateUtils.checkTrue(prev == null, "Multiple values for extension=%s", key);
  });
  return map;
}

代码示例来源:origin: org.apache.sshd/sshd-osgi

/**
 * @return A snapshot of the currently registered specialized {@link PublicKeyEntryDataResolver}-s,
 * where key=the key-type value (case <U>insensitive</U>) - e.g., &quot;ssh-rsa&quot;,
 * &quot;pgp-sign-dss&quot;, etc., value=the associated {@link PublicKeyEntryDataResolver}
 * for the key type
 */
public static NavigableMap<String, PublicKeyEntryDataResolver> getRegisteredKeyDataEntryResolvers() {
  NavigableMap<String, PublicKeyEntryDataResolver> decoders;
  synchronized (KEY_DATA_RESOLVERS) {
    if (KEY_DATA_RESOLVERS.isEmpty()) {
      return Collections.emptyNavigableMap();
    }
    decoders = new TreeMap<>(KEY_DATA_RESOLVERS.comparator());
    decoders.putAll(KEY_DATA_RESOLVERS);
  }
  return decoders;
}

代码示例来源:origin: org.apache.sshd/sshd-sftp

protected NavigableMap<String, Object> readFileAttributes(Path file, String view, LinkOption... options) throws IOException {
  try {
    Map<String, ?> attrs = Files.readAttributes(file, view, options);
    if (GenericUtils.isEmpty(attrs)) {
      return Collections.emptyNavigableMap();
    }
    NavigableMap<String, Object> sorted = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
    sorted.putAll(attrs);
    return sorted;
  } catch (IOException e) {
    return handleReadFileAttributesException(file, view, options, e);
  }
}

代码示例来源:origin: MartinHaeusler/chronos

private NavigableMap<Long, byte[]> getMapForReading(final MapDBTransaction tx) {
  checkNotNull(tx, "Precondition violation - argument 'tx' must not be NULL!");
  String mapName = this.getBranchName() + MAP_SUFFIX;
  if (tx.exists(mapName)) {
    return Collections.unmodifiableNavigableMap(tx.treeMap(mapName, Serializer.LONG, Serializer.BYTE_ARRAY));
  } else {
    return Collections.emptyNavigableMap();
  }
}

代码示例来源:origin: org.ogema.widgets/ogema-js-bundle

@Override
public NavigableMap<Long, ReceivedMessage> getMessages(MessageStatus status) {
  switch(status) {
  case CREATED:
    return Collections.unmodifiableNavigableMap(messages.unreadMessages);
  case READ:
    return Collections.unmodifiableNavigableMap(messages.readMessages);
  case DELETED:
    return Collections.unmodifiableNavigableMap(messages.deletedMessages);
  default: 
    return Collections.emptyNavigableMap();
  }
}

代码示例来源:origin: org.apache.sshd/sshd-openpgp

/**
 * @param subKeys The {@link Subkey}-s to map - ignored if {@code null}/empty
 * @return A {@link NavigableMap} where key=the (case <U>insensitive</U>) fingerprint
 * value, value=the matching {@link Subkey}
 * @throws NullPointerException If key with {@code null} fingerprint encountered
 * @throws IllegalArgumentException If key with empty fingerprint encountered
 * @throws IllegalStateException If more than one key with same fingerprint found
 */
public static NavigableMap<String, Subkey> mapSubKeysByFingerprint(Collection<? extends Subkey> subKeys) {
  if (GenericUtils.isEmpty(subKeys)) {
    return Collections.emptyNavigableMap();
  }
  NavigableMap<String, Subkey> keysMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
  for (Subkey sk : subKeys) {
    String fp = ValidateUtils.checkNotNullAndNotEmpty(sk.getFingerprint(), "No fingerprint for %s", sk);
    Subkey prev = keysMap.put(fp, sk);
    ValidateUtils.checkState(prev == null, "Multiple sub-keys with fingerprint=%s: %s / %s", fp, sk, prev);
  }
  return keysMap;
}

代码示例来源:origin: org.ogema.widgets/ogema-js-bundle

private NavigableMap<Long, ReceivedMessage> getMessages(long tm, MessageStatus status) {
  switch(status) {
  case SENT:
    return Collections.unmodifiableNavigableMap(messages.unreadMessages.tailMap(tm));
  case READ:
    return Collections.unmodifiableNavigableMap(messages.readMessages.tailMap(tm));
  case DELETED:
    return Collections.unmodifiableNavigableMap(messages.deletedMessages.tailMap(tm));
  default: 
    return Collections.emptyNavigableMap();
  }
}

代码示例来源:origin: vmware/xenon

@Test
public void readPost111() throws IOException {
  String prefix = "post-1.1.1-";
  assertCollectionEqualAndUsable(Collections.emptyList(), readFileAndDeserialize(prefix + "emptyList"));
  assertCollectionEqualAndUsable(Arrays.asList("test"), readFileAndDeserialize(prefix + "asList"));
  assertCollectionEqualAndUsable(Collections.emptyMap(), readFileAndDeserialize(prefix + "emptyMap"));
  assertCollectionEqualAndUsable(Collections.emptyNavigableMap(),
      readFileAndDeserialize(prefix + "emptyNavigableMap"));
  assertCollectionEqualAndUsable(Collections.emptySortedMap(), readFileAndDeserialize(prefix + "emptySortedMap"));
  assertCollectionEqualAndUsable(Collections.emptySet(), readFileAndDeserialize(prefix + "emptySet"));
  assertCollectionEqualAndUsable(Collections.emptyNavigableSet(),
      readFileAndDeserialize(prefix + "emptyNavigableSet"));
  assertCollectionEqualAndUsable(Collections.emptySortedSet(), readFileAndDeserialize(prefix + "emptySortedSet"));
  assertCollectionEqualAndUsable(Collections.singleton("test"), readFileAndDeserialize(prefix + "singletonSet"));
  assertCollectionEqualAndUsable(Collections.singletonList("test"),
      readFileAndDeserialize(prefix + "singletonList"));
  assertCollectionEqualAndUsable(Collections.singletonMap("k", "v"),
      readFileAndDeserialize(prefix + "singletonMap"));
}

代码示例来源:origin: vmware/xenon

@Test
public void testEmptyCollectionClone() {
  Object target;
  target = Collections.emptyList();
  assertCollectionEqualAndUsable(target, cloneWithKryo(target));
  target = Collections.emptySet();
  assertCollectionEqualAndUsable(target, cloneWithKryo(target));
  target = Collections.emptyMap();
  assertCollectionEqualAndUsable(target, cloneWithKryo(target));
  target = Collections.emptyNavigableMap();
  assertCollectionEqualAndUsable(target, cloneWithKryo(target));
  target = Collections.emptyNavigableSet();
  assertCollectionEqualAndUsable(target, cloneWithKryo(target));
  target = Collections.emptySortedMap();
  assertCollectionEqualAndUsable(target, cloneWithKryo(target));
  target = Collections.emptySortedSet();
  assertCollectionEqualAndUsable(target, cloneWithKryo(target));
}

代码示例来源:origin: com.vmware.xenon/xenon-common

@Test
public void testEmptyCollectionSerialization() {
  Object target;
  target = Collections.emptyList();
  assertCollectionEqualAndUsable(target, serAndDeser(target));
  target = Collections.emptySet();
  assertCollectionEqualAndUsable(target, serAndDeser(target));
  target = Collections.emptyMap();
  assertCollectionEqualAndUsable(target, serAndDeser(target));
  target = Collections.emptyNavigableMap();
  assertCollectionEqualAndUsable(target, serAndDeser(target));
  target = Collections.emptyNavigableSet();
  assertCollectionEqualAndUsable(target, serAndDeser(target));
  target = Collections.emptySortedMap();
  assertCollectionEqualAndUsable(target, serAndDeser(target));
  target = Collections.emptySortedSet();
  assertCollectionEqualAndUsable(target, serAndDeser(target));
}

代码示例来源:origin: vmware/xenon

@Test
public void testEmptyCollectionSerialization() {
  Object target;
  target = Collections.emptyList();
  assertCollectionEqualAndUsable(target, serAndDeser(target));
  target = Collections.emptySet();
  assertCollectionEqualAndUsable(target, serAndDeser(target));
  target = Collections.emptyMap();
  assertCollectionEqualAndUsable(target, serAndDeser(target));
  target = Collections.emptyNavigableMap();
  assertCollectionEqualAndUsable(target, serAndDeser(target));
  target = Collections.emptyNavigableSet();
  assertCollectionEqualAndUsable(target, serAndDeser(target));
  target = Collections.emptySortedMap();
  assertCollectionEqualAndUsable(target, serAndDeser(target));
  target = Collections.emptySortedSet();
  assertCollectionEqualAndUsable(target, serAndDeser(target));
}

代码示例来源:origin: com.vmware.xenon/xenon-common

@Test
public void testEmptyCollectionClone() {
  Object target;
  target = Collections.emptyList();
  assertCollectionEqualAndUsable(target, cloneWithKryo(target));
  target = Collections.emptySet();
  assertCollectionEqualAndUsable(target, cloneWithKryo(target));
  target = Collections.emptyMap();
  assertCollectionEqualAndUsable(target, cloneWithKryo(target));
  target = Collections.emptyNavigableMap();
  assertCollectionEqualAndUsable(target, cloneWithKryo(target));
  target = Collections.emptyNavigableSet();
  assertCollectionEqualAndUsable(target, cloneWithKryo(target));
  target = Collections.emptySortedMap();
  assertCollectionEqualAndUsable(target, cloneWithKryo(target));
  target = Collections.emptySortedSet();
  assertCollectionEqualAndUsable(target, cloneWithKryo(target));
}

相关文章

Collections类方法