public static MotionState transform(final Double decimalType) throws CouldNotTransformException { MotionState.Builder motionState = MotionState.newBuilder(); try { if (decimalType.intValue() == 0) { motionState.setValue(State.NO_MOTION); } else { motionState.setValue(State.MOTION); } return motionState.build(); } catch (Exception ex) { throw new CouldNotTransformException("Could not transform " + Double.class.getName() + "! " + Double.class.getSimpleName() + "[" + decimalType + "] is unknown!", ex); } }
public static TamperState transform(final double state) throws CouldNotTransformException { if (state == 0) { return TamperState.newBuilder().setValue(TamperState.State.NO_TAMPER).build(); } else if (state > 0) { //TODO:mpohling/thuxohl adjust the tamper state to also reflect the intensity of the alarm! return TamperState.newBuilder().setValue(TamperState.State.TAMPER).build(); } else { throw new CouldNotTransformException("Could not transform " + Double.class.getName() + "! " + Double.class.getSimpleName() + "[" + state + "] is unknown!"); } }
public static ActivationState transform(final OnOffHolder.OnOff onOffType) throws CouldNotTransformException { switch (onOffType) { case OFF: return ActivationState.newBuilder().setValue(ActivationState.State.DEACTIVE).build(); case ON: return ActivationState.newBuilder().setValue(ActivationState.State.ACTIVE).build(); default: throw new CouldNotTransformException("Could not transform " + OnOffHolder.OnOff.class.getName() + "! " + OnOffHolder.OnOff.class.getSimpleName() + "[" + onOffType.name() + "] is unknown!"); } }
public static ActivationState transform(OnOffHolderType.OnOffHolder.OnOff onOffType) throws CouldNotTransformException { switch (onOffType) { case OFF: return ActivationState.newBuilder().setValue(ActivationState.State.DEACTIVE).build(); case ON: return ActivationState.newBuilder().setValue(ActivationState.State.ACTIVE).build(); default: throw new CouldNotTransformException("Could not transform " + OnOffHolderType.OnOffHolder.OnOff.class.getName() + "! " + OnOffHolderType.OnOffHolder.OnOff.class.getSimpleName() + "[" + onOffType.name() + "] is unknown!"); } }
public static PowerState transform(OnOffHolderType.OnOffHolder.OnOff onOffType) throws CouldNotTransformException { switch (onOffType) { case OFF: return PowerState.newBuilder().setValue(PowerState.State.OFF).build(); case ON: return PowerState.newBuilder().setValue(PowerState.State.ON).build(); default: throw new CouldNotTransformException("Could not transform " + OnOffHolderType.OnOffHolder.OnOff.class.getName() + "! " + OnOffHolderType.OnOffHolder.OnOff.class.getSimpleName() + "[" + onOffType.name() + "] is unknown!"); } }
public static ActivationState transform(OnOffHolderType.OnOffHolder.OnOff onOffType) throws CouldNotTransformException { switch (onOffType) { case OFF: return ActivationState.newBuilder().setValue(ActivationState.State.DEACTIVE).build(); case ON: return ActivationState.newBuilder().setValue(ActivationState.State.ACTIVE).build(); default: throw new CouldNotTransformException("Could not transform " + OnOffHolderType.OnOffHolder.OnOff.class.getName() + "! " + OnOffHolderType.OnOffHolder.OnOff.class.getSimpleName() + "[" + onOffType.name() + "] is unknown!"); } }
public static rsb.Scope transform(final ScopeType.Scope scope) throws CouldNotTransformException { try { if (scope == null) { throw new NotAvailableException("scope"); } return new Scope(ScopeGenerator.generateStringRep(scope.getComponentList())); } catch (Exception ex) { throw new CouldNotTransformException(scope, rsb.Scope.class, ex); } }
public static ContactState transform(OpenClosedHolder.OpenClosed openClosedType) throws CouldNotTransformException { switch (openClosedType) { case CLOSED: return ContactState.newBuilder().setValue(ContactState.State.CLOSED).build(); case OPEN: return ContactState.newBuilder().setValue(ContactState.State.OPEN).build(); default: throw new CouldNotTransformException("Could not transform " + OpenClosedHolder.OpenClosed.class.getName() + "! " + OpenClosedHolder.OpenClosed.class.getSimpleName() + "[" + openClosedType.name() + "] is unknown!"); } }
public static BlindState transform(final StopMoveHolder.StopMove stopMoveType) throws CouldNotTransformException { switch (stopMoveType) { case STOP: return BlindState.newBuilder().setMovementState(BlindState.MovementState.STOP).build(); case MOVE: return BlindState.newBuilder().setMovementState(BlindState.MovementState.UNKNOWN).build(); default: throw new CouldNotTransformException("Could not transform " + StopMoveHolder.StopMove.class.getName() + "! " + StopMoveHolder.StopMove.class.getSimpleName() + "[" + stopMoveType.name() + "] is unknown!"); } }
public static BlindState transform(final UpDownHolder.UpDown upDownType) throws CouldNotTransformException { switch (upDownType) { case DOWN: return BlindState.newBuilder().setMovementState(BlindState.MovementState.DOWN).build(); case UP: return BlindState.newBuilder().setMovementState(BlindState.MovementState.UP).build(); default: throw new CouldNotTransformException("Could not transform " + UpDownHolder.UpDown.class.getName() + "! " + UpDownHolder.UpDown.class.getSimpleName() + "[" + upDownType.name() + "] is unknown!"); } }
public static ButtonState transform(final OnOffHolder.OnOff onOffType) throws CouldNotTransformException { switch (onOffType) { case OFF: return ButtonState.newBuilder().setValue(State.RELEASED).build(); case ON: return ButtonState.newBuilder().setValue(State.PRESSED).build(); default: throw new CouldNotTransformException("Could not transform " + OnOffHolder.OnOff.class.getName() + "! " + OnOffHolder.OnOff.class.getSimpleName() + "[" + onOffType.name() + "] is unknown!"); } }
public static OnOffHolderType.OnOffHolder transform(ActivationState.State activationState) throws TypeNotSupportedException, CouldNotTransformException { switch (activationState) { case DEACTIVE: return OnOffHolderType.OnOffHolder.newBuilder().setState(OnOffHolderType.OnOffHolder.OnOff.OFF).build(); case ACTIVE: return OnOffHolderType.OnOffHolder.newBuilder().setState(OnOffHolderType.OnOffHolder.OnOff.ON).build(); case UNKNOWN: throw new TypeNotSupportedException(activationState, OnOffHolderType.OnOffHolder.OnOff.class); default: throw new CouldNotTransformException("Could not transform " + ActivationState.State.class.getName() + "! " + ActivationState.State.class.getSimpleName() + "[" + activationState.name() + "] is unknown!"); } } }
public static HandleState transform(final String value) throws CouldNotTransformException { switch (StringProcessor.transformToUpperCase(value)) { case "CLOSED": return HandleState.newBuilder().setPosition(0).build(); case "OPEN": return HandleState.newBuilder().setPosition(90).build(); case "TILTED": return HandleState.newBuilder().setPosition(180).build(); default: throw new CouldNotTransformException("Could not transform " + String.class.getName() + "! " + String.class.getSimpleName() + "[" + value + "] is not a valid " + HandleState.class.getSimpleName() + "!"); } }
public static HSBColor transform(HSBType.HSB color) throws CouldNotTransformException { try { return HSBColor.newBuilder().setHue(color.getHue()).setSaturation(color.getSaturation()).setBrightness(color.getBrightness()).build(); } catch (Exception ex) { throw new CouldNotTransformException("Could not transform " + HSBType.HSB.class.getName() + " to " + HSBColor.class.getName() + "!", ex); } }
public static HSBType.HSB transform(HSBColor color) throws CouldNotTransformException { try { return HSBType.HSB.newBuilder().setHue(color.getHue()).setSaturation(color.getSaturation()).setBrightness(color.getBrightness()).build(); } catch (Exception ex) { throw new CouldNotTransformException("Could not transform " + HSBColor.class.getName() + " to " + HSBType.class.getName() + "!", ex); } } }
public static HandleState transform(final String stringType) throws CouldNotTransformException { switch (stringType) { case "CLOSED": return HandleState.newBuilder().setPosition(0).build(); case "OPEN": return HandleState.newBuilder().setPosition(90).build(); case "TILTED": return HandleState.newBuilder().setPosition(180).build(); default: throw new CouldNotTransformException("Could not transform " + String.class.getName() + "! " + String.class.getSimpleName() + "[" + stringType + "] is unknown!"); } }
public static HSBType.HSB transform(final ColorState colorState) throws CouldNotTransformException { try { HSBColor color = colorState.getColor().getHsbColor(); return HSBType.HSB.newBuilder().setHue(color.getHue()).setSaturation(color.getSaturation()).setBrightness(color.getBrightness()).build(); } catch (Exception ex) { throw new CouldNotTransformException("Could not transform " + HSBColor.class.getName() + " to " + HSBType.class.getName() + "!", ex); } } }
public static UpDownHolder transform(final BlindState blindState) throws TypeNotSupportedException, CouldNotTransformException { switch (blindState.getMovementState()) { case DOWN: return UpDownHolder.newBuilder().setState(UpDownHolder.UpDown.DOWN).build(); case UP: return UpDownHolder.newBuilder().setState(UpDownHolder.UpDown.UP).build(); case UNKNOWN: throw new TypeNotSupportedException(blindState, UpDownHolder.UpDown.class); default: throw new CouldNotTransformException("Could not transform " + BlindState.class.getName() + "! " + BlindState.class.getSimpleName() + "[" + blindState.getMovementState().name() + "] is unknown!"); } } }
public static OnOffHolder transform(final ButtonState buttonState) throws TypeNotSupportedException, CouldNotTransformException { switch (buttonState.getValue()) { case RELEASED: return OnOffHolder.newBuilder().setState(OnOffHolder.OnOff.OFF).build(); case PRESSED: return OnOffHolder.newBuilder().setState(OnOffHolder.OnOff.ON).build(); case UNKNOWN: throw new TypeNotSupportedException(buttonState, OnOffHolder.OnOff.class); default: throw new CouldNotTransformException("Could not transform " + ButtonState.State.class.getName() + "! " + ButtonState.State.class.getSimpleName() + "[" + buttonState.getValue().name() + "] is unknown!"); } } }
public static ColorState transform(final HSBType.HSB hsbColor) throws CouldNotTransformException { try { HSBColor hsbColorBuilder = HSBColor.newBuilder().setHue(hsbColor.getHue()).setSaturation(hsbColor.getSaturation()).setBrightness(hsbColor.getBrightness()).build(); Color color = Color.newBuilder().setHsbColor(hsbColorBuilder).setType(Color.Type.HSB).build(); return ColorState.newBuilder().setColor(color).build(); } catch (Exception ex) { throw new CouldNotTransformException("Could not transform " + HSBType.HSB.class.getName() + " to " + ColorState.class.getName() + "!", ex); } }