List of usage examples for com.google.common.primitives Shorts toArray
public static short[] toArray(Collection<? extends Number> collection)
From source file:net.larry1123.elec.util.config.fieldhanders.shorts.ShortArrayListFieldHandler.java
/** * {@inheritDoc}//ww w . j a v a 2s .c o m */ @Override public void setToFile(ArrayList<Short> value) { if (CollectionUtils.isNotEmpty(value)) { getPropertiesFile().setShortArray(getPropertyKey(), Shorts.toArray(value), getSpacer()); } }
From source file:xfel.mods.arp.base.utils.reflection.PrimitiveTypeHelper.java
@Override public Object convertToTypeArray(Collection<?> collection) { return Shorts.toArray((Collection<? extends Number>) collection); }
From source file:org.apache.hive.service.cli.Column.java
public Column(TColumn colValues) { if (colValues.isSetBoolVal()) { type = Type.BOOLEAN_TYPE; nulls = toBitset(colValues.getBoolVal().getNulls()); boolVars = Booleans.toArray(colValues.getBoolVal().getValues()); size = boolVars.length;// w w w . jav a2 s . c o m } else if (colValues.isSetByteVal()) { type = Type.TINYINT_TYPE; nulls = toBitset(colValues.getByteVal().getNulls()); byteVars = Bytes.toArray(colValues.getByteVal().getValues()); size = byteVars.length; } else if (colValues.isSetI16Val()) { type = Type.SMALLINT_TYPE; nulls = toBitset(colValues.getI16Val().getNulls()); shortVars = Shorts.toArray(colValues.getI16Val().getValues()); size = shortVars.length; } else if (colValues.isSetI32Val()) { type = Type.INT_TYPE; nulls = toBitset(colValues.getI32Val().getNulls()); intVars = Ints.toArray(colValues.getI32Val().getValues()); size = intVars.length; } else if (colValues.isSetI64Val()) { type = Type.BIGINT_TYPE; nulls = toBitset(colValues.getI64Val().getNulls()); longVars = Longs.toArray(colValues.getI64Val().getValues()); size = longVars.length; } else if (colValues.isSetDoubleVal()) { type = Type.DOUBLE_TYPE; nulls = toBitset(colValues.getDoubleVal().getNulls()); doubleVars = Doubles.toArray(colValues.getDoubleVal().getValues()); size = doubleVars.length; } else if (colValues.isSetBinaryVal()) { type = Type.BINARY_TYPE; nulls = toBitset(colValues.getBinaryVal().getNulls()); binaryVars = colValues.getBinaryVal().getValues(); size = binaryVars.size(); } else if (colValues.isSetStringVal()) { type = Type.STRING_TYPE; nulls = toBitset(colValues.getStringVal().getNulls()); stringVars = colValues.getStringVal().getValues(); size = stringVars.size(); } else { throw new IllegalStateException("invalid union object"); } }
From source file:org.apache.hadoop.hive.serde2.thrift.ColumnBuffer.java
public ColumnBuffer(TColumn colValues) { if (colValues.isSetBoolVal()) { type = Type.BOOLEAN_TYPE; nulls = toBitset(colValues.getBoolVal().getNulls()); boolVars = Booleans.toArray(colValues.getBoolVal().getValues()); size = boolVars.length;//from w w w . j av a 2s. co m } else if (colValues.isSetByteVal()) { type = Type.TINYINT_TYPE; nulls = toBitset(colValues.getByteVal().getNulls()); byteVars = Bytes.toArray(colValues.getByteVal().getValues()); size = byteVars.length; } else if (colValues.isSetI16Val()) { type = Type.SMALLINT_TYPE; nulls = toBitset(colValues.getI16Val().getNulls()); shortVars = Shorts.toArray(colValues.getI16Val().getValues()); size = shortVars.length; } else if (colValues.isSetI32Val()) { type = Type.INT_TYPE; nulls = toBitset(colValues.getI32Val().getNulls()); intVars = Ints.toArray(colValues.getI32Val().getValues()); size = intVars.length; } else if (colValues.isSetI64Val()) { type = Type.BIGINT_TYPE; nulls = toBitset(colValues.getI64Val().getNulls()); longVars = Longs.toArray(colValues.getI64Val().getValues()); size = longVars.length; } else if (colValues.isSetDoubleVal()) { type = Type.DOUBLE_TYPE; nulls = toBitset(colValues.getDoubleVal().getNulls()); doubleVars = Doubles.toArray(colValues.getDoubleVal().getValues()); size = doubleVars.length; } else if (colValues.isSetBinaryVal()) { type = Type.BINARY_TYPE; nulls = toBitset(colValues.getBinaryVal().getNulls()); binaryVars = colValues.getBinaryVal().getValues(); size = binaryVars.size(); } else if (colValues.isSetStringVal()) { type = Type.STRING_TYPE; nulls = toBitset(colValues.getStringVal().getNulls()); stringVars = colValues.getStringVal().getValues(); size = stringVars.size(); } else { throw new IllegalStateException("invalid union object"); } }
From source file:org.eclipse.xtend.core.macro.declaration.CompilationUnitImpl.java
private Object toArrayOfType(final Iterable<?> iterable, final Class<?> componentType) { Collection<?> _xifexpression = null; if ((iterable instanceof Collection<?>)) { _xifexpression = ((Collection<?>) iterable); } else {/*from w w w .j a v a2 s .c o m*/ _xifexpression = IterableExtensions.toList(iterable); } final Collection<?> collection = _xifexpression; Object _switchResult = null; boolean _matched = false; if (Objects.equal(componentType, int.class)) { _matched = true; _switchResult = Ints.toArray(((List<Integer>) collection)); } if (!_matched) { if (Objects.equal(componentType, long.class)) { _matched = true; _switchResult = Longs.toArray(((List<Long>) collection)); } } if (!_matched) { if (Objects.equal(componentType, char.class)) { _matched = true; _switchResult = Chars.toArray(((List<Character>) collection)); } } if (!_matched) { if (Objects.equal(componentType, boolean.class)) { _matched = true; _switchResult = Booleans.toArray(((List<Boolean>) collection)); } } if (!_matched) { if (Objects.equal(componentType, byte.class)) { _matched = true; _switchResult = Bytes.toArray(((List<Byte>) collection)); } } if (!_matched) { if (Objects.equal(componentType, short.class)) { _matched = true; _switchResult = Shorts.toArray(((List<Short>) collection)); } } if (!_matched) { if (Objects.equal(componentType, float.class)) { _matched = true; _switchResult = Floats.toArray(((List<Float>) collection)); } } if (!_matched) { if (Objects.equal(componentType, double.class)) { _matched = true; _switchResult = Doubles.toArray(((List<Double>) collection)); } } if (!_matched) { _switchResult = Iterables.<Object>toArray(collection, ((Class<Object>) componentType)); } return _switchResult; }