001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.transaction;
016    
017    import java.util.EnumSet;
018    import java.util.HashMap;
019    import java.util.Map;
020    
021    /**
022     * @author Michael Young
023     * @author Shuyang Zhou
024     */
025    public enum Propagation {
026    
027            MANDATORY(TransactionDefinition.PROPAGATION_MANDATORY),
028            NEVER(TransactionDefinition.PROPAGATION_NEVER),
029            NESTED(TransactionDefinition.PROPAGATION_NESTED),
030            NOT_SUPPORTED(TransactionDefinition.PROPAGATION_NOT_SUPPORTED),
031            REQUIRED(TransactionDefinition.PROPAGATION_REQUIRED),
032            REQUIRES_NEW(TransactionDefinition.PROPAGATION_REQUIRES_NEW),
033            SUPPORTS(TransactionDefinition.PROPAGATION_SUPPORTS);
034    
035            public static Propagation getPropagation(int value) {
036                    return _propagations.get(value);
037            }
038    
039            public int value() {
040                    return _value;
041            }
042    
043            private Propagation(int value) {
044                    _value = value;
045            }
046    
047            private static final Map<Integer, Propagation> _propagations =
048                    new HashMap<>();
049    
050            static {
051                    for (Propagation propagation : EnumSet.allOf(Propagation.class)) {
052                            _propagations.put(propagation._value, propagation);
053                    }
054            }
055    
056            private final int _value;
057    
058    }