/*
 * Copyright 2017 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.spinnaker.orca.pipeline.expressions.whitelisting;

import java.util.*;
import com.netflix.spinnaker.orca.ExecutionStatus;
import com.netflix.spinnaker.orca.pipeline.model.Execution;
import com.netflix.spinnaker.orca.pipeline.model.Stage;

public interface ReturnTypeRestrictor extends InstantiationTypeRestrictor {
  Set<Class<?>> allowedReturnTypes = Collections.unmodifiableSet(
    new HashSet<>(
      Arrays.asList(
        Collection.class,
        Map.class,
        SortedMap.class,
        List.class,
        Set.class,
        SortedSet.class,
        ArrayList.class,
        LinkedList.class,
        HashSet.class,
        LinkedHashSet.class,
        HashMap.class,
        LinkedHashMap.class,
        TreeMap.class,
        TreeSet.class,
        Execution.class,
        Stage.class,
        ExecutionStatus.class,
        Execution.AuthenticationDetails.class,
        Execution.PausedDetails.class
      )
    )
  );

  static boolean supports(Class<?> type) {
    final Class<?> returnType = type.isArray() ? type.getComponentType() : type;
    return returnType.isPrimitive() || InstantiationTypeRestrictor.supports(returnType) || allowedReturnTypes.contains(returnType);
  }
}

@@ -663,28 +663,8 @@
 g;%0A%0A
-import java.util.*;%0A
 impo
@@ -819,21 +819,577 @@
 e.model.
-Stage
+JenkinsTrigger;%0Aimport com.netflix.spinnaker.orca.pipeline.model.Stage;%0Aimport com.netflix.spinnaker.orca.pipeline.model.Trigger;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.Arrays;%0Aimport java.util.Collection;%0Aimport java.util.Collections;%0Aimport java.util.HashMap;%0Aimport java.util.HashSet;%0Aimport java.util.LinkedHashMap;%0Aimport java.util.LinkedHashSet;%0Aimport java.util.LinkedList;%0Aimport java.util.List;%0Aimport java.util.Map;%0Aimport java.util.Set;%0Aimport java.util.SortedMap;%0Aimport java.util.SortedSet;%0Aimport java.util.TreeMap;%0Aimport java.util.TreeSet
 ;%0A%0Apubli
@@ -1938,32 +1938,185 @@
    Stage.class,%0A
+        Trigger.class,%0A        JenkinsTrigger.BuildInfo.class,%0A        JenkinsTrigger.JenkinsArtifact.class,%0A        JenkinsTrigger.SourceControl.class,%0A
         Executio

Support new return types in SpEL expressions