public Object getAttribute(String key, Object defaultValue) { return commonInfo.getAttribute(key, defaultValue); }
public Object getAttribute(String key, Object defaultValue) { return commonInfo.getAttribute(key, defaultValue); }
public Object getAttribute(String key, Object defaultValue) { return commonInfo.getAttribute(key, defaultValue); }
public Object getAttribute(String key) { return commonInfo.getAttribute(key); }
public Object getAttribute(String key) { return commonInfo.getAttribute(key); }
public Object getAttribute(String key) { return commonInfo.getAttribute(key); }
public String getAttributeAsString(String key, String defaultValue) { Object x = getAttribute(key); if ( x == null ) return defaultValue; if ( x instanceof String ) return (String)x; return String.valueOf(x); // throws an exception if this isn't a string }
public int getAttributeAsInt(String key, int defaultValue) { Object x = getAttribute(key); if ( x == null || x == VCFConstants.MISSING_VALUE_v4 ) return defaultValue; if ( x instanceof Integer ) return (Integer)x; return Integer.valueOf((String)x); // throws an exception if this isn't a string }
public int getAttributeAsInt(String key, int defaultValue) { Object x = getAttribute(key); if ( x == null || x == VCFConstants.MISSING_VALUE_v4 ) return defaultValue; if ( x instanceof Integer ) return (Integer)x; return Integer.valueOf((String)x); // throws an exception if this isn't a string }
public double getAttributeAsDouble(String key, double defaultValue) { Object x = getAttribute(key); if ( x == null ) return defaultValue; if ( x instanceof Double ) return (Double)x; if ( x instanceof Integer ) return (Integer)x; return Double.valueOf((String)x); // throws an exception if this isn't a string }
public boolean getAttributeAsBoolean(String key, boolean defaultValue) { Object x = getAttribute(key); if ( x == null ) return defaultValue; if ( x instanceof Boolean ) return (Boolean)x; return Boolean.valueOf((String)x); // throws an exception if this isn't a string }
public String getAttributeAsString(String key, String defaultValue) { Object x = getAttribute(key); if ( x == null ) return defaultValue; if ( x instanceof String ) return (String)x; return String.valueOf(x); // throws an exception if this isn't a string }
public boolean getAttributeAsBoolean(String key, boolean defaultValue) { Object x = getAttribute(key); if ( x == null ) return defaultValue; if ( x instanceof Boolean ) return (Boolean)x; return Boolean.valueOf((String)x); // throws an exception if this isn't a string }
public double getAttributeAsDouble(String key, double defaultValue) { Object x = getAttribute(key); if ( x == null ) return defaultValue; if ( x instanceof Double ) return (Double)x; if ( x instanceof Integer ) return (Integer)x; return Double.valueOf((String)x); // throws an exception if this isn't a string }
public boolean getAttributeAsBoolean(String key, boolean defaultValue) { Object x = getAttribute(key); if ( x == null ) return defaultValue; if ( x instanceof Boolean ) return (Boolean)x; return Boolean.valueOf((String)x); // throws an exception if this isn't a string }
public String getAttributeAsString(String key, String defaultValue) { Object x = getAttribute(key); if ( x == null ) return defaultValue; if ( x instanceof String ) return (String)x; return String.valueOf(x); // throws an exception if this isn't a string }
public int getAttributeAsInt(String key, int defaultValue) { Object x = getAttribute(key); if ( x == null || x == VCFConstants.MISSING_VALUE_v4 ) return defaultValue; if ( x instanceof Integer ) return (Integer)x; return Integer.valueOf((String)x); // throws an exception if this isn't a string }
public double getAttributeAsDouble(String key, double defaultValue) { Object x = getAttribute(key); if ( x == null ) return defaultValue; if ( x instanceof Double ) return (Double)x; if ( x instanceof Integer ) return (Integer)x; return Double.valueOf((String)x); // throws an exception if this isn't a string }
private final static Map<String, Object> subsetAttributes(final CommonInfo igc, final Collection<String> keysToPreserve) { Map<String, Object> attributes = new HashMap<>(keysToPreserve.size()); for ( final String key : keysToPreserve ) { if ( igc.hasAttribute(key) ) attributes.put(key, igc.getAttribute(key)); } return attributes; }
/** * Gets the attributes from a key as a list. * * Note: int[] and double[] arrays are boxed. * * @return empty list if the key was not found; {@link Collections#singletonList(Object)} if * there is only one value; a list containing the values if the value is a {@link List} or array. */ @SuppressWarnings("unchecked") public List<Object> getAttributeAsList(String key) { Object o = getAttribute(key); if ( o == null ) return Collections.emptyList(); if ( o instanceof List ) return (List<Object>)o; if ( o.getClass().isArray() ) { if (o instanceof int[]) { return Arrays.stream((int[])o).boxed().collect(Collectors.toList()); } else if (o instanceof double[]) { return Arrays.stream((double[])o).boxed().collect(Collectors.toList()); } return Arrays.asList((Object[])o); } return Collections.singletonList(o); }