Search in sources :

Example 31 with PMessage

use of net.morimekta.providence.PMessage in project providence by morimekta.

the class HasFieldValueThat method matches.

@Override
public boolean matches(Object o) {
    if (o == null) {
        return false;
    }
    for (int i = 0; i < path.length; ++i) {
        if (!(o instanceof PMessage)) {
            return false;
        }
        PMessage actual = (PMessage) o;
        PField field = actual.descriptor().findFieldByName(path[i]);
        if (field == null) {
            return false;
        }
        if (!actual.has(field.getId())) {
            return false;
        }
        o = actual.get(field.getId());
    }
    return valueMatcher.matches(o);
}
Also used : PField(net.morimekta.providence.descriptor.PField) PMessage(net.morimekta.providence.PMessage)

Aggregations

PMessage (net.morimekta.providence.PMessage)31 PField (net.morimekta.providence.descriptor.PField)20 Nonnull (javax.annotation.Nonnull)7 TokenizerException (net.morimekta.providence.serializer.pretty.TokenizerException)7 IOException (java.io.IOException)6 PEnumValue (net.morimekta.providence.PEnumValue)6 PServiceCall (net.morimekta.providence.PServiceCall)6 PServiceCallType (net.morimekta.providence.PServiceCallType)6 Token (net.morimekta.providence.serializer.pretty.Token)6 Map (java.util.Map)5 PApplicationException (net.morimekta.providence.PApplicationException)5 PMessageDescriptor (net.morimekta.providence.descriptor.PMessageDescriptor)5 SerializerException (net.morimekta.providence.serializer.SerializerException)5 Binary (net.morimekta.util.Binary)5 ArrayList (java.util.ArrayList)4 PMessageBuilder (net.morimekta.providence.PMessageBuilder)4 PServiceMethod (net.morimekta.providence.descriptor.PServiceMethod)4 TMessage (org.apache.thrift.protocol.TMessage)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3