PageRenderTime 16ms CodeModel.GetById 10ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

/src/main/java/com/google/ie/common/util/EntityMapperUtility.java

http://thoughtsite.googlecode.com/
Java | 57 lines | 22 code | 8 blank | 27 comment | 0 complexity | 5a3788edd42035e0e7be0d4dba420a51 MD5 | raw file
 1/* Copyright 2010 Google Inc.
 2 * 
 3 * Licensed under the Apache License, Version 2.0 (the "License");
 4 * you may not use this file except in compliance with the License.
 5 * You may obtain a copy of the License at
 6 * 
 7 *      http://www.apache.org/licenses/LICENSE-2.0
 8 * 
 9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS.
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License
14 */
15
16package com.google.ie.common.util;
17
18import com.google.ie.business.domain.BadWord;
19import com.google.ie.business.domain.Idea;
20import com.google.ie.business.domain.IdeaComment;
21import com.google.ie.business.domain.Project;
22import com.google.ie.business.domain.ProjectComment;
23
24import java.io.Serializable;
25import java.util.HashMap;
26import java.util.Map;
27
28/**
29 * Utility class to map the entity name with the entity
30 * 
31 * @author adahiya
32 * 
33 */
34public class EntityMapperUtility {
35
36    /** Map to store name to entity mapping */
37    private static Map<String, Class<? extends Serializable>> indexableEntities = new HashMap<String, Class<? extends Serializable>>();
38
39    static {
40        indexableEntities.put(Idea.class.getSimpleName(), Idea.class);
41        indexableEntities.put(BadWord.class.getSimpleName(), BadWord.class);
42        indexableEntities.put(IdeaComment.class.getSimpleName(), IdeaComment.class);
43        indexableEntities.put(Project.class.getSimpleName(), Project.class);
44        indexableEntities.put(ProjectComment.class.getSimpleName(), ProjectComment.class);
45    }
46
47    /**
48     * Return the mapped entity identified by entity name
49     * 
50     * @param entityName name of the entity to be mapped
51     * @return entity class
52     */
53    public static Class<? extends Serializable> getEntity(String entityName) {
54        return indexableEntities.get(entityName);
55    }
56}
57