/*
 * Copyright 2017 Gregory Moyer
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.syphr.lametrictime.api.model;

import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalUnit;
import java.util.SortedMap;
import java.util.TreeMap;

import org.syphr.lametrictime.api.local.model.BooleanParameter;
import org.syphr.lametrictime.api.local.model.Parameter;
import org.syphr.lametrictime.api.local.model.StringParameter;
import org.syphr.lametrictime.api.local.model.UpdateAction;

public class ClockApp extends CoreApplication
{
    private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern("HH:mm:ss");

    private static final String NAME = "com.lametric.clock";

    private static final String ACTION_ALARM = "clock.alarm";

    private static final String PARAMETER_ENABLED = "enabled";
    private static final String PARAMETER_TIME = "time";
    private static final String PARAMETER_WAKE_WITH_RADIO = "wake_with_radio";

    public ClockApp()
    {
        super(NAME);
    }

    public CoreAction setAlarm(Boolean enabled, LocalTime time, Boolean wakeWithRadio)
    {
        SortedMap<String, Parameter> parameters = new TreeMap<>();

        if (enabled != null)
        {
            parameters.put(PARAMETER_ENABLED, new BooleanParameter().withValue(enabled));
        }

        if (time != null)
        {
            parameters.put(PARAMETER_TIME,
                           new StringParameter().withValue(time.format(TIME_FORMATTER)));
        }

        if (wakeWithRadio != null)
        {
            parameters.put(PARAMETER_WAKE_WITH_RADIO,
                           new BooleanParameter().withValue(wakeWithRadio));
        }

        return new CoreAction(this,
                              new UpdateAction().withId(ACTION_ALARM).withParameters(parameters));
    }

    public CoreAction snooze(long amount, TemporalUnit unit)
    {
        SortedMap<String, Parameter> parameters = new TreeMap<>();
        parameters.put(PARAMETER_ENABLED, new BooleanParameter().withValue(true));
        parameters.put(PARAMETER_TIME, new StringParameter().withValue(LocalTime.now()
                                                                                .plus(amount, unit)
                                                                                .format(TIME_FORMATTER)));

        return new CoreAction(this,
                              new UpdateAction().withId(ACTION_ALARM).withParameters(parameters));
    }

    public CoreAction stopAlarm()
    {
        SortedMap<String, Parameter> parameters = new TreeMap<>();
        parameters.put(PARAMETER_ENABLED, new BooleanParameter().withValue(false));

        return new CoreAction(this,
                              new UpdateAction().withId(ACTION_ALARM).withParameters(parameters));
    }
}

@@ -708,48 +708,8 @@
 er;%0A
-import java.time.temporal.TemporalUnit;%0A
 impo
@@ -2349,662 +2349,8 @@
  %7D%0A%0A
-    public CoreAction snooze(long amount, TemporalUnit unit)%0A    %7B%0A        SortedMap%3CString, Parameter%3E parameters = new TreeMap%3C%3E();%0A        parameters.put(PARAMETER_ENABLED, new BooleanParameter().withValue(true));%0A        parameters.put(PARAMETER_TIME, new StringParameter().withValue(LocalTime.now()%0A                                                                                .plus(amount, unit)%0A                                                                                .format(TIME_FORMATTER)));%0A%0A        return new CoreAction(this,%0A                              new UpdateAction().withId(ACTION_ALARM).withParameters(parameters));%0A    %7D%0A%0A
     

Remove the snooze action on the Clock app