Here you can find the source of coerceTagValueInt(String tag, Object val)
private static Integer coerceTagValueInt(String tag, Object val)
//package com.java2s; //License from project: Open Source License public class Main { private static Integer coerceTagValueInt(String tag, Object val) { // from HTSJDK: https://github.com/samtools/htsjdk/blob/master/src/java/htsjdk/samtools/SAMRecord.java if (val == null) return null; if (val instanceof Integer) { return (Integer) val; }// w w w. jav a2 s . c o m if (!(val instanceof Number)) { throw new RuntimeException("Value for tag " + tag + " is not Number: " + val.getClass()); } final long longVal = ((Number) val).longValue(); if (longVal < Integer.MIN_VALUE || longVal > Integer.MAX_VALUE) { throw new RuntimeException("Value for tag " + tag + " is not in Integer range: " + longVal); } return (int) longVal; } }