Sha256: 0d212d8ea5ec2445375b937ea119f6793ee0f8989bfcd28b56a095fff2e1a103
Contents?: true
Size: 1.14 KB
Versions: 6
Compression:
Stored size: 1.14 KB
Contents
package org.embulk.filter.typecast.cast; import org.embulk.spi.DataException; import org.embulk.spi.time.Timestamp; import org.msgpack.value.Value; public class BooleanCast { private BooleanCast() {} private static String buildErrorMessage(String as, boolean value) { return String.format("cannot cast boolean to %s: \"%s\"", as, value); } public static boolean asBoolean(boolean value) throws DataException { return value; } public static long asLong(boolean value) throws DataException { return value ? 1 : 0; } public static double asDouble(boolean value) throws DataException { throw new DataException(buildErrorMessage("double", value)); } public static String asString(boolean value) throws DataException { return value ? "true" : "false"; } public static Value asJson(boolean value) throws DataException { throw new DataException(buildErrorMessage("json", value)); } public static Timestamp asTimestamp(boolean value) throws DataException { throw new DataException(buildErrorMessage("timestamp", value)); } }
Version data entries
6 entries across 6 versions & 1 rubygems