当前位置: 首页>>代码示例>>Java>>正文


Java ObjectWithSchema类代码示例

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


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

示例1: onNext

import com.mercateo.common.rest.schemagen.types.ObjectWithSchema; //导入依赖的package包/类
@Override
public void onNext(Fact f) {
    final OutboundEvent.Builder eventBuilder = new OutboundEvent.Builder();
    eventBuilder.name("new-fact");
    ObjectWithSchema<?> withSchema = createPayload(f, fullOutputMode);

    eventBuilder.data(withSchema);
    eventBuilder.mediaType(MediaType.APPLICATION_JSON_TYPE);
    eventBuilder.id(f.id().toString());
    final OutboundEvent event = eventBuilder.build();
    try {
        eventOutput.write(event);
    } catch (IOException e) {
        unsubscribe();
        log.debug("Error while writing into the pipe", e);
    }
}
 
开发者ID:uweschaefer,项目名称:factcast,代码行数:18,代码来源:FactsObserver.java

示例2: forRoot

import com.mercateo.common.rest.schemagen.types.ObjectWithSchema; //导入依赖的package包/类
ObjectWithSchema<Void> forRoot() {
    val getFactsLink = factsResourceLinkFactory.forCall(FactsRel.FACT_IDS, r -> r
            .getServerSentEvents(null));

    val getFullFactsLink = factsResourceLinkFactory.forCall(FactsRel.FULL_FACTS, r -> r
            .getServerSentEventsFull(null));
    val createLink = transactionsLinkFactory.forCall(FactsRel.CREATE_TRANSACTIONAL, r -> r
            .newTransaction(null));

    return hyperSchemaCreator.create(null, collect(getFactsLink, getFullFactsLink, createLink));
}
 
开发者ID:uweschaefer,项目名称:factcast,代码行数:12,代码来源:RootSchemaCreator.java

示例3: getForId

import com.mercateo.common.rest.schemagen.types.ObjectWithSchema; //导入依赖的package包/类
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}")
@Cacheable
public ObjectWithSchema<FactJson> getForId(@NotNull @PathParam("id") String id) {
    Optional<Fact> fact;
    try {
        fact = factStore.fetchById(UUID.fromString(id));
    } catch (IllegalArgumentException e) {
        throw new NotFoundException();
    }
    FactJson returnValue = fact.map(factTransformer::toJson).orElseThrow(
            NotFoundException::new);
    return schemaCreator.forFactWithId(returnValue);
}
 
开发者ID:uweschaefer,项目名称:factcast,代码行数:16,代码来源:FactsResource.java

示例4: getRoot

import com.mercateo.common.rest.schemagen.types.ObjectWithSchema; //导入依赖的package包/类
@GET
@Produces(MediaType.APPLICATION_JSON)
@NoCache
public ObjectWithSchema<Void> getRoot() {
    return schemaCreator.forRoot();

}
 
开发者ID:uweschaefer,项目名称:factcast,代码行数:8,代码来源:RootResource.java

示例5: testOnNext

import com.mercateo.common.rest.schemagen.types.ObjectWithSchema; //导入依赖的package包/类
@Test
public void testOnNext() throws Exception {
    uut.onNext(TestFacts.one);
    ArgumentCaptor<OutboundEvent> cap = ArgumentCaptor.forClass(OutboundEvent.class);
    verify(eventOutput).write(cap.capture());
    OutboundEvent ev = cap.getValue();
    @SuppressWarnings("unchecked")
    JsonHyperSchema jsonHyperSchema = ((ObjectWithSchema<Void>) ev.getData()).schema;
    assertTrue(jsonHyperSchema.getByRel(Rel.CANONICAL).isPresent());
    assertThat(ev.getId(), is(TestFacts.one.id().toString()));
}
 
开发者ID:uweschaefer,项目名称:factcast,代码行数:12,代码来源:FactsObserver0Test.java

示例6: testCreationOfFulltype

