HSBType extends PercentType implements ComplexType, State, Command { @Override public <T extends State> @Nullable T as(@Nullable Class<T> target) { if (target == OnOffType.class) { return target.cast(PercentType.ZERO.equals(getBrightness()) ? OnOffType.OFF : OnOffType.ON); } else if (target == DecimalType.class) { return target.cast(new DecimalType( getBrightness().toBigDecimal().divide(BigDecimal.valueOf(100), 8, RoundingMode.UP))); } else if (target == PercentType.class) { return target.cast(new PercentType(getBrightness().toBigDecimal())); } else { return defaultConversion(target); } } HSBType();  HSBType(DecimalType h, PercentType s, PercentType b);  HSBType(String value); static HSBType valueOf(String value); static HSBType fromRGB(int r, int g, int b); static HSBType fromXY(float x, float y); @Override SortedMap<String, PrimitiveType> getConstituents(); DecimalType getHue(); PercentType getSaturation(); PercentType getBrightness(); PercentType getRed(); PercentType getGreen(); PercentType getBlue(); int getRGB(); @Override String toString(); @Override String toFullString(); @Override int hashCode(); @Override boolean equals(@Nullable Object obj); PercentType[] toRGB(); PercentType[] toXY(); @Override T as(@Nullable Class<T> target); static final String KEY_HUE; static final String KEY_SATURATION; static final String KEY_BRIGHTNESS; static final HSBType BLACK; static final HSBType WHITE; static final HSBType RED; static final HSBType GREEN; static final HSBType BLUE; }
@Test public void testConversionToOnOffType() { assertEquals(OnOffType.ON, new HSBType("100,100,100").as(OnOffType.class)); assertEquals(OnOffType.ON, new HSBType("100,100,1").as(OnOffType.class)); assertEquals(OnOffType.OFF, new HSBType("100,100,0").as(OnOffType.class)); }
@Test public void testConversionToDecimalType() { assertEquals(new DecimalType("1.0"), new HSBType("100,100,100").as(DecimalType.class)); assertEquals(new DecimalType("0.01"), new HSBType("100,100,1").as(DecimalType.class)); assertEquals(DecimalType.ZERO, new HSBType("100,100,0").as(DecimalType.class)); }
@Test public void testConversionToPercentType() { assertEquals(PercentType.HUNDRED, new HSBType("100,100,100").as(PercentType.class)); assertEquals(new PercentType("1"), new HSBType("100,100,1").as(PercentType.class)); assertEquals(PercentType.ZERO, new HSBType("100,100,0").as(PercentType.class)); }
@Test public void testConversionToPointType() { assertEquals(null, new HSBType("100,100,100").as(PointType.class)); }