com.vmware.xenon.common.Utils.buildKind()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(107)

本文整理了Java中com.vmware.xenon.common.Utils.buildKind()方法的一些代码示例,展示了Utils.buildKind()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.buildKind()方法的具体详情如下:
包路径:com.vmware.xenon.common.Utils
类名称:Utils
方法名:buildKind

Utils.buildKind介绍

[英]Builds a kind string from a type. It uses a cache to lookup the type to kind mapping. The mapping can be overridden with Utils#registerKind(Class, String)
[中]

代码示例

代码示例来源:origin: vmware/admiral

public TableDescription setStateType(Class<? extends ServiceDocument> stateType) {
  this.stateType = stateType;
  this.documentKind = Utils.buildKind(stateType);
  return this;
}

代码示例来源:origin: vmware/xenon

/**
 * Add a clause which matches the {@linkplain ServiceDocument#documentKind document kind} of the provided class.
 * @param documentClass the service document class.
 * @return a reference to this object.
 */
public Builder addKindFieldClause(Class<? extends ServiceDocument> documentClass) {
  return addFieldClause(FIELD_NAME_KIND, Utils.buildKind(documentClass));
}

代码示例来源:origin: vmware/xenon

/**
 * Add a clause with the specified occurance which matches the
 * {@linkplain ServiceDocument#documentKind document kind} of the provided class.
 * @param documentClass the service document class.
 * @param occurance the occurance for this clause.
 * @return a reference to this object.
 */
public Builder addKindFieldClause(Class<? extends ServiceDocument> documentClass,
    Occurance occurance) {
  return addFieldClause(FIELD_NAME_KIND, Utils.buildKind(documentClass), occurance);
}

代码示例来源:origin: vmware/admiral

public static QueryTask buildQuery(Class<? extends ServiceDocument> stateClass,
    boolean direct, QueryTask.Query... clauses) {
  String kind = Utils.buildKind(stateClass);
  return buildQuery(kind, direct, clauses);
}

代码示例来源:origin: com.vmware.xenon/xenon-swagger

private ServiceDocument template(Class<? extends ServiceDocument> type) {
  ServiceDocumentDescription desc = ServiceDocumentDescription.Builder
      .create()
      .buildDescription(type);
  try {
    ServiceDocument res = type.newInstance();
    res.documentDescription = desc;
    res.documentKind = Utils.buildKind(type);
    return res;
  } catch (ReflectiveOperationException e) {
    throw new AssertionError(e);
  }
}

代码示例来源:origin: com.vmware.xenon/xenon-swagger

private ModelImpl modelForPodo(Class<?> type) {
  PropertyDescription pd = Builder.create()
      .buildPodoPropertyDescription(type);
  pd.kind = Utils.buildKind(type);
  return this.modelRegistry.getModel(pd);
}

代码示例来源:origin: vmware/admiral

public static QueryTask.Query createKindClause(Class<?> c) {
  QueryTask.Query kindClause = new QueryTask.Query()
      .setTermPropertyName(ServiceDocument.FIELD_NAME_KIND)
      .setTermMatchValue(Utils.buildKind(c));
  return kindClause;
}

代码示例来源:origin: com.vmware.xenon/xenon-swagger

private Parameter paramNamedBody(Class<?> type) {
  BodyParameter res = paramBody(type);
  res.setName(PARAM_NAME_BODY + AS_SEPARATOR + shortenKind(Utils.buildKind(type)));
  return res;
}

代码示例来源:origin: vmware/xenon

private ServiceStats populateDocumentProperties(ServiceStats stats) {
  ServiceStats clone = new ServiceStats();
  // sort entries by key (natural ordering)
  clone.entries = new TreeMap<>(stats.entries);
  clone.documentUpdateTimeMicros = stats.documentUpdateTimeMicros;
  clone.documentSelfLink = UriUtils.buildUriPath(this.parent.getSelfLink(),
      ServiceHost.SERVICE_URI_SUFFIX_STATS);
  clone.documentOwner = getHost().getId();
  clone.documentKind = Utils.buildKind(ServiceStats.class);
  return clone;
}

