• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java StringValue类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.cloud.datastore.StringValue的典型用法代码示例。如果您正苦于以下问题:Java StringValue类的具体用法?Java StringValue怎么用?Java StringValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



StringValue类属于com.google.cloud.datastore包,在下文中一共展示了StringValue类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: store

import com.google.cloud.datastore.StringValue; //导入依赖的package包/类
void store(Workflow workflow) throws IOException {
  storeWithRetries(() -> datastore.runInTransaction(transaction -> {
    final Key componentKey = componentKeyFactory.newKey(workflow.componentId());
    if (transaction.get(componentKey) == null) {
      transaction.put(Entity.newBuilder(componentKey).build());
    }

    final String json = OBJECT_MAPPER.writeValueAsString(workflow);
    final Key workflowKey = workflowKey(workflow.id());
    final Optional<Entity> workflowOpt = getOpt(transaction, workflowKey);
    final Entity workflowEntity = asBuilderOrNew(workflowOpt, workflowKey)
        .set(PROPERTY_WORKFLOW_JSON, StringValue.newBuilder(json).setExcludeFromIndexes(true).build())
        .build();

    return transaction.put(workflowEntity);
  }));
}
 
开发者ID:spotify,项目名称:styx,代码行数:18,代码来源:DatastoreStorage.java


示例2: backfillToEntity

import com.google.cloud.datastore.StringValue; //导入依赖的package包/类
private Entity backfillToEntity(Backfill backfill) {
  final Key key = datastore.newKeyFactory().setKind(KIND_BACKFILL).newKey(backfill.id());

  Entity.Builder builder = Entity.newBuilder(key)
      .set(PROPERTY_CONCURRENCY, backfill.concurrency())
      .set(PROPERTY_START, instantToTimestamp(backfill.start()))
      .set(PROPERTY_END, instantToTimestamp(backfill.end()))
      .set(PROPERTY_COMPONENT, backfill.workflowId().componentId())
      .set(PROPERTY_WORKFLOW, backfill.workflowId().id())
      .set(PROPERTY_SCHEDULE, backfill.schedule().toString())
      .set(PROPERTY_NEXT_TRIGGER, instantToTimestamp(backfill.nextTrigger()))
      .set(PROPERTY_ALL_TRIGGERED, backfill.allTriggered())
      .set(PROPERTY_HALTED, backfill.halted());

  backfill.description().ifPresent(x -> builder.set(PROPERTY_DESCRIPTION, StringValue
      .newBuilder(x).setExcludeFromIndexes(true).build()));

  return builder.build();
}
 
开发者ID:spotify,项目名称:styx,代码行数:20,代码来源:DatastoreStorage.java


示例3: setUpQueryTests

