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


Java FieldType类代码示例

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


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

示例1: buildBook

import com.google.code.siren4j.meta.FieldType; //导入依赖的package包/类
public Entity buildBook(Book book, boolean addToCartActionIncluded, UriInfo uriInfo) {
    final com.google.code.siren4j.component.builder.EntityBuilder entityBuilder = createEntityBuilder().setComponentClass("book")
            .addLink(linkBuilder.forBook(book, uriInfo))
            .addProperty("isbn", book.getIsbn())
            .addProperty("name", book.getName())
            .addProperty("author", book.getAuthor())
            .addProperty("availability", book.getAvailability())
            .addProperty("price", book.getPrice());


    if (addToCartActionIncluded)
        entityBuilder.addAction(createActionBuilder().setName("add-to-cart")
                .setTitle("Add book to cart")
                .setMethod(ActionImpl.Method.POST)
                .setHref(linkBuilder.forShoppingCart(uriInfo).getHref())
                .setType(MediaType.APPLICATION_JSON)
                .addField(createFieldBuilder().setName("isbn").setType(FieldType.TEXT).setRequired(true).build())
                .addField(createFieldBuilder().setName("quantity").setType(FieldType.NUMBER).setRequired(true).build())
                .build());

    return entityBuilder.build();
}
 
开发者ID:sdaschner,项目名称:jaxrs-hypermedia,代码行数:23,代码来源:EntityBuilder.java

示例2: testBuild

import com.google.code.siren4j.meta.FieldType; //导入依赖的package包/类
@Test
public void testBuild() throws Exception {
	String fieldName = "code";
	FieldType fieldType = FieldType.HIDDEN;
	String fieldValue = "3455";
	
	Field result = builder.setName(fieldName)
	    .setType(fieldType)
	    .setValue(fieldValue)
           .addOption("foo", "bar", false)
	    .build();
	
	assertEquals(fieldName, result.getName());
	assertEquals(fieldType, result.getType());
	assertEquals(fieldValue, result.getValue());
	System.out.println(result.toString());
}
 
开发者ID:eserating,项目名称:siren4j,代码行数:18,代码来源:FieldBuilderTest.java

示例3: places

import com.google.code.siren4j.meta.FieldType; //导入依赖的package包/类
private List<Entity> places() {
    return hotel.getPlaces().stream().
            map(room -> EntityBuilder.newInstance().
                    setRelationship("hotel-place").
                    addProperty("type", room.getType().name().toLowerCase()).
                    addProperty("category", room.getCategory().name().toLowerCase()).
                    addProperty("price", room.getPrice()).
                    addAction(ActionBuilder.newInstance().
                            setName("book-as-place").
                            setComponentClass("booking-place").
                            setMethod(ActionImpl.Method.POST).
                            setHref(uriInfo.getBaseUriBuilder().path(BookingsResource.class).build().toString()).
                            setType(MediaType.APPLICATION_JSON).
                            addField(
                                    FieldBuilder.newInstance().
                                            setName("placeId").
                                            setType(FieldType.TEXT).
                                            setValue(room.getId().toString()).
                                            build()).
                            addFields(new SaveBookingFieldsBuilder().build()).
                            build()).
                    build()).
            collect(Collectors.toList());
}
 
开发者ID:vtsukur,项目名称:take-a-REST,代码行数:25,代码来源:HotelWithPlacesRepresentationBuilder.java

示例4: buildBookSelection

