本文整理汇总了Java中com.google.protobuf.BoolValue类的典型用法代码示例。如果您正苦于以下问题:Java BoolValue类的具体用法?Java BoolValue怎么用?Java BoolValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BoolValue类属于com.google.protobuf包,在下文中一共展示了BoolValue类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: sort_commands_by_timestamp
import com.google.protobuf.BoolValue; //导入依赖的package包/类
@Test
public void sort_commands_by_timestamp() {
final Command cmd1 = requestFactory.createCommand(StringValue.getDefaultInstance(),
minutesAgo(1));
final Command cmd2 = requestFactory.createCommand(Int64Value.getDefaultInstance(),
secondsAgo(30));
final Command cmd3 = requestFactory.createCommand(BoolValue.getDefaultInstance(),
secondsAgo(5));
final List<Command> sortedCommands = newArrayList(cmd1, cmd2, cmd3);
final List<Command> commandsToSort = newArrayList(cmd3, cmd1, cmd2);
assertFalse(sortedCommands.equals(commandsToSort));
Commands.sort(commandsToSort);
assertEquals(sortedCommands, commandsToSort);
}
开发者ID:SpineEventEngine,项目名称:core-java,代码行数:17,代码来源:CommandsShould.java
示例2: create_wereBetween_predicate
import com.google.protobuf.BoolValue; //导入依赖的package包/类
@Test
public void create_wereBetween_predicate() {
final Command command1 = requestFactory.createCommand(StringValue.getDefaultInstance(),
minutesAgo(5));
final Command command2 = requestFactory.createCommand(Int64Value.getDefaultInstance(),
minutesAgo(2));
final Command command3 = requestFactory.createCommand(BoolValue.getDefaultInstance(),
secondsAgo(30));
final Command command4 = requestFactory.createCommand(BoolValue.getDefaultInstance(),
secondsAgo(20));
final Command command5 = requestFactory.createCommand(BoolValue.getDefaultInstance(),
secondsAgo(5));
final ImmutableList<Command> commands =
ImmutableList.of(command1, command2, command3, command4, command5);
final Iterable<Command> filter = Iterables.filter(
commands,
Commands.wereWithinPeriod(minutesAgo(3), secondsAgo(10))
);
assertEquals(3, FluentIterable.from(filter)
.size());
}
开发者ID:SpineEventEngine,项目名称:core-java,代码行数:24,代码来源:CommandsShould.java
示例3: compresses
import com.google.protobuf.BoolValue; //导入依赖的package包/类
@Test
public void compresses() {
expectFzip = true;
final SimpleRequest request = SimpleRequest.newBuilder()
.setResponseSize(314159)
.setResponseCompressed(BoolValue.newBuilder().setValue(true))
.setResponseType(PayloadType.COMPRESSABLE)
.setPayload(Payload.newBuilder()
.setBody(ByteString.copyFrom(new byte[271828])))
.build();
final SimpleResponse goldenResponse = SimpleResponse.newBuilder()
.setPayload(Payload.newBuilder()
.setType(PayloadType.COMPRESSABLE)
.setBody(ByteString.copyFrom(new byte[314159])))
.build();
assertEquals(goldenResponse, blockingStub.unaryCall(request));
// Assert that compression took place
assertTrue(FZIPPER.anyRead);
assertTrue(FZIPPER.anyWritten);
}
开发者ID:grpc,项目名称:grpc-java,代码行数:23,代码来源:TransportCompressionTest.java
示例4: createAdditionalServiceTypes
import com.google.protobuf.BoolValue; //导入依赖的package包/类
/**
* Creates additional types (Value, Struct and ListValue) to be added to the Service config.
* TODO (guptasu): Fix this hack. Find a better way to add the predefined types.
* TODO (guptasu): Add them only when required and not in all cases.
*/
static Iterable<Type> createAdditionalServiceTypes() {
Map<String, DescriptorProto> additionalMessages = Maps.newHashMap();
additionalMessages.put(Struct.getDescriptor().getFullName(),
Struct.getDescriptor().toProto());
additionalMessages.put(Value.getDescriptor().getFullName(),
Value.getDescriptor().toProto());
additionalMessages.put(ListValue.getDescriptor().getFullName(),
ListValue.getDescriptor().toProto());
additionalMessages.put(Empty.getDescriptor().getFullName(),
Empty.getDescriptor().toProto());
additionalMessages.put(Int32Value.getDescriptor().getFullName(),
Int32Value.getDescriptor().toProto());
additionalMessages.put(DoubleValue.getDescriptor().getFullName(),
DoubleValue.getDescriptor().toProto());
additionalMessages.put(BoolValue.getDescriptor().getFullName(),
BoolValue.getDescriptor().toProto());
additionalMessages.put(StringValue.getDescriptor().getFullName(),
StringValue.getDescriptor().toProto());
for (Descriptor descriptor : Struct.getDescriptor().getNestedTypes()) {
additionalMessages.put(descriptor.getFullName(), descriptor.toProto());
}
// TODO (guptasu): Remove this hard coding. Without this, creation of Model from Service throws.
// Needs investigation.
String fileName = "struct.proto";
List<Type> additionalTypes = Lists.newArrayList();
for (String typeName : additionalMessages.keySet()) {
additionalTypes.add(TypesBuilderFromDescriptor.createType(typeName,
additionalMessages.get(typeName), fileName));
}
return additionalTypes;
}
开发者ID:googleapis,项目名称:api-compiler,代码行数:40,代码来源:TypesBuilderFromDescriptor.java
示例5: toProto
import com.google.protobuf.BoolValue; //导入依赖的package包/类
public static RunnerApi.DisplayData toProto(DisplayData displayData) {
// TODO https://issues.apache.org/jira/browse/BEAM-2645
return RunnerApi.DisplayData.newBuilder()
.addItems(
RunnerApi.DisplayData.Item.newBuilder()
.setId(RunnerApi.DisplayData.Identifier.newBuilder().setKey("stubImplementation"))
.setLabel("Stub implementation")
.setType(RunnerApi.DisplayData.Type.Enum.BOOLEAN)
.setValue(Any.pack(BoolValue.newBuilder().setValue(true).build())))
.build();
}
开发者ID:apache,项目名称:beam,代码行数:12,代码来源:DisplayDataTranslation.java
示例6: create_wereAfter_predicate
import com.google.protobuf.BoolValue; //导入依赖的package包/类
@Test
public void create_wereAfter_predicate() {
final Command command = requestFactory.command()
.create(BoolValue.getDefaultInstance());
assertTrue(Commands.wereAfter(secondsAgo(5))
.apply(command));
}
开发者ID:SpineEventEngine,项目名称:core-java,代码行数:8,代码来源:CommandsShould.java
示例7: getOneParameterMethod
import com.google.protobuf.BoolValue; //导入依赖的package包/类
private static Method getOneParameterMethod() {
final Method method;
final Class<?> clazz = StubHandler.class;
try {
//noinspection DuplicateStringLiteralInspection
method = clazz.getDeclaredMethod("handle", BoolValue.class);
} catch (NoSuchMethodException e) {
throw new IllegalStateException(e);
}
return method;
}
开发者ID:SpineEventEngine,项目名称:core-java,代码行数:12,代码来源:HandlerMethodShould.java
示例8: on
import com.google.protobuf.BoolValue; //导入依赖的package包/类
@Subscribe
public void on(BoolValue message, EventContext context) {
methodCalled = true;
if (!message.getValue()) {
throw new UnsupportedOperationException("Do not want false messages!");
}
}
开发者ID:SpineEventEngine,项目名称:core-java,代码行数:8,代码来源:EventSubscriberTestEnv.java
示例9: create_set_on_varargs
import com.google.protobuf.BoolValue; //导入依赖的package包/类
@Test
public void create_set_on_varargs() {
assertEquals(3, EventClass.setOf(
BoolValue.class,
Int32Value.class,
StringValue.class).size());
}
开发者ID:SpineEventEngine,项目名称:core-java,代码行数:8,代码来源:EventClassShould.java
示例10: serverCompressedUnary
import com.google.protobuf.BoolValue; //导入依赖的package包/类
/**
* Tests if the server can send a compressed unary response. Ideally we would assert that the
* responses have the requested compression, but this is not supported by the API. Given a
* compliant server, this test will exercise the code path for receiving a compressed response but
* cannot itself verify that the response was compressed.
*/
@Test
public void serverCompressedUnary() throws Exception {
assumeEnoughMemory();
final SimpleRequest responseShouldBeCompressed =
SimpleRequest.newBuilder()
.setResponseCompressed(BoolValue.newBuilder().setValue(true))
.setResponseSize(314159)
.setPayload(Payload.newBuilder().setBody(ByteString.copyFrom(new byte[271828])))
.build();
final SimpleRequest responseShouldBeUncompressed =
SimpleRequest.newBuilder()
.setResponseCompressed(BoolValue.newBuilder().setValue(false))
.setResponseSize(314159)
.setPayload(Payload.newBuilder().setBody(ByteString.copyFrom(new byte[271828])))
.build();
final SimpleResponse goldenResponse =
SimpleResponse.newBuilder()
.setPayload(Payload.newBuilder().setBody(ByteString.copyFrom(new byte[314159])))
.build();
assertEquals(goldenResponse, blockingStub.unaryCall(responseShouldBeCompressed));
assertStatsTrace(
"grpc.testing.TestService/UnaryCall",
Status.Code.OK,
Collections.singleton(responseShouldBeCompressed),
Collections.singleton(goldenResponse));
assertEquals(goldenResponse, blockingStub.unaryCall(responseShouldBeUncompressed));
assertStatsTrace(
"grpc.testing.TestService/UnaryCall",
Status.Code.OK,
Collections.singleton(responseShouldBeUncompressed),
Collections.singleton(goldenResponse));
}
开发者ID:grpc,项目名称:grpc-java,代码行数:41,代码来源:AbstractInteropTest.java
示例11: serverCompressedStreaming
import com.google.protobuf.BoolValue; //导入依赖的package包/类
/**
* Tests server per-message compression in a streaming response. Ideally we would assert that the
* responses have the requested compression, but this is not supported by the API. Given a
* compliant server, this test will exercise the code path for receiving a compressed response but
* cannot itself verify that the response was compressed.
*/
public void serverCompressedStreaming() throws Exception {
final StreamingOutputCallRequest request =
StreamingOutputCallRequest.newBuilder()
.addResponseParameters(
ResponseParameters.newBuilder()
.setCompressed(BoolValue.newBuilder().setValue(true))
.setSize(31415))
.addResponseParameters(
ResponseParameters.newBuilder()
.setCompressed(BoolValue.newBuilder().setValue(false))
.setSize(92653))
.build();
final List<StreamingOutputCallResponse> goldenResponses =
Arrays.asList(
StreamingOutputCallResponse.newBuilder()
.setPayload(Payload.newBuilder().setBody(ByteString.copyFrom(new byte[31415])))
.build(),
StreamingOutputCallResponse.newBuilder()
.setPayload(Payload.newBuilder().setBody(ByteString.copyFrom(new byte[92653])))
.build());
StreamRecorder<StreamingOutputCallResponse> recorder = StreamRecorder.create();
asyncStub.streamingOutputCall(request, recorder);
recorder.awaitCompletion();
assertSuccess(recorder);
assertEquals(goldenResponses, recorder.getValues());
}
开发者ID:grpc,项目名称:grpc-java,代码行数:34,代码来源:AbstractInteropTest.java
示例12: BoolValueMarshaller
import com.google.protobuf.BoolValue; //导入依赖的package包/类
private BoolValueMarshaller() {
super(BoolValue.getDefaultInstance());
}
开发者ID:curioswitch,项目名称:curiostack,代码行数:4,代码来源:WellKnownTypeMarshaller.java
示例13: doMerge
import com.google.protobuf.BoolValue; //导入依赖的package包/类
@Override
protected final void doMerge(JsonParser parser, int unused, Message.Builder messageBuilder)
throws IOException {
BoolValue.Builder builder = (BoolValue.Builder) messageBuilder;
builder.setValue(ParseSupport.parseBool(parser));
}
开发者ID:curioswitch,项目名称:curiostack,代码行数:7,代码来源:WellKnownTypeMarshaller.java
示例14: doWrite
import com.google.protobuf.BoolValue; //导入依赖的package包/类
@Override
protected final void doWrite(BoolValue message, JsonGenerator gen) throws IOException {
SerializeSupport.printBool(message.getValue(), gen);
}
开发者ID:curioswitch,项目名称:curiostack,代码行数:5,代码来源:WellKnownTypeMarshaller.java
示例15: anyFields
import com.google.protobuf.BoolValue; //导入依赖的package包/类
@Test
public void anyFields() throws Exception {
TestAllTypes content = TestAllTypes.newBuilder().setOptionalInt32(1234).build();
TestAny message = TestAny.newBuilder().setAnyValue(Any.pack(content)).build();
assertMatchesUpstream(message, TestAllTypes.getDefaultInstance());
TestAny messageWithDefaultAnyValue =
TestAny.newBuilder().setAnyValue(Any.getDefaultInstance()).build();
assertMatchesUpstream(messageWithDefaultAnyValue);
// Well-known types have a special formatting when embedded in Any.
//
// 1. Any in Any.
Any anyMessage = Any.pack(Any.pack(content));
assertMatchesUpstream(anyMessage, TestAllTypes.getDefaultInstance());
// 2. Wrappers in Any.
anyMessage = Any.pack(Int32Value.newBuilder().setValue(12345).build());
assertMatchesUpstream(anyMessage, TestAllTypes.getDefaultInstance());
anyMessage = Any.pack(UInt32Value.newBuilder().setValue(12345).build());
assertMatchesUpstream(anyMessage, TestAllTypes.getDefaultInstance());
anyMessage = Any.pack(Int64Value.newBuilder().setValue(12345).build());
assertMatchesUpstream(anyMessage, TestAllTypes.getDefaultInstance());
anyMessage = Any.pack(UInt64Value.newBuilder().setValue(12345).build());
assertMatchesUpstream(anyMessage, TestAllTypes.getDefaultInstance());
anyMessage = Any.pack(FloatValue.newBuilder().setValue(12345).build());
assertMatchesUpstream(anyMessage, TestAllTypes.getDefaultInstance());
anyMessage = Any.pack(DoubleValue.newBuilder().setValue(12345).build());
assertMatchesUpstream(anyMessage, TestAllTypes.getDefaultInstance());
anyMessage = Any.pack(BoolValue.newBuilder().setValue(true).build());
assertMatchesUpstream(anyMessage, TestAllTypes.getDefaultInstance());
anyMessage = Any.pack(StringValue.newBuilder().setValue("Hello").build());
assertMatchesUpstream(anyMessage, TestAllTypes.getDefaultInstance());
anyMessage =
Any.pack(BytesValue.newBuilder().setValue(ByteString.copyFrom(new byte[] {1, 2})).build());
assertMatchesUpstream(anyMessage, TestAllTypes.getDefaultInstance());
// 3. Timestamp in Any.
anyMessage = Any.pack(Timestamps.parse("1969-12-31T23:59:59Z"));
assertMatchesUpstream(anyMessage, TestAllTypes.getDefaultInstance());
// 4. Duration in Any
anyMessage = Any.pack(Durations.parse("12345.10s"));
assertMatchesUpstream(anyMessage, TestAllTypes.getDefaultInstance());
// 5. FieldMask in Any
anyMessage = Any.pack(FieldMaskUtil.fromString("foo.bar,baz"));
assertMatchesUpstream(anyMessage, TestAllTypes.getDefaultInstance());
// 6. Struct in Any
Struct.Builder structBuilder = Struct.newBuilder();
structBuilder.putFields("number", Value.newBuilder().setNumberValue(1.125).build());
anyMessage = Any.pack(structBuilder.build());
assertMatchesUpstream(anyMessage, TestAllTypes.getDefaultInstance());
// 7. Value (number type) in Any
Value.Builder valueBuilder = Value.newBuilder();
valueBuilder.setNumberValue(1);
anyMessage = Any.pack(valueBuilder.build());
assertMatchesUpstream(anyMessage, TestAllTypes.getDefaultInstance());
// 8. Value (null type) in Any
anyMessage = Any.pack(Value.newBuilder().setNullValue(NullValue.NULL_VALUE).build());
assertMatchesUpstream(anyMessage, TestAllTypes.getDefaultInstance());
}
开发者ID:curioswitch,项目名称:curiostack,代码行数:66,代码来源:MessageMarshallerTest.java
示例16: toAnyType
import com.google.protobuf.BoolValue; //导入依赖的package包/类
/**
* Convert a protocol buffer field value to {@link Any} with the below rule:
* <ul>
* <li> If the field is a primitive type and can be mapped to a wrapper message type
* defined in //tech/type/proto/wrappers.proto, its value is boxed into a wrapper
* and goes to Any.value, the type name of the wrapper goes to Any.type_url.
* <li> If the field is already a message, its type name goes to Any.type_url,
* its value directly goes to Any.value
* <li> If the field is an enum value, the name of the enum value is boxed into
* tech.type.String and put into Any.value, and tech.type.String goes to Any.type_url.
*/
private static Any toAnyType(FieldDescriptor.Type protobufType, Object value) {
Any.Builder builder = Any.newBuilder();
java.lang.String typeFullName;
Message wrapperMessage;
switch (protobufType) {
case MESSAGE:
wrapperMessage = (Message) value;
typeFullName = wrapperMessage.getDescriptorForType().getFullName();
break;
case ENUM:
// NOTE: Erasing the enum type to the String wrapper is currently intentional, to avoid
// the need to add an enum wrapper type. This may change in the future.
typeFullName = StringValue.getDescriptor().getFullName();
wrapperMessage =
StringValue.newBuilder().setValue(((EnumValueDescriptor) value).getName()).build();
break;
case BOOL:
typeFullName = BoolValue.getDescriptor().getFullName();
wrapperMessage = BoolValue.newBuilder().setValue((Boolean) value).build();
break;
case DOUBLE:
typeFullName = DoubleValue.getDescriptor().getFullName();
wrapperMessage = DoubleValue.newBuilder().setValue((java.lang.Double) value).build();
break;
case FLOAT:
typeFullName = FloatValue.getDescriptor().getFullName();
wrapperMessage = FloatValue.newBuilder().setValue((java.lang.Float) value).build();
break;
case STRING:
typeFullName = StringValue.getDescriptor().getFullName();
wrapperMessage = StringValue.newBuilder().setValue((java.lang.String) value).build();
break;
case SINT32:
case SFIXED32:
case INT32:
typeFullName = Int32Value.getDescriptor().getFullName();
wrapperMessage = Int32Value.newBuilder().setValue((Integer) value).build();
break;
case SINT64:
case SFIXED64:
case INT64:
typeFullName = Int64Value.getDescriptor().getFullName();
wrapperMessage = Int64Value.newBuilder().setValue((Long) value).build();
break;
case UINT32:
case FIXED32:
typeFullName = UInt32Value.getDescriptor().getFullName();
wrapperMessage = UInt32Value.newBuilder().setValue((Integer) value).build();
break;
case UINT64:
case FIXED64:
typeFullName = UInt64Value.getDescriptor().getFullName();
wrapperMessage = UInt64Value.newBuilder().setValue((Long) value).build();
break;
case BYTES:
typeFullName = BytesValue.getDescriptor().getFullName();
wrapperMessage = BytesValue.newBuilder().setValue(ByteString.copyFrom((byte[]) value))
.build();
break;
default:
throw new IllegalArgumentException("Type " + protobufType.name()
+ " cannot be converted to Any type.");
}
return builder.setTypeUrl(TYPE_SERVICE_BASE_URL + "/" + typeFullName)
.setValue(wrapperMessage.toByteString()).build();
}
开发者ID:googleapis,项目名称:api-compiler,代码行数:78,代码来源:DescriptorNormalization.java
示例17: createBoolOption
import com.google.protobuf.BoolValue; //导入依赖的package包/类
private static Option createBoolOption(String optionName, boolean value) {
return Option.newBuilder()
.setName(optionName)
.setValue(Any.pack(BoolValue.newBuilder().setValue(value).build()))
.build();
}
开发者ID:googleapis,项目名称:api-compiler,代码行数:7,代码来源:ProtoApiFromOpenApi.java
示例18: throw_exception_if_no_handler_for_event
import com.google.protobuf.BoolValue; //导入依赖的package包/类
@Test(expected = IllegalStateException.class)
public void throw_exception_if_no_handler_for_event() {
dispatch(projection, BoolValue.getDefaultInstance(), EventContext.getDefaultInstance());
}
开发者ID:SpineEventEngine,项目名称:core-java,代码行数:5,代码来源:ProjectionShould.java
示例19: construct_non_empty_queries
import com.google.protobuf.BoolValue; //导入依赖的package包/类
@Test
public void construct_non_empty_queries() {
final Message someGenericId = Sample.messageOfType(ProjectId.class);
final Any someId = AnyPacker.pack(someGenericId);
final EntityId entityId = EntityId.newBuilder()
.setId(someId)
.build();
final EntityIdFilter idFilter = EntityIdFilter.newBuilder()
.addIds(entityId)
.build();
final Version versionValue = Version.newBuilder()
.setNumber(1)
.build();
final BoolValue archivedValue = BoolValue.newBuilder()
.setValue(true)
.build();
final ColumnFilter versionFilter = ColumnFilters.eq(version.name(), versionValue);
final ColumnFilter archivedFilter = ColumnFilters.eq(archived.name(), archivedValue);
final CompositeColumnFilter aggregatingFilter =
CompositeColumnFilter.newBuilder()
.addFilter(versionFilter)
.addFilter(archivedFilter)
.setOperator(EITHER)
.build();
final EntityFilters filters = EntityFilters.newBuilder()
.setIdFilter(idFilter)
.addFilter(aggregatingFilter)
.build();
final Class<? extends Entity> entityClass = AbstractVersionableEntity.class;
final EntityQuery<?> query = EntityQueries.from(filters, entityClass);
assertNotNull(query);
final Collection<?> ids = query.getIds();
assertFalse(ids.isEmpty());
assertSize(1, ids);
final Object singleId = ids.iterator().next();
assertEquals(someGenericId, singleId);
final List<CompositeQueryParameter> values = newArrayList(query.getParameters());
assertSize(1, values);
final CompositeQueryParameter singleParam = values.get(0);
final Collection<ColumnFilter> columnFilters = singleParam.getFilters()
.values();
assertEquals(EITHER, singleParam.getOperator());
assertContains(versionFilter, columnFilters);
assertContains(archivedFilter, columnFilters);
}
开发者ID:SpineEventEngine,项目名称:core-java,代码行数:48,代码来源:EntityQueriesShould.java
示例20: return_first_param_type
import com.google.protobuf.BoolValue; //导入依赖的package包/类
@Test
public void return_first_param_type() {
assertEquals(BoolValue.class, HandlerMethod.getFirstParamType(oneParamMethod.getMethod()));
}
开发者ID:SpineEventEngine,项目名称:core-java,代码行数:5,代码来源:HandlerMethodShould.java
注:本文中的com.google.protobuf.BoolValue类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论