gpt4 book ai didi

io.sphere.sdk.zones.queries.ZoneQuery类的使用及代码示例

转载 作者:知者 更新时间:2024-03-16 05:21:31 25 4
gpt4 key购买 nike

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

ZoneQuery介绍

[英]summary zones
[中]摘要区域

代码示例

代码示例来源:origin: com.commercetools.sunrise/common

private CompletionStage<Optional<Zone>> fetchZoneByCountry(final Location location) {
  final ZoneQuery request = ZoneQuery.of().byLocation(location);
  return sphereClient.execute(request)
      .thenApplyAsync(PagedResult::head);
}

代码示例来源:origin: io.sphere.sdk.jvm/models

private ZoneQuery() {
  super(ZoneEndpoint.ENDPOINT.endpoint(), resultTypeReference());
}

代码示例来源:origin: com.commercetools.sdk.jvm.core/commercetools-models

default ZoneQuery byName(final String name) {
  return withPredicates(m -> m.name().is(name));
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

public static void withUpdateableDynamicShippingMethodForGermany(final BlockingSphereClient client, final CartPredicate cartPredicate, final UnaryOperator<ShippingMethod> consumer) {
  final Optional<Zone> zoneOptional = client.executeBlocking(ZoneQuery.of().byCountry(DE)).head();
  final Zone zone;
  if (zoneOptional.isPresent()) {
    zone = zoneOptional.get();
  } else {
    zone = client.executeBlocking(ZoneCreateCommand.of(ZoneDraft.of("de", singleton(Location.of(DE)))));
  }
  withUpdateableDynamicShippingMethod(client, cartPredicate, shippingMethodWithOutZone -> {
    final ShippingMethod updated = client.executeBlocking(ShippingMethodUpdateCommand.of(shippingMethodWithOutZone, asList(AddZone.of(zone), AddShippingRate.of(ShippingRate.of(EURO_1), zone))));
    return consumer.apply(updated);
  });
}

代码示例来源:origin: io.sphere.sdk.jvm/sphere-models

public static ZoneQueryBuilder of() {
  return new ZoneQueryBuilder(ZoneQuery.of());
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

@Test
public void queryByName() throws Exception {
  ZoneFixtures.withUpdateableZone(client(), zoneA -> {
    ZoneFixtures.withUpdateableZone(client(), zoneB -> {
      final PagedQueryResult<Zone> result = client().executeBlocking(ZoneQuery.of().byName(zoneA.getName()));
      assertThat(result.getResults()).isEqualTo(asList(zoneA));
      return zoneB;
    }, CD);
    return zoneA;
  }, CC);
}

代码示例来源:origin: io.sphere.sdk.jvm/models

public static ZoneQuery of() {
  return new ZoneQuery();
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

public static void withUpdateableShippingMethodForGermany(final BlockingSphereClient client, final UnaryOperator<ShippingMethod> consumer) {
  final Optional<Zone> zoneOptional = client.executeBlocking(ZoneQuery.of().byCountry(DE)).head();
  final Zone zone;
  if (zoneOptional.isPresent()) {
    zone = zoneOptional.get();
  } else {
    zone = client.executeBlocking(ZoneCreateCommand.of(ZoneDraft.of("de", singleton(Location.of(DE)))));
  }
  withUpdateableShippingMethod(client, shippingMethodWithOutZone -> {
    final ShippingMethod updated = client.executeBlocking(ShippingMethodUpdateCommand.of(shippingMethodWithOutZone, asList(AddZone.of(zone), AddShippingRate.of(ShippingRate.of(EURO_1), zone))));
    return consumer.apply(updated);
  });
}

代码示例来源:origin: com.commercetools.sdk.jvm.core/commercetools-models

public static ZoneQueryBuilder of() {
  return new ZoneQueryBuilder(ZoneQuery.of());
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

@Test
public void byCountry() throws Exception {
  ZoneFixtures.withUpdateableZone(client(), zoneA -> {
    ZoneFixtures.withUpdateableZone(client(), zoneB -> {
      final Set<Location> locations = zoneA.getLocations();
      final PagedQueryResult<Zone> result = client().executeBlocking(ZoneQuery.of().byCountry(oneOf(locations).getCountry()));
      assertThat(result.getResults()).isEqualTo(asList(zoneA));
      return zoneB;
    }, CF);
    return zoneA;
  }, CG);
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

private void locationCheck(final Location searchLocation, final Zone ... expected) {
    final PagedQueryResult<Zone> result = client().executeBlocking(ZoneQuery.of().byLocation(searchLocation));
    final Set<Zone> actual = new HashSet<>(result.getResults());
    assertThat(actual).isEqualTo(new HashSet<>(asList(expected)));
  }
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

public static void deleteZonesForCountries(final BlockingSphereClient client, final CountryCode country, final CountryCode ... moreCountries) {
    final Set<CountryCode> countries = setOf(country, moreCountries);
    final ZoneQuery query = ZoneQuery.of();
    final Consumer<Zone> action = zone -> {
      try {
        client.executeBlocking(ZoneDeleteCommand.of(zone));
      } catch (final SphereException e) {
        client.executeBlocking(ShippingMethodQuery.of().withPredicates(ShippingMethodQueryModel.of().zoneRates().zone().is(zone)))
            .head()
            .ifPresent(sm -> {
              client.executeBlocking(ShippingMethodDeleteCommand.of(sm));
              client.executeBlocking(ZoneDeleteCommand.of(zone));
            });
      }
    };
    client.executeBlocking(query).getResults().stream()
        .filter(zone -> countries.stream().anyMatch(zone::contains))
        .forEach(action);

  }
}

代码示例来源:origin: com.commercetools.sdk.jvm.core/commercetools-models

ZoneQueryImpl(){
  super("/zones", ZoneQuery.resultTypeReference(), ZoneQueryModel.of(), ZoneExpansionModel.of(), ZoneQueryImpl::new);
}

代码示例来源:origin: io.sphere.sdk.jvm/sphere-models

default ZoneQuery byName(final String name) {
  return withPredicates(m -> m.name().is(name));
}

代码示例来源:origin: io.sphere.sdk.jvm/sphere-models

ZoneQueryImpl(){
  super(ZoneEndpoint.ENDPOINT.endpoint(), ZoneQuery.resultTypeReference(), ZoneQueryModel.of(), ZoneExpansionModel.of(), ZoneQueryImpl::new);
}

代码示例来源:origin: io.sphere.sdk.jvm/sphere-models

/**
 * Predicate which matches the country of a location, does not take the state into the consideration.
 * For considering also the state use {@link #byLocation(io.sphere.sdk.zones.Location)}.
 * @param countryCode the country to query for
 * @return query with the same values but a predicate searching for a specific country
 */
default ZoneQuery byCountry(final CountryCode countryCode) {
  return withPredicates(m -> m.locations().country().is(countryCode));
}

代码示例来源:origin: com.commercetools.sdk.jvm.core/commercetools-models

/**
 * Predicate which matches the country of a location, does not take the state into the consideration.
 * For considering also the state use {@link #byLocation(io.sphere.sdk.zones.Location)}.
 * @param countryCode the country to query for
 * @return query with the same values but a predicate searching for a specific country
 */
default ZoneQuery byCountry(final CountryCode countryCode) {
  return withPredicates(m -> m.locations().country().is(countryCode));
}

代码示例来源:origin: com.commercetools.sdk.jvm.core/commercetools-models

/**
   * Predicate which matches the country and state of a location.
   *
   * For ignoring the state use {@link #byCountry(com.neovisionaries.i18n.CountryCode)}.
   * @param location the location to query for
   * @return query with the same values but a predicate searching for a specific location
   */
  default ZoneQuery byLocation(final Location location) {
    final QueryPredicate<Zone> predicate =
        Optional.ofNullable(location.getState())
            .map(state -> ZoneQueryModel.of().locations().where(l -> l.country().is(location.getCountry()).and(l.state().is(state))))
            .orElseGet(() -> ZoneQueryModel.of().locations().where(l -> l.country().is(location.getCountry()).and(l.state().isNotPresent())));
    return withPredicates(predicate);
  }
}

代码示例来源:origin: io.sphere.sdk.jvm/sphere-models

/**
   * Predicate which matches the country and state of a location.
   *
   * For ignoring the state use {@link #byCountry(com.neovisionaries.i18n.CountryCode)}.
   * @param location the location to query for
   * @return query with the same values but a predicate searching for a specific location
   */
  default ZoneQuery byLocation(final Location location) {
    final QueryPredicate<Zone> predicate =
        Optional.ofNullable(location.getState())
            .map(state -> ZoneQueryModel.of().locations().where(l -> l.country().is(location.getCountry()).and(l.state().is(state))))
            .orElseGet(() -> ZoneQueryModel.of().locations().where(l -> l.country().is(location.getCountry()).and(l.state().isNotPresent())));
    return withPredicates(predicate);
  }
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com