import com.google.code.siren4j.meta.FieldType; //导入依赖的package包/类
private Entity buildBookSelection(BookSelection selection, UriInfo uriInfo, boolean hypertextIncluded, boolean asSubEntity) {
    final Book book = selection.getBook();
    final Entity bookEntity = createEntityBuilder().setComponentClass("book")
            .setRelationship("item")
            .addLink(linkBuilder.forBook(book, uriInfo))
            .addProperty("isbn", book.getIsbn())
            .addProperty("name", book.getName())
            .addProperty("price", book.getPrice())
            .build();

    final com.google.code.siren4j.component.builder.EntityBuilder selectionBuilder = createEntityBuilder().setComponentClass("book-selection")
            .addProperty("quantity", selection.getQuantity())
            .addProperty("price", selection.getPrice())
            .addSubEntity(bookEntity);

    if (asSubEntity)
        selectionBuilder.setRelationship("item");

    if (hypertextIncluded) {
        selectionBuilder.addAction(createActionBuilder().setName("modify-book-selection")
                .setTitle("Modify book cart selection")
                .setMethod(ActionImpl.Method.PUT)
                .setHref(linkBuilder.forBookSelection(selection, uriInfo).getHref())
                .setType(MediaType.APPLICATION_JSON)
                .addField(createFieldBuilder().setName("quantity").setType(FieldType.NUMBER).setRequired(true).build())
                .build());
        selectionBuilder.addAction(createActionBuilder().setName("delete-book-selection")
                .setTitle("Delete book cart selection")
                .setMethod(ActionImpl.Method.DELETE)
                .setHref(linkBuilder.forBookSelection(selection, uriInfo).getHref())
                .build());
        selectionBuilder.addLink(linkBuilder.forBookSelection(selection, uriInfo));
    }

    return selectionBuilder.build();
}
 
开发者ID:sdaschner,项目名称:jaxrs-hypermedia,代码行数:37,代码来源:EntityBuilder.java

示例5: createField

import com.google.code.siren4j.meta.FieldType; //导入依赖的package包/类
private Field createField(String name, FieldType type, String value) {
    FieldBuilder builder = FieldBuilder.newInstance();
    builder.setName(name)
            .setType(type);
    if (StringUtils.isNotBlank(value)) {
        builder.setValue(value);
    }
    return builder.build();

}
 
开发者ID:eserating,项目名称:siren4j,代码行数:11,代码来源:EntitySerializationTest.java

示例6: testRequiredName

import com.google.code.siren4j.meta.FieldType; //导入依赖的package包/类
@Test
public void testRequiredName() throws Exception {
	try {
		builder.setType(FieldType.BUTTON).build();
		fail("Expected validation exception.");
	} catch (Exception e) {
		//Success
	}
	
}
 
开发者ID:eserating,项目名称:siren4j,代码行数:11,代码来源:FieldBuilderTest.java

示例7: testSetterOrdering

import com.google.code.siren4j.meta.FieldType; //导入依赖的package包/类
@Test
public void testSetterOrdering() throws Exception {
	//Last call to a particular setter should win.
	//This is really testing the BaseBuilder.
	Field result = builder.setName("foo")
			.setType(FieldType.TEXT)
			.setName("Bar")
			.setName("I win")
			.build();
	
	assertEquals("I win", result.getName());
}
 
开发者ID:eserating,项目名称:siren4j,代码行数:13,代码来源:FieldBuilderTest.java

示例8: addPaymentActionIfAvailable

import com.google.code.siren4j.meta.FieldType; //导入依赖的package包/类
private EntityBuilder addPaymentActionIfAvailable(final EntityBuilder entityBuilder) {
    if (booking.getState() == Booking.State.CREATED) {
        return entityBuilder.addAction(
                ActionBuilder.newInstance().
                        setName("pay").
                        setComponentClass("payment").
                        setMethod(ActionImpl.Method.POST).
                        setHref(selfHref() + "/payment").
                        setType("application/json").
                        addField(
                                FieldBuilder.newInstance().
                                        setName("cardholdersName").
                                        build()).
                        addField(
                                FieldBuilder.newInstance().
                                        setName("creditCardNumber").
                                        build()).
                        addField(
                                FieldBuilder.newInstance().
                                        setName("cvv").
                                        setType(FieldType.NUMBER).
                                        build()).
                        build());
    }
    else {
        return entityBuilder;
    }
}
 
开发者ID:vtsukur,项目名称:take-a-REST,代码行数:29,代码来源:BookingRepresentationBuilder.java

示例9: build

import com.google.code.siren4j.meta.FieldType; //导入依赖的package包/类
public List<Field> build() {
    return Arrays.asList(
            FieldBuilder.newInstance().
                    setName("checkIn").
                    setType(FieldType.DATE).
                    build(),
            FieldBuilder.newInstance().
                    setName("checkOut").
                    setType(FieldType.DATE).
                    build(),
            FieldBuilder.newInstance().
                    setName("includeBreakfast").
                    setType(FieldType.CHECKBOX).
                    build());
}
 
