001/**
002 * Copyright 2010-2014 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.common.util.metainf.spring;
017
018import org.kuali.common.util.Assert;
019import org.kuali.common.util.metainf.service.MetaInfUtils;
020
021public class MetaInfConfigUtils {
022
023        private static final String INCLUDES = "includes";
024        private static final String EXCLUDES = "excludes";
025
026        /**
027         * <code>group</code> is optional
028         * 
029         * <pre>
030         * metainf.[prefix].[group].[suffix]
031         * 
032         * metainf.[prefix].[suffix]
033         * </pre>
034         */
035        public static String getKey(String prefix, MetaInfGroup group, String suffix) {
036                Assert.noNullsWithMsg("prefix and suffix are required", prefix, suffix);
037                StringBuilder sb = new StringBuilder();
038                sb.append(MetaInfUtils.PROPERTY_PREFIX);
039                sb.append(".");
040                sb.append(prefix);
041                if (group != null) {
042                        sb.append(".");
043                        sb.append(group.name().toLowerCase());
044                }
045                sb.append(".");
046                sb.append(suffix);
047                return sb.toString();
048        }
049
050        /**
051         * <code>metainf.[prefix].includes</code>
052         */
053        public static String getIncludesKey(String prefix) {
054                return getKey(prefix, null, INCLUDES);
055        }
056
057        /**
058         * <code>metainf.[prefix].excludes</code>
059         */
060        public static String getExcludesKey(String prefix) {
061                return getKey(prefix, null, EXCLUDES);
062        }
063
064        /**
065         * <code>metainf.[prefix].[group].includes</code>
066         */
067        public static String getIncludesKey(MetaInfGroup group, String prefix) {
068                return getKey(prefix, group, INCLUDES);
069        }
070
071        /**
072         * <code>metainf.[prefix].[group].excludes</code>
073         */
074        public static String getExcludesKey(MetaInfGroup group, String prefix) {
075                return getKey(prefix, group, EXCLUDES);
076        }
077
078}