com.linecorp.centraldogma.common.Query.apply()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(4.1k)|赞(0)|评价(0)|浏览(84)

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

Query.apply介绍

暂无

代码示例

代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server-shaded

/**
 * Performs the specified {@link Query}.
 *
 * @return the {@link Entry} on a successful query.
 *         The specified {@code other} on a failure due to missing entry.
 *
 * @see #get(Revision, Query)
 */
default <T> CompletableFuture<Entry<T>> getOrNull(Revision revision, Query<T> query) {
  requireNonNull(query, "query");
  requireNonNull(revision, "revision");
  return getOrNull(revision, query.path()).thenApply(entry -> {
    if (entry == null) {
      return null;
    }
    final EntryType entryType = entry.type();
    if (!query.type().supportedEntryTypes().contains(entryType)) {
      throw new QueryExecutionException("unsupported entry type: " + entryType);
    }
    @SuppressWarnings("unchecked")
    final T entryContent = (T) entry.content();
    try {
      return Entry.of(entry.revision(), query.path(), entryType, query.apply(entryContent));
    } catch (CentralDogmaException e) {
      throw e;
    } catch (Exception e) {
      throw new QueryExecutionException(e);
    }
  });
}

代码示例来源:origin: line/centraldogma

/**
 * Applies the specified {@link Query} to the {@link Entry#content()} of the specified {@link Entry} and
 * returns the query result.
 *
 * @throws IllegalStateException if the specified {@link Entry} is a directory
 * @throws QuerySyntaxException if the syntax of specified {@link Query} is invalid
 * @throws QueryExecutionException if an {@link Exception} is raised while applying the specified
 *                                 {@link Query} to the {@link Entry#content()}
 */
static <T> Entry<T> applyQuery(Entry<T> entry, Query<T> query) {
  requireNonNull(query, "query");
  entry.content(); // Ensure that content is not null.
  final EntryType entryType = entry.type();
  final QueryType queryType = query.type();
  if (!queryType.supportedEntryTypes().contains(entryType)) {
    throw new QueryExecutionException("Unsupported entry type: " + entryType +
                     " (query: " + query + ')');
  }
  if (queryType == IDENTITY) {
    return entry;
  } else if (queryType == JSON_PATH) {
    return Entry.of(entry.revision(), query.path(), entryType, query.apply(entry.content()));
  } else {
    throw new QueryExecutionException("Unsupported entry type: " + entryType +
                     " (query: " + query + ')');
  }
}

代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server

/**
 * Applies the specified {@link Query} to the {@link Entry#content()} of the specified {@link Entry} and
 * returns the query result.
 *
 * @throws IllegalStateException if the specified {@link Entry} is a directory
 * @throws QuerySyntaxException if the syntax of specified {@link Query} is invalid
 * @throws QueryExecutionException if an {@link Exception} is raised while applying the specified
 *                                 {@link Query} to the {@link Entry#content()}
 */
static <T> Entry<T> applyQuery(Entry<T> entry, Query<T> query) {
  requireNonNull(query, "query");
  entry.content(); // Ensure that content is not null.
  final EntryType entryType = entry.type();
  final QueryType queryType = query.type();
  if (!queryType.supportedEntryTypes().contains(entryType)) {
    throw new QueryExecutionException("Unsupported entry type: " + entryType +
                     " (query: " + query + ')');
  }
  if (queryType == IDENTITY) {
    return entry;
  } else if (queryType == JSON_PATH) {
    return Entry.of(entry.revision(), query.path(), entryType, query.apply(entry.content()));
  } else {
    throw new QueryExecutionException("Unsupported entry type: " + entryType +
                     " (query: " + query + ')');
  }
}

代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server-shaded

final Object toContent = castQuery.apply(toEntry.content());
final Object fromContent = castQuery.apply(fromEntry.content());
final Object toContent = castQuery.apply(toEntry.content());

代码示例来源:origin: line/centraldogma

final Object toContent = castQuery.apply(toEntry.content());
final Object fromContent = castQuery.apply(fromEntry.content());
final Object toContent = castQuery.apply(toEntry.content());

代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server

final Object toContent = castQuery.apply(toEntry.content());
final Object fromContent = castQuery.apply(fromEntry.content());
final Object toContent = castQuery.apply(toEntry.content());

相关文章