代码示例来源:origin: vmware/xenon

private void complete(Operation op) {
  close();
  ServiceHostLogService.LogServiceState state = new ServiceHostLogService.LogServiceState();
  state.documentKind = Utils.buildKind(LogServiceState.class);
  state.documentSelfLink = this.parentSelfLink;
  state.items = this.lines;
  op.setBody(state).complete();
}

代码示例来源:origin: vmware/xenon

@Test
public void registerKind() {
  String kindBefore = Utils.buildKind(ExampleServiceState.class);
  String newKind = "e";
  Utils.registerKind(ExampleServiceState.class, newKind);
  String kindAfter = Utils.buildKind(ExampleServiceState.class);
  assertEquals(newKind, kindAfter);
  Utils.registerKind(ExampleServiceState.class, kindBefore);
  kindAfter = Utils.buildKind(ExampleServiceState.class);
  assertEquals(kindBefore, kindAfter);
  Class<?> stateClass = Utils.getTypeFromKind(kindAfter);
  assertEquals(stateClass.getCanonicalName(), ExampleServiceState.class.getCanonicalName());
}

代码示例来源:origin: com.vmware.xenon/xenon-common

@Test
public void registerKind() {
  String kindBefore = Utils.buildKind(ExampleServiceState.class);
  String newKind = "e";
  Utils.registerKind(ExampleServiceState.class, newKind);
  String kindAfter = Utils.buildKind(ExampleServiceState.class);
  assertEquals(newKind, kindAfter);
  Utils.registerKind(ExampleServiceState.class, kindBefore);
  kindAfter = Utils.buildKind(ExampleServiceState.class);
  assertEquals(kindBefore, kindAfter);
  Class<?> stateClass = Utils.getTypeFromKind(kindAfter);
  assertEquals(stateClass.getCanonicalName(), ExampleServiceState.class.getCanonicalName());
}

代码示例来源:origin: com.vmware.xenon/xenon-common

private SynchronizationTaskService.State createSynchronizationTaskState(
    Long membershipUpdateTimeMicros, String factoryLink, Class<? extends ServiceDocument> type) {
  SynchronizationTaskService.State task = new SynchronizationTaskService.State();
  task.documentSelfLink = UriUtils.convertPathCharsFromLink(factoryLink);
  task.factorySelfLink = factoryLink;
  task.factoryStateKind = Utils.buildKind(type);
  task.membershipUpdateTimeMicros = membershipUpdateTimeMicros;
  task.nodeSelectorLink = ServiceUriPaths.DEFAULT_NODE_SELECTOR;
  task.queryResultLimit = 1000;
  task.taskInfo = TaskState.create();
  task.taskInfo.isDirect = true;
  return task;
}

代码示例来源:origin: vmware/xenon

private SynchronizationTaskService.State createSynchronizationTaskState(
    Long membershipUpdateTimeMicros, String factoryLink, Class<? extends ServiceDocument> type) {
  SynchronizationTaskService.State task = new SynchronizationTaskService.State();
  task.documentSelfLink = UriUtils.convertPathCharsFromLink(factoryLink);
  task.factorySelfLink = factoryLink;
  task.factoryStateKind = Utils.buildKind(type);
  task.membershipUpdateTimeMicros = membershipUpdateTimeMicros;
  task.nodeSelectorLink = ServiceUriPaths.DEFAULT_NODE_SELECTOR;
  task.queryResultLimit = 1000;
  task.taskInfo = TaskState.create();
  task.taskInfo.isDirect = true;
  return task;
}

代码示例来源:origin: vmware/admiral

