com.nedap.archie.rules.evaluation.ValueList Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tools Show documentation
Show all versions of tools Show documentation
tools that operate on the archie reference models and archetype object model
The newest version!
package com.nedap.archie.rules.evaluation;
import com.nedap.archie.rules.PrimitiveType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* A list of values, as evaluated by the rule evaluation.
*
* Every value has both a value and a set of paths used in calculating that value. See Value
* Created by pieter.bos on 31/03/16.
*/
public class ValueList {
private PrimitiveType type;
private List> values = new ArrayList<>();
private static Logger logger = LoggerFactory.getLogger(ValueList.class);
public ValueList() {
}
public ValueList(List> values) {
setValues(values);
determineTypeFromValues();
}
public void determineTypeFromValues() {
if(!values.isEmpty()) {
this.type = PrimitiveType.fromJavaType(values.get(0).getValue().getClass());
} else{
this.type = PrimitiveType.Unknown;
}
}
/*
* Construct a value list of a single value, that does not have a path.
*/
public ValueList(Object value) {
this(value, Collections.emptyList());
}
/*
* Construct a value list of a single value, that does not have a path.
*/
public ValueList(Object value, PrimitiveType type) {
this(value, Collections.emptyList());
setType(type);
}
/**
* Construct a value list of a single object, with its paths
* @param value
* @param paths
*/
public ValueList(Object value, List paths){
if(value == null) {
this.type = null;
addValue(value, paths);
} else {
addValue(value, paths);
this.type = PrimitiveType.fromJavaType(value.getClass());
}
}
public PrimitiveType getType() {
return type;
}
public void setType(PrimitiveType type) {
this.type = type;
}
public List> getValues() {
return values;
}
public List