// Path: scheduled-actions-core/src/main/java/com/netflix/scheduledactions/Context.java
// public class Context {
//     private String actionInstanceId;
//     private final String name;
//     private final String group;
//     private final Map<String, String> parameters;
// 
//     @JsonCreator
//     public Context(@JsonProperty("actionInstanceId") String actionInstanceId,
//                    @JsonProperty("name") String name,
//                    @JsonProperty("group") String group,
//                    @JsonProperty("parameters") Map<String, String> parameters) {
//         this.actionInstanceId = actionInstanceId;
//         this.name = name;
//         this.group = group;
//         this.parameters = parameters;
//     }
// 
//     public void setActionInstanceId(String actionInstanceId) {
//         this.actionInstanceId = actionInstanceId;
//     }
// 
//     public String getActionInstanceId() {
//       return actionInstanceId;
//     }
// 
//     public String getName() {
//         return name;
//       }
// 
//     public String getGroup() {
//       return group;
//     }
// 
//     public Map<String, String> getParameters() {
//       return parameters;
//     }
// 
//     @Override
//     public String toString() {
//         return String.format(
//             "Context: (actionInstance: %s, name: %s, group: %s, parameters: %s)", actionInstanceId, name, group, parameters
//         );
//     }
// }


import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.netflix.scheduledactions.Context;
import rx.functions.Action1;
import java.util.Date;
/*
 * Copyright 2015 Netflix, Inc.
 *
 * 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 com.netflix.scheduledactions.triggers;



public class CronTrigger implements Trigger {

    private final String cronExpression;
    private final Date startAt;
    private final String timeZoneId;

    public CronTrigger(String cronExpression) {
        this(cronExpression, "America/Los_Angeles", new Date());
    }

    @JsonCreator
    public CronTrigger(@JsonProperty("cronExpression") String cronExpression,
                       @JsonProperty("timeZoneId") String timeZoneId,
                       @JsonProperty("startAt") Date startAt) {
        this.cronExpression = cronExpression;
        this.timeZoneId = timeZoneId;
        this.startAt = startAt;
    }

    @Override
    public void validate() throws IllegalArgumentException {
        CronExpressionFuzzer.validate(cronExpression);
    }

    @Override
    public com.netflix.fenzo.triggers.Trigger<Context> createFenzoTrigger(Context context,
                                                                          Class<? extends Action1<Context>> action) {
        return new com.netflix.fenzo.triggers.CronTrigger<>(
// Path: scheduled-actions-core/src/main/java/com/netflix/scheduledactions/Context.java
// public class Context {
//     private String actionInstanceId;
//     private final String name;
//     private final String group;
//     private final Map<String, String> parameters;
// 
//     @JsonCreator
//     public Context(@JsonProperty("actionInstanceId") String actionInstanceId,
//                    @JsonProperty("name") String name,
//                    @JsonProperty("group") String group,
//                    @JsonProperty("parameters") Map<String, String> parameters) {
//         this.actionInstanceId = actionInstanceId;
//         this.name = name;
//         this.group = group;
//         this.parameters = parameters;
//     }
// 
//     public void setActionInstanceId(String actionInstanceId) {
//         this.actionInstanceId = actionInstanceId;
//     }
// 
//     public String getActionInstanceId() {
//       return actionInstanceId;
//     }
// 
//     public String getName() {
//         return name;
//       }
// 
//     public String getGroup() {
//       return group;
//     }
// 
//     public Map<String, String> getParameters() {
//       return parameters;
//     }
// 
//     @Override
//     public String toString() {
//         return String.format(
//             "Context: (actionInstance: %s, name: %s, group: %s, parameters: %s)", actionInstanceId, name, group, parameters
//         );
//     }
// }


// Path: scheduled-actions-core/src/main/java/com/netflix/scheduledactions/triggers/CronTrigger.java
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.netflix.scheduledactions.Context;
import rx.functions.Action1;
import java.util.Date;

/*
 * Copyright 2015 Netflix, Inc.
 *
 * 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 com.netflix.scheduledactions.triggers;



public class CronTrigger implements Trigger {

    private final String cronExpression;
    private final Date startAt;
    private final String timeZoneId;

    public CronTrigger(String cronExpression) {
        this(cronExpression, "America/Los_Angeles", new Date());
    }

    @JsonCreator
    public CronTrigger(@JsonProperty("cronExpression") String cronExpression,
                       @JsonProperty("timeZoneId") String timeZoneId,
                       @JsonProperty("startAt") Date startAt) {
        this.cronExpression = cronExpression;
        this.timeZoneId = timeZoneId;
        this.startAt = startAt;
    }

    @Override
    public void validate() throws IllegalArgumentException {
        CronExpressionFuzzer.validate(cronExpression);
    }

    @Override
    public com.netflix.fenzo.triggers.Trigger<Context> createFenzoTrigger(Context context,
                                                                          Class<? extends Action1<Context>> action) {
        return new com.netflix.fenzo.triggers.CronTrigger<>(
            this.cronExpression, this.timeZoneId, this.startAt, context.getName(), context, Context.class, action