<commit_before>package utils.typesafe.extended;

import java.util.ArrayList;
import java.util.List;

/**
 * 业务逻辑的原子操作
 * Created by Jake on 2015/7/19.
 */
public abstract class PromiseActor<T> implements Promiseable<T> {

    private List<MultiSafeType> safeTypes = new ArrayList<MultiSafeType>();

    /**
     * 获取操作相关类型,必要时候重写
     * <br/>(多对象修改在一个原子性操作的时候)
     * @return
     */
    @Override
    public MultiSafeType[] promiseTypes() {
        return new MultiSafeType[]{(MultiSafeType) this.get()};
    }

    /**
     * 当获取所需要的关联操作后,when代表将子操作纳入本操作组成新的原子性操作
     * @param promiseables
     * @return
     */
    public void when(Promiseable... promiseables) {
        if (promiseables == null || promiseables.length == 0) {
            throw new IllegalArgumentException("promiseables must more than one arguments");
        }

        for (int i = 0;i < promiseables.length;i++) {
            Promiseable<?> promiseable = promiseables[i];
            for (MultiSafeType safeType : promiseable.promiseTypes()) {
                safeTypes.add(safeType);
            }
        }
    }<commit_msg>新增PromiseActor<commit_after>package utils.typesafe.extended;

import java.util.ArrayList;
import java.util.List;

/**
 * 业务逻辑的原子操作
 * Created by Jake on 2015/7/19.
 */
public abstract class PromiseActor<T> implements Promiseable<T> {

    // 关联的所有线程安全对象
    private List<MultiSafeType> safeTypes = new ArrayList<MultiSafeType>();

    /**
     * 获取操作相关类型,必要时候重写
     * <br/>(多对象修改在一个原子性操作的时候)
     * @return
     */
    @Override
    public MultiSafeType[] promiseTypes() {
        return new MultiSafeType[]{(MultiSafeType) this.get()};
    }

    /**
     * 当获取所需要的关联操作后,when代表将子操作纳入本操作组成新的原子性操作
     * @param promiseables
     * @return
     */
    public void when(Promiseable... promiseables) {
        if (promiseables == null || promiseables.length == 0) {
            throw new IllegalArgumentException("promiseables must more than one arguments");
        }

        for (int i = 0;i < promiseables.length;i++) {
            Promiseable<?> promiseable = promiseables[i];
            for (MultiSafeType safeType : promiseable.promiseTypes()) {
                safeTypes.add(safeType);
            }
        }
    }
{'fraction_non_alphanumeric': 0.11870503597122302, 'fraction_numerical': 0.008093525179856115, 'mean_word_length': 2.5486443381180224, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1369353', 'n_tokens_mistral': 765, 'n_tokens_neox': 780, 'n_words': 137}