import com.google.cloud.datastore.StringValue; //导入依赖的package包/类
private void setUpQueryTests() {
  Key taskKey = datastore.newKeyFactory()
      .setKind("Task")
      .addAncestors(PathElement.of("TaskList", "default"))
      .newKey("someTask");
  datastore.put(Entity.newBuilder(taskKey)
      .set("category", "Personal")
      .set("done", false)
      .set("completed", false)
      .set("priority", 4)
      .set("created", includedDate)
      .set("percent_complete", 10.0)
      .set("description",
          StringValue.newBuilder("Learn Cloud Datastore").setExcludeFromIndexes(true).build())
      .set("tag", "fun", "l", "programming")
      .build());
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:18,代码来源:ConceptsTest.java


示例4: testUnmarshalToObject_List

import com.google.cloud.datastore.StringValue; //导入依赖的package包/类
@Test
public void testUnmarshalToObject_List() {
	// Setup
	Key key = Key.newBuilder("project", "kind", 1).build();
	Entity entity = Entity.newBuilder(key)
			.set("object",
					Arrays.asList(DoubleValue.of(3.14), LongValue.of(42),
							StringValue.of("hello")))
			.set("list",
					Arrays.asList(DoubleValue.of(3.14), LongValue.of(42),
							StringValue.of("hello")))
			.set("linkedList", Arrays.asList(DoubleValue.of(3.14), LongValue.of(42),
					StringValue.of("hello")))
			.build();
	Unmarshaller unmarshaller = new Unmarshaller();
	TestBean bean = new TestBean();
	bean.linkedList = new LinkedList<Object>();

	// Exercise
	unmarshaller.unmarshalToObject(entity, bean);

	// Verify
	Assert.assertThat((List<?>) bean.object, contains(3.14, 42L, "hello"));
	Assert.assertThat(bean.list, contains(3.14, 42L, "hello"));
	Assert.assertThat(bean.linkedList, contains(3.14, 42L, "hello"));
	Assert.assertThat(bean.linkedList, instanceOf(LinkedList.class));
}
 
开发者ID:tkob,项目名称:spring-data-gclouddatastore,代码行数:28,代码来源:UnmarshallerTests.java


示例5: index

import com.google.cloud.datastore.StringValue; //导入依赖的package包/类
@Override
public Value<?> index(Value<?> input) {
  if (input.getType() == ValueType.NULL) {
    return NullValue.of();
  }
  try {
    String str = ((StringValue) input).get();
    return StringValue.of(str.toUpperCase(Locale.ENGLISH));
  } catch (Exception exp) {
    throw new IndexingException(exp);
  }
}
 
开发者ID:sai-pullabhotla,项目名称:catatumbo,代码行数:13,代码来源:UpperCaseStringIndexer.java


示例6: index

import com.google.cloud.datastore.StringValue; //导入依赖的package包/类
@Override
public Value<?> index(Value<?> input) {
  if (input.getType() == ValueType.NULL) {
    return NullValue.of();
  }
  try {
    String str = ((StringValue) input).get();
    return StringValue.of(str.toLowerCase(Locale.ENGLISH));
  } catch (Exception exp) {
    throw new IndexingException(exp);
  }
}
 
开发者ID:sai-pullabhotla,项目名称:catatumbo,代码行数:13,代码来源:LowerCaseStringIndexer.java


示例7: toDatastore

import com.google.cloud.datastore.StringValue; //导入依赖的package包/类
@Override
public ValueBuilder<?, ?, ?> toDatastore(Object input) {
  if (input == null) {
    return NullValue.newBuilder();
  }
  return StringValue.newBuilder(input.toString());
}
 
开发者ID:sai-pullabhotla,项目名称:catatumbo,代码行数:8,代码来源:LocalDateMapper.java


示例8: toModel

import com.google.cloud.datastore.StringValue; //导入依赖的package包/类
@Override
public Object toModel(Value<?> input) {
  if (input instanceof NullValue) {
    return null;
  }
  try {
    return LocalDate.parse(((StringValue) input).get());
  } catch (ClassCastException exp) {
    String pattern = "Mapping of type %s to %s is not supported";
    throw new MappingException(
        String.format(pattern, input.getClass().getName(), LocalDate.class.getName()), exp);
  }
}
 
开发者ID:sai-pullabhotla,项目名称:catatumbo,代码行数:14,代码来源:LocalDateMapper.java


示例9: toDatastore

import com.google.cloud.datastore.StringValue; //导入依赖的package包/类
@Override
public ValueBuilder<?, ?, ?> toDatastore(Object input) {
  if (input == null) {
    return NullValue.newBuilder();
  }
  return StringValue.newBuilder((String) input);
}
 
开发者ID:sai-pullabhotla,项目名称:catatumbo,代码行数:8,代码来源:StringMapper.java


示例10: toModel

import com.google.cloud.datastore.StringValue; //导入依赖的package包/类
@Override
public Object toModel(Value<?> input) {
  if (input instanceof NullValue) {
    return null;
  }
  return ((StringValue) input).get();
}
 
开发者ID:sai-pullabhotla,项目名称:catatumbo,代码行数:8,代码来源:StringMapper.java


示例11: toDatastore

import com.google.cloud.datastore.StringValue; //导入依赖的package包/类
@Override
public ValueBuilder<?, ?, ?> toDatastore(Object input) {
  if (input == null) {
    return NullValue.newBuilder();
  }
  return StringValue.newBuilder(String.valueOf((char) input));
}
 
开发者ID:sai-pullabhotla,项目名称:catatumbo,代码行数:8,代码来源:CharMapper.java


示例12: toModel

import com.google.cloud.datastore.StringValue; //导入依赖的package包/类
@Override
public Object toModel(Value<?> input) {
  if (input instanceof NullValue) {
    return null;
  }
  String str = ((StringValue) input).get();
  if (str.length() != 1) {
    throw new MappingException(String.format("Unable to convert %s to char", str));
  }
  return str.charAt(0);
}
 
开发者ID:sai-pullabhotla,项目名称:catatumbo,代码行数:12,代码来源:CharMapper.java


示例13: toDatastore

import com.google.cloud.datastore.StringValue; //导入依赖的package包/类
@Override
public ValueBuilder<?, ?, ?> toDatastore(Object input) {
  if (input == null) {
    return NullValue.newBuilder();
  }
  return StringValue.newBuilder(((LocalTime) input).format(FORMATTER));
}
 
开发者ID:sai-pullabhotla,项目名称:catatumbo,代码行数:8,代码来源:LocalTimeMapper.java


示例14: toDatastore

import com.google.cloud.datastore.StringValue; //导入依赖的package包/类
@Override
public ValueBuilder<?, ?, ?> toDatastore(Object input) {
  if (input == null) {
    return NullValue.newBuilder();
  }
  return StringValue.newBuilder(new String((char[]) input));
}
 
开发者ID:sai-pullabhotla,项目名称:catatumbo,代码行数:8,代码来源:CharArrayMapper.java


示例15: toModel

import com.google.cloud.datastore.StringValue; //导入依赖的package包/类
@Override
public Object toModel(Value<?> input) {
  if (input instanceof NullValue) {
    return null;
  }
  return ((StringValue) input).get().toCharArray();
}
 
开发者ID:sai-pullabhotla,项目名称:catatumbo,代码行数:8,代码来源:CharArrayMapper.java


示例16: toModel

import com.google.cloud.datastore.StringValue; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Object toModel(Value<?> input) {
  if (input instanceof NullValue) {
    return null;
  }
  String value = ((StringValue) input).get();
  return Enum.valueOf(enumClass, value);
}
 
开发者ID:sai-pullabhotla,项目名称:catatumbo,代码行数:10,代码来源:EnumMapper.java


示例17: toDatastore

import com.google.cloud.datastore.StringValue; //导入依赖的package包/类
@Override
public ValueBuilder<?, ?, ?> toDatastore(Object input) {
  ValueBuilder<?, ?, ?> builder;
  if (input == null) {
    builder = NullValue.newBuilder();
  } else if (input instanceof Long) {
    builder = LongValue.newBuilder((long) input);
  } else if (input instanceof Double) {
    builder = DoubleValue.newBuilder((double) input);
  } else if (input instanceof Boolean) {
    builder = BooleanValue.newBuilder((boolean) input);
  } else if (input instanceof String) {
    builder = StringValue.newBuilder((String) input);
  } else if (input instanceof DatastoreKey) {
    builder = KeyValue.newBuilder(((DatastoreKey) input).nativeKey());
  } else if (input instanceof GeoLocation) {
    GeoLocation geoLocation = (GeoLocation) input;
    builder = LatLngValue
        .newBuilder(LatLng.of(geoLocation.getLatitude(), geoLocation.getLongitude()));
  } else if (input instanceof Map) {
    @SuppressWarnings("unchecked")
    Map<String, ?> map = (Map<String, ?>) input;
    FullEntity.Builder<IncompleteKey> entityBuilder = FullEntity.newBuilder();
    for (Map.Entry<String, ?> entry : map.entrySet()) {
      String key = entry.getKey();
      entityBuilder.set(key, toDatastore(entry.getValue()).build());
    }
    builder = EntityValue.newBuilder(entityBuilder.build());
  } else {
    throw new MappingException(String.format("Unsupported type: %s", input.getClass().getName()));
  }
  return builder;
}
 
开发者ID:sai-pullabhotla,项目名称:catatumbo,代码行数:34,代码来源:CatchAllMapper.java


示例18: toModel

import com.google.cloud.datastore.StringValue; //导入依赖的package包/类
@Override
public Object toModel(Value<?> input) {
  Object javaValue;
  if (input instanceof NullValue) {
    javaValue = null;
  } else if (input instanceof StringValue) {
    javaValue = input.get();
  } else if (input instanceof LongValue) {
    javaValue = input.get();
  } else if (input instanceof DoubleValue) {
    javaValue = input.get();
  } else if (input instanceof BooleanValue) {
    javaValue = input.get();
  } else if (input instanceof KeyValue) {
    javaValue = new DefaultDatastoreKey(((KeyValue) input).get());
  } else if (input instanceof LatLngValue) {
    LatLng latLong = ((LatLngValue) input).get();
    javaValue = new GeoLocation(latLong.getLatitude(), latLong.getLongitude());
  } else if (input instanceof EntityValue) {
    EntityValue entityValue = (EntityValue) input;
    FullEntity<?> entity = entityValue.get();
    Map<String, Object> map = new HashMap<>();
    for (String property : entity.getNames()) {
      map.put(property, toModel(entity.getValue(property)));
    }
    javaValue = map;
  } else {
    throw new MappingException(String.format("Unsupported type %s", input.getClass().getName()));
  }
  return javaValue;
}
 
开发者ID:sai-pullabhotla,项目名称:catatumbo,代码行数:32,代码来源:CatchAllMapper.java


示例19: toDatastore

import com.google.cloud.datastore.StringValue; //导入依赖的package包/类
@Override
public ValueBuilder<?, ?, ?> toDatastore(Object input) {
  if (input == null) {
    return NullValue.newBuilder();
  }
  return StringValue.newBuilder(((LocalDateTime) input).format(FORMATTER));
}
 
开发者ID:sai-pullabhotla,项目名称:catatumbo,代码行数:8,代码来源:LocalDateTimeMapper.java


示例20: testIndex_2

import com.google.cloud.datastore.StringValue; //导入依赖的package包/类
@Test
public void testIndex_2() {
  StringValue input = StringValue.of("Hello World");
  StringValue output = (StringValue) indexer.index(input);
  assertEquals(input.get().toLowerCase(Locale.ENGLISH), output.get());
  assertNotEquals(input.get(), output.get());
}
 
开发者ID:sai-pullabhotla,项目名称:catatumbo,代码行数:8,代码来源:LowerCaseStringIndexerTest.java



注:本文中的com.google.cloud.datastore.StringValue类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Term类代码示例发布时间:2022-05-23
下一篇:
Java JMessageDialog类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap