Package com.asakusafw.runtime.value

Examples of com.asakusafw.runtime.value.IntOption


        return object.get();
    }

    @Override
    public Object getPrimitiveWritableObject(Object o) {
        IntOption object = (IntOption) o;
        if (object == null || object.isNull()) {
            return null;
        }
        return new IntWritable(object.get());
    }
View Full Code Here


        ModelInput<Object> reader = support.createInput(model.unwrap().getClass(), "testing", in(output),
                0, size(output));
        assertThat(reader.readTo(buffer.unwrap()), is(true));
        assertThat(buffer.getOption("value"), is((Object) new StringOption("Hello\nworld!")));
        assertThat(buffer.getOption("number"), is((Object) new IntOption(1)));
        assertThat(reader.readTo(buffer.unwrap()), is(true));
        assertThat(buffer.getOption("value"), is((Object) new StringOption("Hello\nworld!")));
        assertThat(buffer.getOption("number"), is((Object) new IntOption(3)));
        assertThat(reader.readTo(buffer.unwrap()), is(false));
    }
View Full Code Here

                result);
        Writable key = (Writable) create(loader, shuffle.getCompiled().getKeyTypeName());
        Writable value = (Writable) create(loader, shuffle.getCompiled().getValueTypeName());

        Ex1 orig = new Ex1();
        orig.setValueOption(new IntOption().modify(100));
        ExSummarized model = new ExSummarized();
        model.setValue(100);
        model.setCount(1);

        invoke(key, Naming.getShuffleKeySetter(1), model);
View Full Code Here

        }
    }

    private void checlValues(List<Ex1> results, int value) {
        for (Ex1 ex1 : results) {
            assertThat(ex1.getValueOption(), is(new IntOption(value)));
        }
    }
View Full Code Here

            }
            return false;
        }

        private FieldDeclaration createRandomHolder() {
            new IntOption().modify(index);
            return factory.newFieldDeclaration(
                    null,
                    new AttributeBuilder(factory)
                        .Private()
                        .Final()
View Full Code Here

        ((LongOption) union.switchObject(1)).modify(200L);
        assertThat(union.getPosition(), is(1));
        ((StringOption) union.switchObject(2)).modify("Hello, world!");
        assertThat(union.getPosition(), is(2));

        assertThat(union.switchObject(0), is((Object) new IntOption(100)));
        assertThat(union.switchObject(1), is((Object) new LongOption(200L)));
        assertThat(union.switchObject(2), is((Object) new StringOption("Hello, world!")));
    }
View Full Code Here

     * @throws Exception if failed
     */
    @Test
    public void createFromObject() throws Exception {
        Union union = new WritableUnion(
                new IntOption(100),
                new LongOption(200L),
                new StringOption("Hello, world!"));
        assertThat(union.switchObject(0), is((Object) new IntOption(100)));
        assertThat(union.switchObject(1), is((Object) new LongOption(200L)));
        assertThat(union.switchObject(2), is((Object) new StringOption("Hello, world!")));
    }
View Full Code Here

     * @throws Exception if failed
     */
    @Test
    public void serialize() throws Exception {
        WritableUnion union = new WritableUnion(
                new IntOption(100),
                new LongOption(200L),
                new StringOption("Hello, world!"),
                new StringOption());

        StringBuilder buf = new StringBuilder(100000);
        for (int i = 0, n = buf.capacity(); i < n; i++) {
            buf.append((char) ('A' + (i * 257 % 26)));
        }
        ((StringOption) union.switchObject(3)).modify(buf.toString());

        WritableUnion r0 = new WritableUnion(IntOption.class, LongOption.class, StringOption.class);
        union.switchObject(0);
        byte[] s0 = ser(union);
        des(r0, s0);
        assertThat(r0.getPosition(), is(0));
        assertThat(r0.getObject(), is((Object) new IntOption(100)));

        WritableUnion r1 = new WritableUnion(IntOption.class, LongOption.class, StringOption.class);
        union.switchObject(1);
        byte[] s1 = ser(union);
        des(r1, s1);
View Full Code Here

    public void simple() {
        ModelLoader loader = generate();
        ModelWrapper object = loader.newModel("Simple");
        object.set("value", 100);
        assertThat(object.get("value"), eq(100));
        assertThat(object.getOption("value"), eq(new IntOption(100)));
        object.setOption("value", new IntOption(200));
        assertThat(object.get("value"), eq(200));

        ModelWrapper copy = loader.newModel("Simple");
        copy.copyFrom(object);
View Full Code Here

     * intの値を解析するテスト。
     * @throws Exception 例外が発生した場合
     */
    @Test
    public void fillInt() throws Exception {
        IntOption value = new IntOption();
        create("int");

        assertThat(parser.next(), is(true));
        parser.fill(value);
        assertThat(value.get(), is(0));
        parser.fill(value);
        assertThat(value.get(), is(10));
        parser.fill(value);
        assertThat(value.get(), is(-10));
        parser.endRecord();

        assertThat(parser.next(), is(true));
        parser.fill(value);
        assertThat(value.isNull(), is(true));
        parser.fill(value);
        assertThat(value.get(), is(Integer.MAX_VALUE));
        parser.fill(value);
        assertThat(value.get(), is(Integer.MIN_VALUE));
        parser.endRecord();

        assertThat(parser.next(), is(false));
    }
View Full Code Here

TOP

Related Classes of com.asakusafw.runtime.value.IntOption

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.