test_class.file: bundles/org.openhab.core/src/test/java/org/openhab/core/library/items/ColorItemTest.java
test_class.identifier: ColorItemTest
test_case.body: @Test
      public void testSetStateWithPercentType() {
          ColorItem item = new ColorItem("test");
          item.setState(new PercentType(50));
          assertEquals(new HSBType(new DecimalType(0), new PercentType(0), new PercentType(50)), item.getState());
      }
test_case.class_method_signature: ColorItemTest.testSetStateWithPercentType()
test_case.full_signature: @Test public void testSetStateWithPercentType()
test_case.identifier: testSetStateWithPercentType
test_case.invocations: setState assertEquals getState
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testSetStateWithPercentType()
focal_class.declarator: acceptedDataTypes = new ArrayList<>()
focal_class.modifier: private static
focal_class.original_string: private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<>();
focal_class.type: List<Class<? extends State>>
focal_class.var_name: acceptedDataTypes
focal_class.declarator: acceptedCommandTypes = new ArrayList<>()
focal_class.modifier: private static
focal_class.original_string: private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<>();
focal_class.type: List<Class<? extends Command>>
focal_class.var_name: acceptedCommandTypes
focal_class.file: bundles/org.openhab.core/src/main/java/org/openhab/core/library/items/ColorItem.java
focal_class.identifier: ColorItem
focal_class.class_method_signature: ColorItem.ColorItem(String name)
focal_class.full_signature: public  ColorItem(String name)
focal_class.identifier: ColorItem
focal_class.modifiers: public
focal_class.parameters: (String name)
focal_class.signature:  ColorItem(String name)
focal_class.class_method_signature: ColorItem.send(HSBType command)
focal_class.full_signature: public void send(HSBType command)
focal_class.identifier: send
focal_class.modifiers: public
focal_class.parameters: (HSBType command)
focal_class.return: void
focal_class.signature: void send(HSBType command)
focal_class.class_method_signature: ColorItem.getAcceptedDataTypes()
focal_class.full_signature: @Override public List<Class<? extends State>> getAcceptedDataTypes()
focal_class.identifier: getAcceptedDataTypes
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: List<Class<? extends State>>
focal_class.signature: List<Class<? extends State>> getAcceptedDataTypes()
focal_class.class_method_signature: ColorItem.getAcceptedCommandTypes()
focal_class.full_signature: @Override public List<Class<? extends Command>> getAcceptedCommandTypes()
focal_class.identifier: getAcceptedCommandTypes
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: List<Class<? extends Command>>
focal_class.signature: List<Class<? extends Command>> getAcceptedCommandTypes()
focal_class.class_method_signature: ColorItem.setState(State state)
focal_class.full_signature: @Override public void setState(State state)
focal_class.identifier: setState
focal_class.modifiers: @Override public
focal_class.parameters: (State state)
focal_class.return: void
focal_class.signature: void setState(State state)
focal_class.superclass: extends DimmerItem
focal_method.body: @Override
      public void setState(State state) {
          if (isAcceptedState(acceptedDataTypes, state)) {
              State currentState = this.state;
  
              if (currentState instanceof HSBType) {
                  DecimalType hue = ((HSBType) currentState).getHue();
                  PercentType saturation = ((HSBType) currentState).getSaturation();
                  // we map ON/OFF values to dark/bright, so that the hue and saturation values are not changed
                  if (state == OnOffType.OFF) {
                      applyState(new HSBType(hue, saturation, PercentType.ZERO));
                  } else if (state == OnOffType.ON) {
                      applyState(new HSBType(hue, saturation, PercentType.HUNDRED));
                  } else if (state instanceof PercentType && !(state instanceof HSBType)) {
                      applyState(new HSBType(hue, saturation, (PercentType) state));
                  } else if (state instanceof DecimalType && !(state instanceof HSBType)) {
                      applyState(new HSBType(hue, saturation,
                              new PercentType(((DecimalType) state).toBigDecimal().multiply(BigDecimal.valueOf(100)))));
                  } else {
                      applyState(state);
                  }
              } else {
                  // try conversion
                  State convertedState = state.as(HSBType.class);
                  if (convertedState != null) {
                      applyState(convertedState);
                  } else {
                      applyState(state);
                  }
              }
          } else {
              logSetTypeError(state);
          }
      }
focal_method.class_method_signature: ColorItem.setState(State state)
focal_method.full_signature: @Override public void setState(State state)
focal_method.identifier: setState
focal_method.invocations: isAcceptedState getHue getSaturation applyState applyState applyState applyState multiply toBigDecimal valueOf applyState as applyState applyState logSetTypeError
focal_method.modifiers: @Override public
focal_method.parameters: (State state)
focal_method.return: void
focal_method.signature: void setState(State state)