public static String transform(final HandleState handleState) throws CouldNotTransformException { try { switch (handleState.getPosition()) { case 0: return "CLOSED"; case 90: return "OPEN"; case 180: return "TILTED"; default: throw new TypeNotSupportedException(handleState, String.class); } } catch (CouldNotPerformException ex) { throw new CouldNotTransformException("Could not transform " + HandleState.class.getName() + "!", ex); } } }
public static double transform(final TamperState tamperState) throws TypeNotSupportedException, CouldNotTransformException { switch (tamperState.getValue()) { case NO_TAMPER: return 0d; case TAMPER: return 1d; case UNKNOWN: throw new TypeNotSupportedException(tamperState, Double.class); default: throw new CouldNotTransformException("Could not transform " + TamperState.State.class.getName() + "! " + TamperState.State.class.getSimpleName() + "[" + tamperState.getValue().name() + "] is unknown!"); } } }
public static Double transform(final AlarmState alarmState) throws CouldNotTransformException { try { switch (alarmState.getValue()) { case NO_ALARM: return 0d; case ALARM: return 1d; case UNKNOWN: throw new InvalidStateException("Unknown state is invalid!"); default: throw new TypeNotSupportedException(AlarmState.State.class, Double.class); } } catch (CouldNotPerformException ex) { throw new CouldNotTransformException("Could not transform " + AlarmState.State.class.getName() + "!", ex); } } }
public static Double transform(final MotionState motionState) throws CouldNotTransformException { try { switch (motionState.getValue()) { case NO_MOTION: return 0d; case MOTION: return 1d; case UNKNOWN: throw new InvalidStateException("Unknown state is invalid!"); default: throw new TypeNotSupportedException(MotionState.State.class, Double.class); } } catch (CouldNotPerformException ex) { throw new CouldNotTransformException("Could not transform " + MotionState.State.class.getName() + "!", ex); } } }
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 OnOffHolder transform(final ActivationState.State activationState) throws TypeNotSupportedException, CouldNotTransformException { switch (activationState) { case DEACTIVE: return OnOffHolder.newBuilder().setState(OnOffHolder.OnOff.OFF).build(); case ACTIVE: return OnOffHolder.newBuilder().setState(OnOffHolder.OnOff.ON).build(); case UNKNOWN: throw new TypeNotSupportedException(activationState, OnOffHolder.OnOff.class); default: throw new CouldNotTransformException("Could not transform " + ActivationState.State.class.getName() + "! " + ActivationState.State.class.getSimpleName() + "[" + activationState.name() + "] is unknown!"); } } }
public static OnOffHolderType.OnOffHolder transform(PowerState.State powerState) throws TypeNotSupportedException, CouldNotTransformException { switch (powerState) { case OFF: return OnOffHolderType.OnOffHolder.newBuilder().setState(OnOffHolderType.OnOffHolder.OnOff.OFF).build(); case ON: return OnOffHolderType.OnOffHolder.newBuilder().setState(OnOffHolderType.OnOffHolder.OnOff.ON).build(); case UNKNOWN: throw new TypeNotSupportedException(powerState, OnOffHolderType.OnOffHolder.OnOff.class); default: throw new CouldNotTransformException("Could not transform " + PowerState.State.class.getName() + "! " + PowerState.State.class.getSimpleName() + "[" + powerState.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 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 OpenClosedHolder transform(ContactState contactState) throws CouldNotTransformException { try { switch (contactState.getValue()) { case CLOSED: return OpenClosedHolder.newBuilder().setState(OpenClosedHolder.OpenClosed.CLOSED).build(); case OPEN: return OpenClosedHolder.newBuilder().setState(OpenClosedHolder.OpenClosed.OPEN).build(); case UNKNOWN: throw new InvalidStateException("Unknown state is invalid!"); default: throw new TypeNotSupportedException(contactState, OpenClosedHolder.class); } } catch (CouldNotPerformException ex) { throw new CouldNotTransformException("Could not transform " + ContactState.class.getName() + "!", ex); } } }
public static StopMoveHolder transform(BlindState blindState) throws TypeNotSupportedException, CouldNotTransformException { switch (blindState.getMovementState()) { case STOP: return StopMoveHolder.newBuilder().setState(StopMoveHolder.StopMove.STOP).build(); case UP: return StopMoveHolder.newBuilder().setState(StopMoveHolder.StopMove.MOVE).build(); case DOWN: return StopMoveHolder.newBuilder().setState(StopMoveHolder.StopMove.MOVE).build(); case UNKNOWN: throw new TypeNotSupportedException(blindState, StopMoveHolder.StopMove.class); default: throw new CouldNotTransformException("Could not transform " + BlindState.class.getName() + "! " + BlindState.class.getSimpleName() + "[" + blindState.getMovementState().name() + "] is unknown!"); } } }