import com.mercateo.common.rest.schemagen.types.ObjectWithSchema; //导入依赖的package包/类
@Test
public void testCreationOfFulltype() throws Exception {

    ObjectWithSchema<FactJson> object = (ObjectWithSchema<FactJson>) uut.createPayload(
            TestFacts.one, true);
    assertThat(object.object.header().id(), is(TestFacts.one.id()));
}
 
开发者ID:uweschaefer,项目名称:factcast,代码行数:8,代码来源:FactsObserver0Test.java

示例7: testCreationOfIdType

import com.mercateo.common.rest.schemagen.types.ObjectWithSchema; //导入依赖的package包/类
@Test
public void testCreationOfIdType() throws Exception {

    ObjectWithSchema<FactIdJson> object = (ObjectWithSchema<FactIdJson>) uut.createPayload(
            TestFacts.one, false);
    assertThat(object.object.id(), is(TestFacts.one.id().toString()));
}
 
开发者ID:uweschaefer,项目名称:factcast,代码行数:8,代码来源:FactsObserver0Test.java

示例8: testGetForId

import com.mercateo.common.rest.schemagen.types.ObjectWithSchema; //导入依赖的package包/类
@Test
public void testGetForId() throws Exception {
    when(factStore.fetchById(TestFacts.one.id())).thenReturn(Optional.of(TestFacts.one));
    ObjectWithSchema<FactJson> value = ObjectWithSchema.create(null, JsonHyperSchema.from(Lists
            .newArrayList()));
    when(schemaCreator.forFactWithId(any())).thenReturn(value);
    ObjectWithSchema<FactJson> result = uut.getForId(TestFacts.one.id().toString());
    assertThat(result, is(value));
}
 
开发者ID:uweschaefer,项目名称:factcast,代码行数:10,代码来源:FactsResource0Test.java

示例9: testGetForIdNotFound

import com.mercateo.common.rest.schemagen.types.ObjectWithSchema; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test(expected = NotFoundException.class)
public void testGetForIdNotFound() throws Exception {
    when(factStore.fetchById(TestFacts.one.id())).thenThrow(IllegalArgumentException.class);
    ObjectWithSchema<FactJson> value = ObjectWithSchema.create(null, JsonHyperSchema.from(Lists
            .newArrayList()));
    when(schemaCreator.forFactWithId(any())).thenReturn(value);
    uut.getForId(TestFacts.one.id().toString());

}
 
开发者ID:uweschaefer,项目名称:factcast,代码行数:11,代码来源:FactsResource0Test.java

示例10: getListing

import com.mercateo.common.rest.schemagen.types.ObjectWithSchema; //导入依赖的package包/类
@SuppressWarnings("boxing")
@GET
@Produces(MediaType.APPLICATION_JSON)
public PaginatedResponse<SummaryJsonType> getListing(@BeanParam @NotNull @Valid SearchQueryBean searchQueryBean) {
	final ListingResult<SummaryJsonType> summaries = getSummaryListing(searchQueryBean);

	final LinkFactory<ImplementationType> lf = getImplementationLinkFactory();

	final List<ObjectWithSchema<SummaryJsonType>> listForResponse = summaries.getResultList().stream()
			.map(r -> getResponse(r, lf)).collect(Collectors.toList());

	List<Link> links = Lists.newArrayList();
	lf.forCall(REL_INSTANCE, r -> r.get(IdParameterBean.of(null))).ifPresent(links::add);
	int offset = searchQueryBean.getOffset();
	int limit = searchQueryBean.getLimit();
	PaginationLinkBuilder paginationLinkBuilder = PaginationLinkBuilder.of(summaries.getTotalNumberOfHits(),
			searchQueryBean.getOffset(), searchQueryBean.getLimit());
	links.addAll(paginationLinkBuilder.generateLinks((rel, off, lim) -> {
		searchQueryBean.setLimit(lim);
		searchQueryBean.setOffset(off);
		return lf.forCall(rel, r -> r.getListing(searchQueryBean));
	}));
	links.addAll(createAdditionalLinksForListing(searchQueryBean));

	return PaginatedResponse.create(listForResponse, summaries.getTotalNumberOfHits(), offset, limit,
			JsonHyperSchema.from(links));
}
 
