protected void validateType(StateVariable stateVariable, Class type) throws LocalServiceBindingException { // Validate datatype as good as we can // (for enums and other convertible types, the state variable type should be STRING) Datatype.Default expectedDefaultMapping = ModelUtil.isStringConvertibleType(getStringConvertibleTypes(), type) ? Datatype.Default.STRING : Datatype.Default.getByJavaType(type); log.finer("Expecting '" + stateVariable + "' to match default mapping: " + expectedDefaultMapping); if (expectedDefaultMapping != null && !stateVariable.getTypeDetails().getDatatype().isHandlingJavaType(expectedDefaultMapping.getJavaType())) { // TODO: Consider custom types?! throw new LocalServiceBindingException( "State variable '" + stateVariable + "' datatype can't handle action " + "argument's Java type (change one): " + expectedDefaultMapping.getJavaType() ); } else if (expectedDefaultMapping == null && stateVariable.getTypeDetails().getDatatype().getBuiltin() != null) { throw new LocalServiceBindingException( "State variable '" + stateVariable + "' should be custom datatype " + "(action argument type is unknown Java type): " + type.getSimpleName() ); } log.finer("State variable matches required argument datatype (or can't be validated because it is custom)"); }
protected void validateType(StateVariable stateVariable, Class type) throws LocalServiceBindingException { // Validate datatype as good as we can // (for enums and other convertible types, the state variable type should be STRING) Datatype.Default expectedDefaultMapping = ModelUtil.isStringConvertibleType(getStringConvertibleTypes(), type) ? Datatype.Default.STRING : Datatype.Default.getByJavaType(type); log.finer("Expecting '" + stateVariable + "' to match default mapping: " + expectedDefaultMapping); if (expectedDefaultMapping != null && !stateVariable.getTypeDetails().getDatatype().isHandlingJavaType(expectedDefaultMapping.getJavaType())) { // TODO: Consider custom types?! throw new LocalServiceBindingException( "State variable '" + stateVariable + "' datatype can't handle action " + "argument's Java type (change one): " + expectedDefaultMapping.getJavaType() ); } else if (expectedDefaultMapping == null && stateVariable.getTypeDetails().getDatatype().getBuiltin() != null) { throw new LocalServiceBindingException( "State variable '" + stateVariable + "' should be custom datatype " + "(action argument type is unknown Java type): " + type.getSimpleName() ); } log.finer("State variable matches required argument datatype (or can't be validated because it is custom)"); }
protected void validateType(StateVariable stateVariable, Class type) throws LocalServiceBindingException { // Validate datatype as good as we can // (for enums and other convertible types, the state variable type should be STRING) Datatype.Default expectedDefaultMapping = ModelUtil.isStringConvertibleType(getStringConvertibleTypes(), type) ? Datatype.Default.STRING : Datatype.Default.getByJavaType(type); log.finer("Expecting '" + stateVariable + "' to match default mapping: " + expectedDefaultMapping); if (expectedDefaultMapping != null && !stateVariable.getTypeDetails().getDatatype().isHandlingJavaType(expectedDefaultMapping.getJavaType())) { // TODO: Consider custom types?! throw new LocalServiceBindingException( "State variable '" + stateVariable + "' datatype can't handle action " + "argument's Java type (change one): " + expectedDefaultMapping.getJavaType() ); } else if (expectedDefaultMapping == null && stateVariable.getTypeDetails().getDatatype().getBuiltin() != null) { throw new LocalServiceBindingException( "State variable '" + stateVariable + "' should be custom datatype " + "(action argument type is unknown Java type): " + type.getSimpleName() ); } log.finer("State variable matches required argument datatype (or can't be validated because it is custom)"); }