TypeMap { public static SampleDimensionType getSampleDimensionType(final Range<?> range) { final Class<?> type = range.getElementClass(); if (Double.class.isAssignableFrom(type)) { return REAL_64BITS; } if (Float.class.isAssignableFrom(type)) { return REAL_32BITS; } long min = ((Number) range.getMinValue()).longValue(); long max = ((Number) range.getMaxValue()).longValue(); if (!range.isMinIncluded()) min++; if (!range.isMaxIncluded()) max--; return getSampleDimensionType(min, max); } private  TypeMap(final SampleDimensionType code,
                    final int     type,   final byte    size,
                    final boolean signed, final boolean real,
                    final Map<Number,Number> pool); private  TypeMap(final SampleDimensionType code,
                    final int     type,   final byte    size,
                    final boolean signed, final boolean real,
                    Number lower, Number upper, final Map<Number,Number> pool); static SampleDimensionType getSampleDimensionType(final Range<?> range); static SampleDimensionType getSampleDimensionType(double min, double max); static SampleDimensionType getSampleDimensionType(final long min, final long max); @SuppressWarnings("fallthrough") static SampleDimensionType getSampleDimensionType(final SampleModel model, final int band); static InternationalString getName(final SampleDimensionType type); static int getDataBufferType(final SampleDimensionType type); static int getSize(final SampleDimensionType type); static boolean isSigned(final SampleDimensionType type); static boolean isFloatingPoint(final SampleDimensionType type); static NumberRange<? extends Number> getRange(final SampleDimensionType type); static NumberRange<? extends Number> getPositiveRange(final SampleDimensionType type); @SuppressWarnings("fallthrough") static Number wrapSample(final double             value,
                                    final SampleDimensionType type,
                                    final boolean    allowWidening); static ColorInterpretation getColorInterpretation(final ColorModel model, final int band);  }
@Test public void testGetSampleDimensionTypeSampleModel() { final SampleModel sm=new BufferedImage(512, 512, BufferedImage.TYPE_USHORT_555_RGB).getSampleModel(); assertSame(SampleDimensionType.UNSIGNED_8BITS, TypeMap.getSampleDimensionType( sm, 0)); assertSame(SampleDimensionType.UNSIGNED_8BITS, TypeMap.getSampleDimensionType( sm, 1)); assertSame(SampleDimensionType.UNSIGNED_8BITS, TypeMap.getSampleDimensionType( sm, 2)); }