开发者ID:Mercateo,项目名称:rest-jersey-utils,代码行数:28,代码来源:AbstractListingResource.java

示例11: getSummary

import com.mercateo.common.rest.schemagen.types.ObjectWithSchema; //导入依赖的package包/类
@GET
@Path("{id}/summary")
@Produces(MediaType.APPLICATION_JSON)
public ObjectWithSchema<SummaryJsonType> getSummary(@NotNull @BeanParam @Valid IdParameterBean idParamBean) {
	String id = idParamBean.getId();
	final SummaryJsonType summaryJson = getSummaryForId(id);
	return getResponse(summaryJson, getImplementationLinkFactory());
}
 
开发者ID:Mercateo,项目名称:rest-jersey-utils,代码行数:9,代码来源:AbstractListingResource.java

示例12: get

import com.mercateo.common.rest.schemagen.types.ObjectWithSchema; //导入依赖的package包/类
@GET
@Path("{id}")
@Produces(MediaType.APPLICATION_JSON)
public ObjectWithSchema<FullJsonType> get(@NotNull @Valid @BeanParam IdParameterBean idParameterBean) {
	String id = idParameterBean.getId();
	final FullJsonType json = getForId(id);
	return getResponse(json);
}
 
开发者ID:Mercateo,项目名称:rest-jersey-utils,代码行数:9,代码来源:AbstractListingResource.java

示例13: getResponse

import com.mercateo.common.rest.schemagen.types.ObjectWithSchema; //导入依赖的package包/类
protected ObjectWithSchema<FullJsonType> getResponse(FullJsonType json) {
	final LinkFactory<ImplementationType> factoryForImplementation = getImplementationLinkFactory();
	final Optional<Link> selfLink = factoryForImplementation.forCall(Rel.SELF,
			r -> r.get(IdParameterBean.of(json.getId())));

	final ArrayList<Optional<Link>> result = Lists.newArrayList(selfLink);

	final List<Optional<Link>> additionalLinks = createAdditionalLinksForFullType(json, factoryForImplementation);

	result.addAll(additionalLinks);

	final JsonHyperSchema hyperSchema = JsonHyperSchema.fromOptional(result);
	return ObjectWithSchema.create(json, hyperSchema);
}
 
开发者ID:Mercateo,项目名称:rest-jersey-utils,代码行数:15,代码来源:AbstractListingResource.java

示例14: getSomething

import com.mercateo.common.rest.schemagen.types.ObjectWithSchema; //导入依赖的package包/类
@Path("/method/{id}")
@GET
@RolesAllowed("test")
@Produces(MediaType.APPLICATION_JSON)
public ObjectWithSchema<Something> getSomething(@PathParam("id") String id) {
	Optional<Link> link = linkMetaFactory.createFactoryFor(ResourceClass.class).forCall(Rel.SELF,
			r -> r.getSomething(id));

	return ObjectWithSchema.create(new Something(), JsonHyperSchema.from(link));
}
 
开发者ID:Mercateo,项目名称:rest-schemagen,代码行数:11,代码来源:ResourceClass.java

示例15: getWithQuery

import com.mercateo.common.rest.schemagen.types.ObjectWithSchema; //导入依赖的package包/类
@Path("/method/value")
@GET
@Produces(MediaType.APPLICATION_JSON)
public ObjectWithSchema<Void> getWithQuery(@QueryParam("test") String test) {

	return ObjectWithSchema.create(null, null);
}
 
开发者ID:Mercateo,项目名称:rest-schemagen,代码行数:8,代码来源:ResourceClass.java


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