/** * Returns <code>true</code> if type mapped to the column at given index is the same as the provided one * @param columnIndex * @param className * @return */ public boolean isSameSelectedColumnType(int columnIndex, String className) { SimulationDescriptor simulationDescriptor = simulation.getSimulationDescriptor(); final FactMapping factMappingByIndex = simulationDescriptor.getFactMappingByIndex(columnIndex); return factMappingByIndex.getClassName().equals(className); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } FactMapping that = (FactMapping) o; return getExpressionElements().equals(that.getExpressionElements()) && Objects.equals(getExpressionIdentifier(), that.getExpressionIdentifier()) && Objects.equals(getFactIdentifier(), that.getFactIdentifier()) && Objects.equals(getClassName(), that.getClassName()) && Objects.equals(getFactAlias(), that.getFactAlias()) && Objects.equals(getExpressionAlias(), that.getExpressionAlias()); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } FactMapping that = (FactMapping) o; return getExpressionElements().equals(that.getExpressionElements()) && Objects.equals(getExpressionIdentifier(), that.getExpressionIdentifier()) && Objects.equals(getFactIdentifier(), that.getFactIdentifier()) && Objects.equals(getClassName(), that.getClassName()) && Objects.equals(getFactAlias(), that.getFactAlias()) && Objects.equals(getExpressionAlias(), that.getExpressionAlias()); }
public Map<List<String>, Object> getParamsForBean(SimulationDescriptor simulationDescriptor, FactIdentifier factIdentifier, List<FactMappingValue> factMappingValues, ClassLoader classLoader, ExpressionEvaluator expressionEvaluator) { Map<List<String>, Object> paramsForBean = new HashMap<>(); for (FactMappingValue factMappingValue : factMappingValues) { ExpressionIdentifier expressionIdentifier = factMappingValue.getExpressionIdentifier(); FactMapping factMapping = simulationDescriptor.getFactMapping(factIdentifier, expressionIdentifier) .orElseThrow(() -> new IllegalStateException("Wrong expression, this should not happen")); List<String> pathToField = factMapping.getExpressionElementsWithoutClass().stream() .map(ExpressionElement::getStep).collect(toList()); try { Object value = expressionEvaluator.getValueForGiven(factMapping.getClassName(), factMappingValue.getRawValue()); paramsForBean.put(pathToField, value); } catch (IllegalArgumentException e) { factMappingValue.setError(true); throw new ScenarioException(e.getMessage(), e); } } return paramsForBean; }
@Override public int hashCode() { return Objects.hash(getExpressionElements(), getExpressionIdentifier(), getFactIdentifier(), getClassName(), getFactAlias(), getExpressionAlias()); } }
@Override public int hashCode() { return Objects.hash(getExpressionElements(), getExpressionIdentifier(), getFactIdentifier(), getClassName(), getFactAlias(), getExpressionAlias()); } }
/** * Returns <code>true</code> when * <p> * instanceAssigned == true * </p><p> * <b>and</b> * </p><p> * !factMapping.getExpressionElements().isEmpty() * </p> * @param instanceAssigned * @param factMapping * @return */ protected boolean isPropertyAssigned(boolean instanceAssigned, FactMapping factMapping) { if (FactIdentifier.DESCRIPTION.equals(factMapping.getFactIdentifier())) { return true; } else { return instanceAssigned && (isSimpleJavaType(factMapping.getClassName()) || !factMapping.getExpressionElements().isEmpty()); } }