All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.sphere.sdk.messages.queries.MessageQuery Maven / Gradle / Ivy

There is a newer version: 1.0.0-M26
Show newest version
package io.sphere.sdk.messages.queries;

import com.fasterxml.jackson.core.type.TypeReference;
import io.sphere.sdk.messages.Message;
import io.sphere.sdk.messages.MessageDerivateHint;
import io.sphere.sdk.messages.expansion.MessageExpansionModel;
import io.sphere.sdk.queries.MetaModelQueryDsl;
import io.sphere.sdk.queries.PagedQueryResult;
import io.sphere.sdk.queries.Query;

/**

 {@doc.gen summary messages}

 

Query for any message:

{@include.example io.sphere.sdk.messages.queries.MessageQueryTest#queryForAllMessages()}

Query for a specific message class:

{@include.example io.sphere.sdk.messages.queries.MessageQueryTest#queryForASpecificMessage()}

Query for any message and then convert into specific messages:

{@include.example io.sphere.sdk.messages.queries.MessageQueryTest#convertAfterQueryToSpecificMessageClasses()}

Query for any message for a specific resource like orders:

{@include.example io.sphere.sdk.messages.queries.MessageQueryTest#queryForASpecificResource()}

If you convert a message to the wrong class the behaviour is undefined, but then still null pointer exceptions can occur:

{@include.example io.sphere.sdk.messages.queries.MessageQueryTest#convertAfterQueryToSpecificMessageClassesButToTheWrongOne()} */ public interface MessageQuery extends MetaModelQueryDsl> { static TypeReference> resultTypeReference() { return new TypeReference>(){ @Override public String toString() { return "TypeReference>"; } }; } static MessageQuery of() { return new MessageQueryImpl(); } /** * Creates a new query that queries only for messages that can be mapped to a certain Java type. This is a terminal operation so no changes can be done on the query. * * {@include.example io.sphere.sdk.messages.queries.MessageQueryTest#queryForASpecificMessage()} * * @param hint a container containing the message type and type references. You can find it as static field on the message you want, e.g., {@link io.sphere.sdk.orders.messages.DeliveryAddedMessage#MESSAGE_HINT}. * @param the type of a single message that should be the outcome of a query. * @return a new query for a certain Java type of messages */ default Query forMessageType(final MessageDerivateHint hint) { final MessageQuery queryWithPredicateForType = plusPredicates(hint.predicate()); return new TypedMessageQuery<>(queryWithPredicateForType.httpRequestIntent(), hint.queryResultTypeReference()); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy