org.dmg.pmml.Entity Java Examples

The following examples show how to use org.dmg.pmml.Entity. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ObjectUtil.java    From jpmml-model with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
static
public Object toSimpleValue(Object value){

	if(value instanceof Entity){
		Entity<?> entity = (Entity<?>)value;

		return entity.getId();
	} // End if

	if(value instanceof ComplexValue){
		ComplexValue complexValue = (ComplexValue)value;

		return complexValue.toSimpleValue();
	}

	return value;
}
 
Example #2
Source File: EntityUtil.java    From jpmml-evaluator with GNU Affero General Public License v3.0 5 votes vote down vote up
static
public <E extends Entity<?>> String getId(E entity, BiMap<String, E> entityRegistry){
	Object id = entity.getId();

	if(id == null){
		BiMap<E, String> inversedEntityRegistry = entityRegistry.inverse();

		return inversedEntityRegistry.get(entity);
	}

	return TypeUtil.format(id);
}
 
Example #3
Source File: EntityUtil.java    From jpmml-evaluator with GNU Affero General Public License v3.0 5 votes vote down vote up
static
public <E extends Entity<?>> ImmutableBiMap<String, E> buildBiMap(List<E> entities){
	ImmutableBiMap.Builder<String, E> builder = new ImmutableBiMap.Builder<>();

	builder = putAll(entities, new AtomicInteger(1), builder);

	return builder.build();
}
 
Example #4
Source File: EntityUtil.java    From jpmml-evaluator with GNU Affero General Public License v3.0 5 votes vote down vote up
static
public <E extends Entity<?>> ImmutableBiMap.Builder<String, E> put(E entity, AtomicInteger index, ImmutableBiMap.Builder<String, E> builder){
	String implicitId = String.valueOf(index.getAndIncrement());

	Object id = entity.getId();
	if(id == null){
		id = implicitId;
	}

	return builder.put(TypeUtil.format(id), entity);
}
 
Example #5
Source File: EntityUtil.java    From jpmml-evaluator with GNU Affero General Public License v3.0 5 votes vote down vote up
static
public <E extends Entity<?>> ImmutableBiMap.Builder<String, E> putAll(List<E> entities, AtomicInteger index, ImmutableBiMap.Builder<String, E> builder){

	for(E entity : entities){
		builder = put(entity, index, builder);
	}

	return builder;
}
 
Example #6
Source File: EntityUtil.java    From jpmml-evaluator with GNU Affero General Public License v3.0 4 votes vote down vote up
static
public <E extends Entity<?>> String getId(E entity, HasEntityRegistry<E> hasEntityRegistry){
	BiMap<String, E> entityRegistry = hasEntityRegistry.getEntityRegistry();

	return getId(entity, entityRegistry);
}