io.vavr.collection.Map.isEmpty()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(161)

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

Map.isEmpty介绍

暂无

代码示例

代码示例来源:origin: vavr-io/vavr

@Override
public boolean isEmpty() {
  return back.isEmpty();
}

代码示例来源:origin: vavr-io/vavr

static <K, V, M extends Map<K, V>> M peek(M map, Consumer<? super Tuple2<K, V>> action) {
  Objects.requireNonNull(action, "action is null");
  if (!map.isEmpty()) {
    action.accept(map.head());
  }
  return map;
}

代码示例来源:origin: vavr-io/vavr

@Override
public M init() {
  if (back.isEmpty()) {
    throw new UnsupportedOperationException("init of empty HashMap");
  } else {
    final Tuple2<K, V> last = last();
    return remove(last._1, last._2);
  }
}

代码示例来源:origin: vavr-io/vavr

static <K, V, M extends Map<K, V>> M merge(M map, OfEntries<K, V, M> ofEntries,
    Map<? extends K, ? extends V> that) {
  Objects.requireNonNull(that, "that is null");
  if (map.isEmpty()) {
    return ofEntries.apply(Map.narrow(that));
  } else if (that.isEmpty()) {
    return map;
  } else {
    return that.foldLeft(map, (result, entry) -> !result.containsKey(entry._1) ? put(result, entry) : result);
  }
}

代码示例来源:origin: vavr-io/vavr

@SuppressWarnings("unchecked")
static <K, V, M extends Map<K, V>> Option<M> initOption(M map) {
  return map.isEmpty() ? Option.none() : Option.some((M) map.init());
}

代码示例来源:origin: vavr-io/vavr

@SuppressWarnings("unchecked")
static <K, V, M extends Map<K, V>> Option<M> tailOption(M map) {
  return map.isEmpty() ? Option.none() : Option.some((M) map.tail());
}

代码示例来源:origin: vavr-io/vavr

@SuppressWarnings("unchecked")
static <K, V, U extends V, M extends Map<K, V>> M merge(
    M map, OfEntries<K, V, M> ofEntries,
    Map<? extends K, U> that, BiFunction<? super V, ? super U, ? extends V> collisionResolution) {
  Objects.requireNonNull(that, "that is null");
  Objects.requireNonNull(collisionResolution, "collisionResolution is null");
  if (map.isEmpty()) {
    return ofEntries.apply(Map.narrow(that));
  } else if (that.isEmpty()) {
    return map;
  } else {
    return that.foldLeft(map, (result, entry) -> {
      final K key = entry._1;
      final U value = entry._2;
      final V newValue = result.get(key).map(v -> (V) collisionResolution.apply(v, value)).getOrElse(value);
      return (M) result.put(key, newValue);
    });
  }
}

代码示例来源:origin: vavr-io/vavr-jackson

@Override
  public boolean isEmpty(SerializerProvider provider, Map<?, ?> value) {
    return value.isEmpty();
  }
}

代码示例来源:origin: io.vavr/vavr

@Override
public boolean isEmpty() {
  return back.isEmpty();
}

代码示例来源:origin: io.vavr/vavr

static <K, V, M extends Map<K, V>> M peek(M map, Consumer<? super Tuple2<K, V>> action) {
  Objects.requireNonNull(action, "action is null");
  if (!map.isEmpty()) {
    action.accept(map.head());
  }
  return map;
}

代码示例来源:origin: io.vavr/vavr

@Override
public M init() {
  if (back.isEmpty()) {
    throw new UnsupportedOperationException("init of empty HashMap");
  } else {
    final Tuple2<K, V> last = last();
    return remove(last._1, last._2);
  }
}

代码示例来源:origin: io.vavr/vavr

static <K, V, M extends Map<K, V>> M merge(M map, OfEntries<K, V, M> ofEntries,
    Map<? extends K, ? extends V> that) {
  Objects.requireNonNull(that, "that is null");
  if (map.isEmpty()) {
    return ofEntries.apply(Map.narrow(that));
  } else if (that.isEmpty()) {
    return map;
  } else {
    return that.foldLeft(map, (result, entry) -> !result.containsKey(entry._1) ? put(result, entry) : result);
  }
}

代码示例来源:origin: io.vavr/vavr

@SuppressWarnings("unchecked")
static <K, V, M extends Map<K, V>> Option<M> tailOption(M map) {
  return map.isEmpty() ? Option.none() : Option.some((M) map.tail());
}

代码示例来源:origin: io.vavr/vavr

@SuppressWarnings("unchecked")
static <K, V, U extends V, M extends Map<K, V>> M merge(
    M map, OfEntries<K, V, M> ofEntries,
    Map<? extends K, U> that, BiFunction<? super V, ? super U, ? extends V> collisionResolution) {
  Objects.requireNonNull(that, "that is null");
  Objects.requireNonNull(collisionResolution, "collisionResolution is null");
  if (map.isEmpty()) {
    return ofEntries.apply(Map.narrow(that));
  } else if (that.isEmpty()) {
    return map;
  } else {
    return that.foldLeft(map, (result, entry) -> {
      final K key = entry._1;
      final U value = entry._2;
      final V newValue = result.get(key).map(v -> (V) collisionResolution.apply(v, value)).getOrElse(value);
      return (M) result.put(key, newValue);
    });
  }
}

代码示例来源:origin: io.vavr/vavr

@SuppressWarnings("unchecked")
static <K, V, M extends Map<K, V>> Option<M> initOption(M map) {
  return map.isEmpty() ? Option.none() : Option.some((M) map.init());
}

代码示例来源:origin: HalBuilder/halbuilder-core

private void renderJsonLinks(
  ObjectNode objectNode, ResourceRepresentation<?> representation, boolean embedded) {
 if (!representation.getLinks().isEmpty()
   || (!embedded && !representation.getNamespaces().isEmpty())) {

相关文章