Examples of PropertyBuilder


Examples of com.dtolabs.rundeck.plugins.util.PropertyBuilder

        }
        return null;
    }

    private static Property propertyFromField(final Field field, final PluginProperty annotation) {
        final PropertyBuilder pbuild = PropertyBuilder.builder();
        //determine type
        final Property.Type type = propertyTypeFromFieldType(field.getType());
        if (null == type) {
            return null;
        }
        pbuild.type(type);
        if (type == Property.Type.String) {
            StringRenderingConstants.DisplayType renderBehaviour = StringRenderingConstants.DisplayType.SINGLE_LINE;
            //set select/freeselect
            final SelectValues selectAnnotation = field.getAnnotation(SelectValues.class);
            if (null != selectAnnotation) {
                pbuild.type(selectAnnotation.freeSelect() ? Property.Type.FreeSelect : Property.Type.Select);
                pbuild.values(selectAnnotation.values());
            }
           
            if (field.getAnnotation(TextArea.class) != null) {
                renderBehaviour = StringRenderingConstants.DisplayType.MULTI_LINE;
            }

            if (field.getAnnotation(Password.class) != null) {
                renderBehaviour = StringRenderingConstants.DisplayType.PASSWORD;
            }

            pbuild.renderingOption(StringRenderingConstants.DISPLAY_TYPE_KEY, renderBehaviour);
        }

        String name = annotation.name();
        if (null == name || "".equals(name)) {
            name = field.getName();
        }
        pbuild.name(name);

        if (null != annotation.title() && !"".equals(annotation.title())) {
            pbuild.title(annotation.title());
        } else {
            pbuild.title(name);
        }

        pbuild.description(annotation.description());

        if (null != annotation.defaultValue() && !"".equals(annotation.defaultValue())) {
            pbuild.defaultValue(annotation.defaultValue());
        }
        pbuild.required(annotation.required());

        pbuild.scope(annotation.scope());

        return pbuild.build();
    }
View Full Code Here

Examples of net.freedom.gj.beans.criteria.PropertyBuilder

    public void execute() {
        System.out.println("executed Service C");
    }

    public List<PropertyCriteria> getCriteria() {
        return new CriteriaBuilder().build( new PropertyBuilder()
                                        .build("client", new PropertyValueEqualsMatcher("ABC"))
                                        .build("category", new PropertyValueEqualsMatcher("furniture")))
                                    .getCriteria();
    }
View Full Code Here

Examples of net.freedom.gj.beans.criteria.PropertyBuilder

        System.out.println("executed B with a switch as ON");
    }
   
   
     public List<PropertyCriteria> getCriteria() {
        return new CriteriaBuilder().build( new PropertyBuilder()
                                        .build("payload", new InstanceOfMatcher(Integer.class))
                                        .build("switch", new PropertyValueEqualsMatcher("ON")))
                                    .getCriteria();
    }
View Full Code Here

Examples of net.freedom.gj.beans.criteria.PropertyBuilder

    }


     public List<PropertyCriteria> getCriteria() {
        try {
            return new CriteriaBuilder().build(new PropertyBuilder()
                    .build("source", new InstanceOfMatcher(Class.forName(sourceType)))
                    .build("target", new InstanceOfMatcher(Class.forName(targetType)))).getCriteria();

        } catch (ClassNotFoundException e) {
            throw new IllegalArgumentException(e.getMessage(),e.getCause());
View Full Code Here

Examples of net.freedom.gj.beans.criteria.PropertyBuilder

     * and target object type has to be of type targetType.
     * @return
     */
    public List<PropertyCriteria> getCriteria() {
        try {
            PropertyBuilder pb = new PropertyBuilder()
                    .build("source", new InstanceOfMatcher(Class.forName(sourceType)))
                    .build("target", new InstanceOfMatcher(Class.forName(targetType)));
            if (additionalCriteria != null && !additionalCriteria.isEmpty()) {
                for (String property : additionalCriteria.keySet()) {
                    pb.build(property, additionalCriteria.get(property));
                }
            }
            return new CriteriaBuilder().build(pb).getCriteria();
        } catch (ClassNotFoundException e) {
            throw new IllegalArgumentException(e.getMessage());
View Full Code Here

Examples of org.apache.jackrabbit.oak.plugins.memory.PropertyBuilder

public class PropertyBuilderTest {

    @Test
    public void testStringProperty() {
        PropertyBuilder builder = PropertyBuilder.scalar(Type.STRING);
        builder.setName("foo").setValue("bar");
        Assert.assertEquals(StringPropertyState.stringProperty("foo", "bar"),
                builder.getPropertyState());

        builder.setArray();
        Assert.assertEquals(MultiStringPropertyState.stringProperty("foo", Arrays.asList("bar")),
                builder.getPropertyState());
    }
View Full Code Here

Examples of org.apache.jackrabbit.oak.plugins.memory.PropertyBuilder

                builder.getPropertyState());
    }

    @Test
    public void testLongProperty() {
        PropertyBuilder builder = PropertyBuilder.scalar(Type.LONG);
        builder.setName("foo").setValue(42L);
        Assert.assertEquals(LongPropertyState.createLongProperty("foo", 42L),
                builder.getPropertyState());

        builder.setArray();
        Assert.assertEquals(MultiLongPropertyState.createLongProperty("foo", Arrays.asList(42L)),
                builder.getPropertyState());
    }
View Full Code Here

Examples of org.apache.jackrabbit.oak.plugins.memory.PropertyBuilder

                builder.getPropertyState());
    }

    @Test
    public void testStringsProperty() {
        PropertyBuilder builder = PropertyBuilder.array(Type.STRING);
        builder.setName("foo")
                .addValue("one")
                .addValue("two");
        assertEquals(MultiStringPropertyState.stringProperty("foo", Arrays.asList("one", "two")),
                builder.getPropertyState());

        builder.setScalar();
        try {
            builder.getPropertyState();
        } catch (IllegalStateException expected) {
            // success
        }

        builder.removeValue("one");
        assertEquals(StringPropertyState.stringProperty("foo", "two"),
                builder.getPropertyState());
    }
View Full Code Here

Examples of org.apache.jackrabbit.oak.plugins.memory.PropertyBuilder

                builder.getPropertyState());
    }

    @Test
    public void testDateProperty() {
        PropertyBuilder builder = PropertyBuilder.array(Type.DATE);
        String date1 = "1970-01-01T00:00:00.000Z";
        String date2 = "1971-01-01T00:00:00.000Z";
        builder.setName("foo")
                .addValue(date1)
                .addValue(date2);
        Assert.assertEquals(MultiGenericPropertyState.dateProperty("foo", Arrays.asList(date1, date2)),
                builder.getPropertyState());

        builder.setScalar();
        try {
            builder.getPropertyState();
        } catch (IllegalStateException expected) {
        }

        builder.removeValue(date1);
        Assert.assertEquals(GenericPropertyState.dateProperty("foo", date2),
                builder.getPropertyState());
    }
View Full Code Here

Examples of org.apache.jackrabbit.oak.plugins.memory.PropertyBuilder

    }

    @Test
    public void testAssignFromLong() {
        PropertyState source = LongPropertyState.createLongProperty("foo", 42L);
        PropertyBuilder builder = PropertyBuilder.scalar(Type.STRING);
        builder.assignFrom(source);
        assertEquals(StringPropertyState.stringProperty("foo", "42"),
                builder.getPropertyState());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.