DoubleAttributeColumnMapping.java

  1. /*
  2.  * Copyright (C) 2021 B3Partners B.V.
  3.  *
  4.  * SPDX-License-Identifier: MIT
  5.  */

  6. package nl.b3p.brmo.schema.mapping;

  7. import nl.b3p.brmo.sql.dialect.SQLDialect;

  8. public class DoubleAttributeColumnMapping extends AttributeColumnMapping {

  9.   public DoubleAttributeColumnMapping(String name, boolean notNull) {
  10.     super(name, "double precision", notNull, false);
  11.   }

  12.   public DoubleAttributeColumnMapping(String name) {
  13.     this(name, true);
  14.   }

  15.   @Override
  16.   public Object toQueryParameter(Object value, SQLDialect sqlDialect) {
  17.     if (value == null) {
  18.       return null;
  19.     } else {
  20.       return Double.parseDouble(value.toString());
  21.     }
  22.   }
  23. }