本文整理了Java中io.sphere.sdk.models.Reference.getTypeId
方法的一些代码示例,展示了Reference.getTypeId
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Reference.getTypeId
方法的具体详情如下:
包路径:io.sphere.sdk.models.Reference
类名称:Reference
方法名:getTypeId
[英]Type id of the object this reference represents, e.g. "customer".
[中]此引用表示的对象的类型id,例如“客户”。
代码示例来源:origin: io.sphere.sdk.jvm/common
@SuppressWarnings("rawtypes")//at runtime generic type is not determinable
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Reference reference = (Reference) o;
if (!getId().equals(reference.getId())) return false;
if (!getTypeId().equals(reference.getTypeId())) return false;
return true;
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Override
public void serialize(final Reference reference, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException {
jsonGenerator.writeStartObject();
jsonGenerator.writeStringField("id", reference.getId());
jsonGenerator.writeStringField("typeId", reference.getTypeId());
jsonGenerator.writeObjectField("obj", reference.getObj());
jsonGenerator.writeEndObject();
}
}
代码示例来源:origin: io.sphere.sdk.jvm/common
public boolean referencesSameResource(final Referenceable<T> counterpart) {
final Reference<T> reference = counterpart.toReference();
return reference.getId().equals(getId()) && reference.getTypeId().equals(getTypeId());
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
default boolean referencesSameResource(final Referenceable<T> counterpart) {
final Reference<T> reference = counterpart.toReference();
return reference.getId().equals(getId()) && reference.getTypeId().equals(getTypeId());
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@SuppressWarnings("rawtypes")//at runtime generic type is not determinable
@Override
public final boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof Reference)) return false;
Reference reference = (Reference) o;
if (!getId().equals(reference.getId())) return false;
if (!getTypeId().equals(reference.getTypeId())) return false;
return true;
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
default Reference<T> filled(@Nullable final T obj) {
return new ReferenceImpl<>(getTypeId(), getId(), obj);
}
代码示例来源:origin: io.sphere.jvmsdk/common
public Reference<T> filled(final Optional<T> obj) {
return new Reference<>(getTypeId(), getId(), obj);
}
代码示例来源:origin: io.sphere.sdk.jvm/common
public Reference<T> filled(final Optional<T> obj) {
return new Reference<>(getTypeId(), getId(), obj);
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
public boolean referencesSameResource(final Referenceable<T> counterpart) {
final Reference<T> reference = counterpart.toReference();
return reference.getId().equals(getId()) && reference.getTypeId().equals(getTypeId());
}
代码示例来源:origin: io.sphere.sdk.jvm/sphere-models
public static CustomFieldsDraft ofCustomFields(final CustomFields custom) {
return CustomFieldsDraft.ofTypeIdAndJson(custom.getType().getTypeId(), custom.getFieldsJsonMap());
}
代码示例来源:origin: com.commercetools.sdk.jvm.core/commercetools-models
.filter(hint -> hint.typeString() == null)
.filter(hint -> hint.resourceReferenceTypeId() != null)
.filter(hint -> hint.resourceReferenceTypeId().equals(genericMessage.getResource().getTypeId()))
.map(hint -> hint.clazz())
.filter(clazz -> Message.class.isAssignableFrom(clazz))
代码示例来源:origin: commercetools/commercetools-jvm-sdk
.filter(hint -> hint.typeString() == null)
.filter(hint -> hint.resourceReferenceTypeId() != null)
.filter(hint -> hint.resourceReferenceTypeId().equals(genericMessage.getResource().getTypeId()))
.map(hint -> hint.clazz())
.filter(clazz -> Message.class.isAssignableFrom(clazz))
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void createFilledReference() throws Exception {
final Reference<TestEntity> reference = newFilledReference();
assertThat(reference.getId()).isEqualTo(id);
assertThat(reference.getTypeId()).isEqualTo(typeId);
assertThat(reference.getObj()).isEqualTo(new TestEntity("value"));
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void createEmptyReference() throws Exception {
final Reference<TestEntity> reference = newEmptyReference();
assertThat(reference.getId()).isEqualTo(id);
assertThat(reference.getTypeId()).isEqualTo(typeId);
assertThat(reference.getObj()).isNull();
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void categoryCreated() throws Exception {
assumeHasAwsCliEnv();
withCategory(client(), category -> {
assertEventually(() -> {
final ReceiveMessageResult result = sqsClient.receiveMessage(queueUrl);
assertThat(result).isNotNull();
final List<Message> sqsMessages = result.getMessages();
assertThat(sqsMessages).hasSize(1);
final Message sqsMessage = sqsMessages.get(0);
final MessageSubscriptionPayload<Category> messageSubscriptionPayload =
SphereJsonUtils.readObject(sqsMessage.getBody(), MessageSubscriptionPayload.class);
assertThat(messageSubscriptionPayload).isNotNull();
final Reference resource = messageSubscriptionPayload.getResource();
assertThat(resource).isNotNull();
assertThat(resource.getTypeId()).isEqualTo(Category.referenceTypeId());
assertThat(messageSubscriptionPayload.hasCompleteMessage()).isTrue();
assertThat(messageSubscriptionPayload.as(CategoryCreatedMessage.class)).isNotNull();
sqsClient.deleteMessage(queueUrl, sqsMessage.getReceiptHandle());
});
});
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
/**
* Waits for the test subscription message.
* (as documented at http://dev.commercetools.com/http-api-projects-subscriptions.html#create-a-subscription)
*/
protected void waitForSubscriptionTestMessage() {
assertEventually(() -> {
final ReceiveMessageResult result = sqsClient.receiveMessage(queueUrl);
assertThat(result).isNotNull();
final List<Message> sqsMessages = result.getMessages();
for (final Message sqsMessage : sqsMessages) {
final ResourceCreatedPayload<Subscription> resourceCreatedPayload =
SphereJsonUtils.readObject(sqsMessage.getBody(), ResourceCreatedPayload.class);
assertThat(resourceCreatedPayload).isNotNull();
assertThat(resourceCreatedPayload.getResourceUserProvidedIdentifiers()).isNotNull();
assertThat(resourceCreatedPayload.getResourceUserProvidedIdentifiers().getKey()).isNotNull();
final Reference resource = resourceCreatedPayload.getResource();
assertThat(resource).isNotNull();
assertThat(resource.getTypeId()).isEqualTo(Subscription.referenceTypeId());
sqsClient.deleteMessage(queueUrl, sqsMessage.getReceiptHandle());
}
});
}
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void productCreated() throws Exception {
assumeHasAwsCliEnv();
withProduct(client(), product -> {
assertEventually(() -> {
final ReceiveMessageResult result = sqsClient.receiveMessage(queueUrl);
assertThat(result).isNotNull();
final List<Message> sqsMessages = result.getMessages();
assertThat(sqsMessages).hasSize(1);
final Message sqsMessage = sqsMessages.get(0);
sqsClient.deleteMessage(queueUrl, sqsMessage.getReceiptHandle());
final ResourceCreatedPayload<Product> resourceCreatedPayload =
SphereJsonUtils.readObject(sqsMessage.getBody(), ResourceCreatedPayload.class);
assertThat(resourceCreatedPayload).isNotNull();
assertThat(resourceCreatedPayload.getModifiedAt()).isNotNull();
final Reference resource = resourceCreatedPayload.getResource();
assertThat(resource).isNotNull();
assertThat(resource.getTypeId()).isEqualTo(Product.referenceTypeId());
sqsClient.deleteMessage(queueUrl, sqsMessage.getReceiptHandle());
});
});
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void execution() throws Exception {
withUpdateableProductDiscount(client(), productDiscount -> {
final ProductDiscountQuery discountQuery = ProductDiscountQuery.of()
.withPredicates(m -> m.active().is(true).and(m.id().is(productDiscount.getId())))
.withExpansionPaths(m -> m.references());
final ProductDiscount loadedDiscount = client().executeBlocking(discountQuery).head().get();
assertThat(loadedDiscount.getId()).isEqualTo(productDiscount.getId());
assertThat(loadedDiscount.getReferences().size()).isGreaterThanOrEqualTo(1);
assertThat(loadedDiscount.getReferences().stream()
.filter(ref -> ref.getTypeId().equals(Product.referenceTypeId()))
.findFirst()
.get()
)
.overridingErrorMessage("one product is expanded")
.matches(ref -> ref.getObj() != null);
return productDiscount;
});
}
}
内容来源于网络,如有侵权,请联系作者删除!