本文整理了Java中io.sphere.sdk.zones.commands.ZoneDeleteCommand
类的一些代码示例,展示了ZoneDeleteCommand
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneDeleteCommand
类的具体详情如下:
包路径:io.sphere.sdk.zones.commands.ZoneDeleteCommand
类名称:ZoneDeleteCommand
[英]Command object to delete a Zone.
[中]命令对象删除区域。
代码示例来源:origin: com.commercetools.sdk.jvm.core/commercetools-models
/**
Creates a command object to delete a {@link Zone} by its key.
@param key the key of the Zone to delete, see {@link Zone#getKey()}
@param version `the current version of the Zone, see {@link Zone#getVersion()}
@return delete command
*/
static ZoneDeleteCommand ofKey(final String key, final Long version) {
final Versioned<Zone> versioned = Versioned.of("key=" + urlEncode(key), version);//hack for simple reuse
return of(versioned);
}
代码示例来源:origin: io.sphere.sdk.jvm/models
public static DeleteCommand<Zone> of(final Versioned<Zone> versioned) {
return new ZoneDeleteCommand(versioned);
}
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void execution() throws Exception {
final Set<CountryCode> euAndSwissCountries = asSet(AT, BE, CH);//not complete, but you get the idea
final String key = randomKey();
final Set<Location> locations = euAndSwissCountries.stream().map(country -> Location.of(country)).collect(toSet());
final ZoneDraft draft = ZoneDraftBuilder.of("zone1",locations ).description("EU and Swiss").key(key).build();
final ZoneCreateCommand createCommand = ZoneCreateCommand.of(draft);
final Zone zone = client().executeBlocking(createCommand);
assertThat(zone.getKey()).isEqualTo(key);
//end example parsing here
client().executeBlocking(ZoneDeleteCommand.ofKey(zone.getKey(),zone.getVersion()));
}
代码示例来源:origin: com.commercetools.sdk.jvm.core/commercetools-models
/**
Creates a command object to delete a {@link Zone} by its id.
@param id the id of the Zone to delete, see {@link Zone#getId()}
@param version `the current version of the Zone, see {@link Zone#getVersion()}
@return delete command
*/
static ZoneDeleteCommand ofId(final String id, final Long version) {
final Versioned<Zone> versioned = Versioned.of("id=" + urlEncode(id), version);//hack for simple reuse
return of(versioned);
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
private static void withUpdateableZone(final BlockingSphereClient client, final ZoneDraft draft, final Function<Zone, Zone> f) {
final ZoneCreateCommand createCommand = ZoneCreateCommand.of(draft);
Zone zone = client.executeBlocking(createCommand);
zone = f.apply(zone);//zone possibly has been updated
client.executeBlocking(ZoneDeleteCommand.of(zone));
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
public static void withZone(final BlockingSphereClient client, final ZoneDraft draft, final Consumer<Zone> consumer) {
final Zone zone = client.executeBlocking(ZoneCreateCommand.of(draft));
consumer.accept(zone);
client.executeBlocking(ZoneDeleteCommand.of(zone));
}
代码示例来源: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);
}
}
内容来源于网络,如有侵权,请联系作者删除!