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


Java ParameterSet类代码示例

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


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

示例1: buildQuery

import com.holonplatform.core.ParameterSet; //导入依赖的package包/类
/**
 * Build a {@link Query} using the Datastore and configuring query filters and sorts.
 * @param configuration Query configuration
 * @param withSorts Whether to apply sorts, if any, to query
 * @return Query instance
 */
protected Query buildQuery(QueryConfigurationProvider configuration, boolean withSorts) {
	Query q = getDatastore().query();
	// target
	if (getTarget() != null) {
		q.target(getTarget());
	}
	// filter
	QueryFilter filter = configuration.getQueryFilter();
	if (filter != null) {
		q.filter(filter);
	}
	// sort
	if (withSorts) {
		QuerySort sort = configuration.getQuerySort();
		if (sort != null) {
			q.sort(sort);
		}
	}
	// parameters
	ParameterSet parameters = configuration.getQueryParameters();
	if (parameters != null) {
		parameters.forEachParameter((n, v) -> q.parameter(n, v));
	}
	return q;
}
 
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:32,代码来源:DatastoreItemDataProvider.java

示例2: parameterSet

import com.holonplatform.core.ParameterSet; //导入依赖的package包/类
public void parameterSet() {
	// tag::params[]
	final ConfigProperty<String> property = ConfigProperty.create("test", String.class);
	
	ParameterSet set = ParameterSet.builder()
			.parameter("testParameter", 1L) // <1>
			.parameter(property, "testValue") // <2>
			.build();
	
	boolean present = set.hasParameter("testParameter"); // <3>
	present = set.hasNotNullParameter("testParameter"); // <4>
	
	set.getParameter(property).ifPresent(p -> p.toString()); // <5>
	// end::params[]
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:16,代码来源:ExampleConfig.java

示例3: present

import com.holonplatform.core.ParameterSet; //导入依赖的package包/类
public void present() {
	String presented = StringValuePresenter.getDefault().present("stringValue"); // <1>
	presented = StringValuePresenter.getDefault().present("stringValue",
			ParameterSet.builder().parameter(StringValuePresenter.MAX_LENGTH, 6).build()); // <2>
	presented = StringValuePresenter.getDefault().present(MyEnum.VALUE1); // <3>
	presented = StringValuePresenter.getDefault().present(new MyEnum[] { MyEnum.VALUE1, MyEnum.VALUE2 }); // <4>
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:8,代码来源:ExamplePresenter.java

示例4: present

import com.holonplatform.core.ParameterSet; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public String present(Property property, Object value) {
	ObjectUtils.argumentNotNull(property, "Property must be not null");
	ParameterSet.Builder<?> parameters = ParameterSet.builder().parameters(property.getConfiguration());
	property.getConfiguration().getTemporalType()
			.ifPresent(t -> parameters.parameter(StringValuePresenter.TEMPORAL_TYPE, t));
	return StringValuePresenter.getDefault().present(property.getType(), value, parameters.build());
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:10,代码来源:DefaultPropertyValuePresenter.java

示例5: getQueryParameters

import com.holonplatform.core.ParameterSet; //导入依赖的package包/类
@Override
public ParameterSet getQueryParameters() {
	return queryParameters;
}
 
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:5,代码来源:DefaultItemDataSourceContainer.java

示例6: testPropertyContainer

import com.holonplatform.core.ParameterSet; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Test
public void testPropertyContainer() {

	ItemDataSourceContainer<PropertyBox, Property> container = ItemDataSourceContainer
			.<PropertyBox, Property>builder().dataSource(new TestPropertyDataProvider(datastore))
			.itemAdapter(new PropertyBoxItemAdapter()).withProperty(TestData.ID, TestData.ID.getType())
			.withProperty(TestData.DESCRIPTION, TestData.DESCRIPTION.getType())
			.withProperty(TestData.SEQUENCE, TestData.SEQUENCE.getType())
			.withProperty(TestData.OBSOLETE, TestData.OBSOLETE.getType())
			.fixedFilter(TestData.ID.isNotNull().and(TestData.SEQUENCE.lt(23))).fixedSort(TestData.ID.asc())
			.defaultSort(TestData.DESCRIPTION.asc()).build();

	int size = container.size();
	assertEquals(22, size);

	container.addQueryParameter("test", "val");
	assertEquals("val", container.getConfiguration().getQueryParameters().getParameter("test").orElse(null));

	container.removeQueryParameter("test");
	assertFalse(container.getConfiguration().getQueryParameters().hasParameter("test"));

	container = ItemDataSourceContainer.<PropertyBox, Property>builder()
			.dataSource(new TestPropertyDataProvider(datastore)).itemAdapter(new PropertyBoxItemAdapter())
			.withProperty(TestData.ID, TestData.ID.getType())
			.withProperty(TestData.DESCRIPTION, TestData.DESCRIPTION.getType())
			.withProperty(TestData.SEQUENCE, TestData.SEQUENCE.getType())
			.withProperty(TestData.OBSOLETE, TestData.OBSOLETE.getType())
			.fixedFilter(TestData.ID.isNotNull().and(TestData.SEQUENCE.lt(23))).fixedSort(TestData.ID.asc())
			.defaultSort(TestData.DESCRIPTION.asc()).itemIdentifier(i -> i.getValue(TestData.ID)).build();

	assertEquals("c20", container.firstItemId());

	QueryConfigurationProvider qcp = new QueryConfigurationProvider() {

		@Override
		public QuerySort getQuerySort() {
			return TestData.DESCRIPTION.desc();
		}

		@Override
		public ParameterSet getQueryParameters() {
			return null;
		}

		@Override
		public QueryFilter getQueryFilter() {
			return TestData.SEQUENCE.lt(21);
		}
	};

	Registration reg = container.addQueryConfigurationProvider(qcp);

	size = container.size();
	assertEquals(20, size);

	assertEquals("c7", container.firstItemId());

	container.sort(new Property[] { TestData.DESCRIPTION }, new boolean[] { true });

	assertEquals("c20", container.firstItemId());

	reg.remove();

	size = container.size();
	assertEquals(22, size);

}
 
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:69,代码来源:TestPropertyQueryContainer.java

示例7: testPropertyContainerBuilder

import com.holonplatform.core.ParameterSet; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Test
public void testPropertyContainerBuilder() {

	ItemDataSourceContainer<PropertyBox, Property> container = ItemDataSourceContainer
			.<PropertyBox, Property>builder().dataSource(new TestPropertyDataProvider(datastore))
			.itemAdapter(new PropertyBoxItemAdapter()).withProperty(TestData.ID, TestData.ID.getType())
			.withProperty(TestData.DESCRIPTION, TestData.DESCRIPTION.getType())
			.withProperty(TestData.SEQUENCE, TestData.SEQUENCE.getType())
			.withProperty(TestData.OBSOLETE, TestData.OBSOLETE.getType()).autoRefresh(false).build();

	int size = container.size();
	assertEquals(0, size);

	container.refresh();

	size = container.size();
	assertEquals(23, size);

	container = ItemDataSourceContainer.<PropertyBox, Property>builder()
			.dataSource(new TestPropertyDataProvider(datastore)).itemAdapter(new PropertyBoxItemAdapter())
			.withProperty(TestData.ID, TestData.ID.getType())
			.withProperty(TestData.DESCRIPTION, TestData.DESCRIPTION.getType())
			.withProperty(TestData.SEQUENCE, TestData.SEQUENCE.getType())
			.withProperty(TestData.OBSOLETE, TestData.OBSOLETE.getType())
			.itemIdentifier(i -> i.getValue(TestData.ID)).fixedFilter(TestData.SEQUENCE.goe(20))
			.withQueryConfigurationProvider(new QueryConfigurationProvider() {

				@Override
				public QuerySort getQuerySort() {
					return null;
				}

				@Override
				public ParameterSet getQueryParameters() {
					return null;
				}

				@Override
				public QueryFilter getQueryFilter() {
					return TestData.SEQUENCE.loe(20);
				}
			}).build();

	size = container.size();
	assertEquals(1, size);

	assertEquals("c20", container.firstItemId());

	boolean obs = (boolean) container.getItem("c20").getItemProperty(TestData.OBSOLETE).getValue();
	assertTrue(obs);

	Optional<PropertyBox> box = datastore.query().target(TARGET).filter(TestData.ID.eq("c20"))
			.findOne(TestData.PROPERTIES);
	assertTrue(box.isPresent());

	box.get().setValue(TestData.OBSOLETE, false);

	datastore.save(TARGET, box.get());

	container.refreshItem("c20");

	obs = (boolean) container.getItem("c20").getItemProperty(TestData.OBSOLETE).getValue();
	assertFalse(obs);

	datastore.bulkUpdate(TARGET).filter(TestData.ID.eq("c20")).set(TestData.OBSOLETE, Boolean.TRUE).execute();

	container = ItemDataSourceContainer.<PropertyBox, Property>builder()
			.dataSource(new TestPropertyDataProvider(datastore)).itemAdapter(new PropertyBoxItemAdapter())
			.withProperty(TestData.ID, TestData.ID.getType())
			.withProperty(TestData.DESCRIPTION, TestData.DESCRIPTION.getType())
			.withProperty(TestData.SEQUENCE, TestData.SEQUENCE.getType())
			.withProperty(TestData.OBSOLETE, TestData.OBSOLETE.getType()).queryParameter("test", "val")
			.fixedSort(TestData.ID.asc()).defaultSort(TestData.DESCRIPTION.asc())
			.fixedFilter(TestData.SEQUENCE.between(1, 2)).build();

	size = container.size();
	assertEquals(2, size);

}
 
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:81,代码来源:TestPropertyQueryContainer.java

示例8: testPropertyContainerDatastore

import com.holonplatform.core.ParameterSet; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Test
public void testPropertyContainerDatastore() {

	ItemDataSourceContainer<PropertyBox, Property> container = ItemDataSourceContainer
			.<PropertyBox, Property>builder()
			.dataSource(new DatastoreItemDataProvider(datastore, TARGET, TestData.PROPERTIES))
			.itemAdapter(new PropertyBoxItemAdapter()).withProperty(TestData.ID, TestData.ID.getType())
			.withProperty(TestData.DESCRIPTION, TestData.DESCRIPTION.getType())
			.withProperty(TestData.SEQUENCE, TestData.SEQUENCE.getType())
			.withProperty(TestData.OBSOLETE, TestData.OBSOLETE.getType())
			.itemIdentifier(i -> i.getValue(TestData.ID)).fixedFilter(TestData.ID.neq("c1")).build();

	int size = container.size();
	assertEquals(22, size);

	QueryConfigurationProvider qcp = new QueryConfigurationProvider() {

		@Override
		public QuerySort getQuerySort() {
			return TestData.DESCRIPTION.desc();
		}

		@Override
		public ParameterSet getQueryParameters() {
			return null;
		}

		@Override
		public QueryFilter getQueryFilter() {
			return TestData.SEQUENCE.lt(23);
		}
	};
	container.addQueryConfigurationProvider(qcp);

	size = container.size();
	assertEquals(21, size);

	assertEquals("c7", container.firstItemId());

	boolean obs = (boolean) container.getItem("c20").getItemProperty(TestData.OBSOLETE).getValue();
	assertTrue(obs);

	Optional<PropertyBox> box = datastore.query().target(TARGET).filter(TestData.ID.eq("c20"))
			.findOne(TestData.PROPERTIES);
	assertTrue(box.isPresent());

	box.get().setValue(TestData.OBSOLETE, false);

	datastore.save(TARGET, box.get());

	container.refreshItem("c20");

	obs = (boolean) container.getItem("c20").getItemProperty(TestData.OBSOLETE).getValue();
	assertFalse(obs);

	datastore.bulkUpdate(TARGET).filter(TestData.ID.eq("c20")).set(TestData.OBSOLETE, Boolean.TRUE).execute();

}
 
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:60,代码来源:TestPropertyQueryContainer.java

示例9: build

import com.holonplatform.core.ParameterSet; //导入依赖的package包/类
@Override
public ParameterSet build() {
	return getInstance();
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:5,代码来源:DefaultParameterSet.java

示例10: testParameterBuilder

import com.holonplatform.core.ParameterSet; //导入依赖的package包/类
@Test
public void testParameterBuilder() {

	ParameterSet ps = ParameterSet.builder().parameter("test", "TEST").parameter("test2", Integer.valueOf(3))
			.build();

	assertTrue(ps.hasParameter("test"));
	assertTrue(ps.hasNotNullParameter("test"));
	assertTrue(ps.hasParameter("test2"));
	assertTrue(ps.hasNotNullParameter("test2"));

	assertFalse(ps.hasParameter((String) null));
	assertFalse(ps.hasNotNullParameter((String) null));

	String sv = ps.getParameter("test", String.class).orElse(null);
	assertNotNull(sv);
	assertEquals("TEST", sv);

	Integer iv = ps.getParameter("test2", Integer.class).orElse(null);
	assertNotNull(iv);
	assertEquals(Integer.valueOf(3), iv);

	ParameterSet ps2 = ParameterSet.builder().parameters(ps).build();

	assertTrue(ps2.hasParameters());
	assertTrue(ps2.hasParameter("test"));
	assertTrue(ps2.hasNotNullParameter("test"));
	assertTrue(ps2.hasParameter("test2"));
	assertTrue(ps2.hasNotNullParameter("test2"));

	DefaultParameterSet ps3 = new DefaultParameterSet();
	ps3.addParameter("p1", Integer.valueOf(1));
	ps3.addParameter("p2", Integer.valueOf(2));
	ps3.removeParameter("p2");

	String ts = ps3.toString();
	assertNotNull(ts);

	Integer pv = ps3.getParameter("p1x", Integer.class, null);
	assertNull(pv);

	Integer pvi = ps3.getParameter("p1", Integer.class, null);
	assertEquals(Integer.valueOf(1), pvi);

	DefaultParameterSet ps4 = new DefaultParameterSet(null);
	assertFalse(ps4.hasParameters());

	ParameterSet ps5 = new DefaultParameterSet();
	ps5.toString();

}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:52,代码来源:TestParameters.java

示例11: buildQuery

import com.holonplatform.core.ParameterSet; //导入依赖的package包/类
/**
 * Build a {@link Query} using the Datastore and configuring query filters and sorts.
 * @param configuration Query configuration
 * @param withSorts Whether to apply sorts, if any, to query
 * @return Query instance
 */
protected Query buildQuery(QueryConfigurationProvider configuration, boolean withSorts) {
	Query q = getDatastore().query();

	// target
	if (getTarget() != null) {
		q.target(getTarget());
	}

	// filter
	final List<QueryFilter> filters = new LinkedList<>();

	QueryFilter filter = configuration.getQueryFilter();
	if (filter != null) {
		filters.add(filter);
	}

	queryConfigurationProviders.forEach(p -> {
		QueryFilter qf = p.getQueryFilter();
		if (qf != null) {
			filters.add(qf);
		}
	});

	QueryFilter.allOf(filters).ifPresent(f -> q.filter(f));

	// sort
	if (withSorts) {

		final List<QuerySort> sorts = new LinkedList<>();

		QuerySort sort = configuration.getQuerySort();
		if (sort != null) {
			sorts.add(sort);
		}

		queryConfigurationProviders.forEach(p -> {
			QuerySort qs = p.getQuerySort();
			if (qs != null) {
				sorts.add(qs);
			}
		});

		if (!sorts.isEmpty()) {
			if (sorts.size() == 1) {
				q.sort(sorts.get(0));
			} else {
				q.sort(QuerySort.of(sorts));
			}
		}
	}
	// parameters
	ParameterSet parameters = configuration.getQueryParameters();
	if (parameters != null) {
		parameters.forEachParameter((n, v) -> q.parameter(n, v));
	}

	queryConfigurationProviders.forEach(p -> {
		if (p.getQueryParameters() != null) {
			p.getQueryParameters().forEachParameter((n, v) -> q.parameter(n, v));
		}
	});

	return q;
}
 
开发者ID:holon-platform,项目名称:holon-vaadin,代码行数:71,代码来源:DatastoreItemDataProvider.java

示例12: getQueryParameters

import com.holonplatform.core.ParameterSet; //导入依赖的package包/类
/**
 * Get the query parameters.
 * <p>
 * By default this method returns <code>null</code>.
 * </p>
 * @return Query parameters, or <code>null</code> if none
 */
default ParameterSet getQueryParameters() {
	return null;
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:11,代码来源:QueryConfigurationProvider.java

示例13: present

import com.holonplatform.core.ParameterSet; //导入依赖的package包/类
/**
 * Present given <code>value</code> of given <code>valueType</code> as a String. Presentation parameters may be
 * specified passing a {@link ParameterSet}.
 * @param <T> Type of the value to present
 * @param <V> Actual value type
 * @param valueType Value type
 * @param value Value to present
 * @param parameters Optional presentation parameters
 * @return String value
 */
<T, V extends T> String present(Class<T> valueType, V value, ParameterSet parameters);
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:12,代码来源:StringValuePresenter.java


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