private void verifyDeleteSuccessfulAsUser(String userEmail, ServiceDocument state,
    String factoryServiceSelfLink) throws Throwable {
  host.assumeIdentity(buildUserServicePath(userEmail));
  createState(state, factoryServiceSelfLink);
  List<String> allStatesLinks = getDocumentLinksOfType(state.getClass());
  Assert.assertEquals(1, allStatesLinks.size());
  ServiceDocumentDeleteTaskState taskState = new ServiceDocumentDeleteTaskState();
  taskState.deleteDocumentKind = Utils.buildKind(state.getClass());
  taskState = doPost(taskState, ServiceDocumentDeleteTaskService.FACTORY_LINK);
  waitForTaskCompletion(taskState.documentSelfLink, ServiceDocumentDeleteTaskState.class);
  allStatesLinks = getDocumentLinksOfType(state.getClass());
  Assert.assertEquals(0, allStatesLinks.size());
}

代码示例来源:origin: com.vmware.photon.controller/photon-model-tasks

private static ResourceRemovalTaskState buildValidStartState() {
  ResourceRemovalTaskState startState = new ResourceRemovalTaskState();
  startState.resourceQuerySpec = new QueryTask.QuerySpecification();
  QueryTask.Query kindClause = new QueryTask.Query().setTermPropertyName(
      ServiceDocument.FIELD_NAME_KIND).setTermMatchValue(
      Utils.buildKind(ComputeService.ComputeState.class));
  startState.resourceQuerySpec.query.addBooleanClause(kindClause);
  startState.isMockRequest = true;
  return startState;
}

代码示例来源:origin: com.vmware.xenon/xenon-common

private void validateBinaryExampleServiceState(Object queryResult, String link, Long counter) {
  ServiceDocument serviceDocument = Utils.fromQueryBinaryDocument(link, queryResult);
  assertNotNull(serviceDocument);
  ExampleServiceState resultState = (ExampleServiceState) serviceDocument;
  assertEquals(counter, resultState.counter);
  assertEquals(Action.POST.toString(), resultState.documentUpdateAction);
  assertEquals(Utils.buildKind(ExampleServiceState.class), resultState.documentKind);
  assertNotNull(resultState.name);
}

代码示例来源:origin: vmware/xenon

private void validateBinaryExampleServiceState(Object queryResult, String link, Long counter) {
  ServiceDocument serviceDocument = Utils.fromQueryBinaryDocument(link, queryResult);
  assertNotNull(serviceDocument);
  ExampleServiceState resultState = (ExampleServiceState) serviceDocument;
  assertEquals(counter, resultState.counter);
  assertEquals(Action.POST.toString(), resultState.documentUpdateAction);
  assertEquals(Utils.buildKind(ExampleServiceState.class), resultState.documentKind);
  assertNotNull(resultState.name);
}

代码示例来源:origin: vmware/xenon

@Test
public void serializeDocumentForIndexing() {
  ExampleServiceState state = new ExampleServiceState();
  state.documentSelfLink = "selfLink";
  state.documentKind = Utils.buildKind(ExampleServiceState.class);
  Output o = KryoSerializers.serializeDocumentForIndexing(state, 2048);
  ExampleServiceState deser = (ExampleServiceState) KryoSerializers.deserializeDocument(
      o.getBuffer(), 0,
      o.position());
  assertNull(deser.documentSelfLink);
  assertNull(deser.documentKind);
}

代码示例来源:origin: com.vmware.xenon/xenon-common

@Test
public void serializeDocumentForIndexing() {
  ExampleServiceState state = new ExampleServiceState();
  state.documentSelfLink = "selfLink";
  state.documentKind = Utils.buildKind(ExampleServiceState.class);
  Output o = KryoSerializers.serializeDocumentForIndexing(state, 2048);
  ExampleServiceState deser = (ExampleServiceState) KryoSerializers.deserializeDocument(
      o.getBuffer(), 0,
      o.position());
  assertNull(deser.documentSelfLink);
  assertNull(deser.documentKind);
}

相关文章