开发者ID:vtsukur,项目名称:take-a-REST,代码行数:16,代码来源:SaveBookingFieldsBuilder.java

示例10: getType

import com.google.code.siren4j.meta.FieldType; //导入依赖的package包/类
public FieldType getType() {
    return type;
}
 
开发者ID:eserating,项目名称:siren4j,代码行数:4,代码来源:FieldImpl.java

示例11: setType

import com.google.code.siren4j.meta.FieldType; //导入依赖的package包/类
public void setType(FieldType type) {
    this.type = type;
}
 
开发者ID:eserating,项目名称:siren4j,代码行数:4,代码来源:FieldImpl.java

示例12: setType

import com.google.code.siren4j.meta.FieldType; //导入依赖的package包/类
public FieldBuilder setType(FieldType type) {
    addStep("setType", new Object[] { type }, new Class<?>[] {FieldType.class});
    return this;
}
 
开发者ID:eserating,项目名称:siren4j,代码行数:5,代码来源:FieldBuilder.java

示例13: createTestEntity

import com.google.code.siren4j.meta.FieldType; //导入依赖的package包/类
private Entity createTestEntity() {

        //List item 1
        List<Entity> embedded1 = new ArrayList<Entity>();
        Map<String, Object> props1 = new HashMap<String, Object>();
        List<Link> links1 = new ArrayList<Link>();
        embedded1.add(createEmbeddedEntity("/baskets/98712", "basket"));
        embedded1.add(createEmbeddedEntity("/customer/7809", "basket"));
        props1.put("total", 30.00f);
        props1.put("currency", "USD");
        props1.put("status", "shipped");
        links1.add(createLink("/orders/123", Link.RELATIONSHIP_SELF));

        Entity listItem1 = createEntity(
                new String[]{"order", "list-item"},
                new String[]{"order"},
                props1,
                embedded1,
                links1,
                null
        );

        //List item 2
        List<Entity> embedded2 = new ArrayList<Entity>();
        Map<String, Object> props2 = new HashMap<String, Object>();
        List<Link> links2 = new ArrayList<Link>();
        embedded2.add(createEmbeddedEntity("/baskets/98713", "basket"));
        embedded2.add(createEmbeddedEntity("/customer/12369", "basket"));
        props2.put("total", 20.00f);
        props2.put("currency", "USD");
        props2.put("status", "processing");
        links2.add(createLink("/orders/124", Link.RELATIONSHIP_SELF));

        Entity listItem2 = createEntity(
                new String[]{"order", "list-item"},
                new String[]{"order"},
                props2,
                embedded2,
                links2,
                null
        );

        List<Action> orderActions = new ArrayList<Action>();
        List<Entity> orderEntities = new ArrayList<Entity>();
        List<Link> orderLinks = new ArrayList<Link>();
        Map<String, Object> orderProps = new HashMap<String, Object>();
        List<Field> actionFields = new ArrayList<Field>();

        actionFields.add(createField("id", FieldType.NUMBER, null));

        orderActions.add(createAction(
                "find-order",
                new String[]{"find-order"},
                (String) null,
                (Method) null,
                "/orders",
                (String) null,
                actionFields
        ));

        orderEntities.add(listItem1);
        orderEntities.add(listItem2);

        orderLinks.add(createLink("/orders", Link.RELATIONSHIP_SELF));
        orderLinks.add(createLink("/orders?page=2", Link.RELATIONSHIP_NEXT));

        orderProps.put("currentlyProcessing", 14);
        orderProps.put("shippedToday", 20);

        Entity orders = createEntity(new String[]{"orders"}, null, orderProps, orderEntities, orderLinks, orderActions);
        return orders;
    }
 
开发者ID:eserating,项目名称:siren4j,代码行数:73,代码来源:EntitySerializationTest.java

示例14: getType

import com.google.code.siren4j.meta.FieldType; //导入依赖的package包/类
/**
 * The field type. This may include any of the input types specified in HTML5.
 * default value is {@link FieldType.TEXT}. see {@link FieldType} for other allowed values (Optional).
 * @return never <code>null</code>. 
 */
public FieldType getType();
 
开发者ID:eserating,项目名称:siren4j,代码行数:7,代码来源:Field.java


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