<commit_before>/*******************************************************************************
 * Copyright 2013-2014 <NAME>
 * 
 * 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.shigengyu.hyperion.core;

import java.util.List;

import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;

public class WorkflowTransitionSet {

	public static WorkflowTransitionSet copyOf(Iterable<WorkflowTransition> transitions) {
		return new WorkflowTransitionSet(ImmutableList.copyOf(transitions));
	}

	public static WorkflowTransitionSet empty() {
		return new WorkflowTransitionSet(ImmutableList.<WorkflowTransition> of());
	}

	private final ImmutableList<WorkflowTransition> transitions;

	private WorkflowTransitionSet(ImmutableList<WorkflowTransition> transitions) {
		this.transitions = transitions;
	}

	public final WorkflowTransitionSet filter(Predicate<WorkflowTransition> predicate) {
		List<WorkflowTransition> filtered = Lists.newArrayList();
		for (WorkflowTransition transition : transitions) {
			if (predicate.apply(transition)) {
				filtered.add(transition);
			}
		}
		return WorkflowTransitionSet.copyOf(filtered);
	}

	public final WorkflowTransitionSet filter(String transitionName) {
		List<WorkflowTransition> list = Lists.newArrayList();
		for (WorkflowTransition transition : transitions) {
			if (transition.getName().equals(transitionName)) {
				list.add(transition);
			}
		}
		return new WorkflowTransitionSet(ImmutableList.copyOf(list));
	}

	public final WorkflowTransitionSet filter(WorkflowStateSet fromStates) {
		List<WorkflowTransition> list = Lists.newArrayList();
		for (WorkflowTransition transition : transitions) {
			if (transition.getFromStates().isSubSetOf(fromStates)) {
				list.add(transition);
			}
		}
		return new WorkflowTransitionSet(ImmutableList.copyOf(list));
	}

	public final WorkflowTransition get(int index) {
		return transitions.get(0);
	}

	public final WorkflowTransitionSet getAutoTransitions() {
		return filter(new Predicate<WorkflowTransition>() {

			@Override<commit_msg>Fix typo<commit_after>/*******************************************************************************
 * Copyright 2013-2014 <NAME>
 * 
 * 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.shigengyu.hyperion.core;

import java.util.List;

import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;

public class WorkflowTransitionSet {

	public static WorkflowTransitionSet copyOf(Iterable<WorkflowTransition> transitions) {
		return new WorkflowTransitionSet(ImmutableList.copyOf(transitions));
	}

	public static WorkflowTransitionSet empty() {
		return new WorkflowTransitionSet(ImmutableList.<WorkflowTransition> of());
	}

	private final ImmutableList<WorkflowTransition> transitions;

	private WorkflowTransitionSet(ImmutableList<WorkflowTransition> transitions) {
		this.transitions = transitions;
	}

	public final WorkflowTransitionSet filter(Predicate<WorkflowTransition> predicate) {
		List<WorkflowTransition> filtered = Lists.newArrayList();
		for (WorkflowTransition transition : transitions) {
			if (predicate.apply(transition)) {
				filtered.add(transition);
			}
		}
		return WorkflowTransitionSet.copyOf(filtered);
	}

	public final WorkflowTransitionSet filter(String transitionName) {
		List<WorkflowTransition> list = Lists.newArrayList();
		for (WorkflowTransition transition : transitions) {
			if (transition.getName().equals(transitionName)) {
				list.add(transition);
			}
		}
		return new WorkflowTransitionSet(ImmutableList.copyOf(list));
	}

	public final WorkflowTransitionSet filter(WorkflowStateSet fromStates) {
		List<WorkflowTransition> list = Lists.newArrayList();
		for (WorkflowTransition transition : transitions) {
			if (transition.getFromStates().isSubSetOf(fromStates)) {
				list.add(transition);
			}
		}
		return new WorkflowTransitionSet(ImmutableList.copyOf(list));
	}

	public final WorkflowTransition get(int index) {
		return transitions.get(index);
	}

	public final WorkflowTransitionSet getAutoTransitions() {
		return filter(new Predicate<WorkflowTransition>() {

			@Override
{'fraction_non_alphanumeric': 0.1421958896500648, 'fraction_numerical': 0.00462877244954638, 'mean_word_length': 5.702233250620347, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3021027', 'n_tokens_mistral': 1523, 'n_tokens_neox': 1376, 'n_words': 376}