Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2013 SAP AG 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.sap.core.odata.core.ep.aggregator;
 
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 

Author(s):
SAP AG
 
 public class EntityTypeMapping {
   private static final EntityTypeMapping ENTITY_TYPE_MAPPING = new EntityTypeMapping();
   final String propertyName;
   final Class<?> mapping;
 
   private EntityTypeMapping() {
     this(nullObject.class);
   }
 
   private EntityTypeMapping(final String namefinal Class<?> mappingClass) {
      = name;
      = mappingClass;
      = Collections.emptyList();
   }
 
   private EntityTypeMapping(final String namefinal List<EntityTypeMappingtypeMappings) {
      = name;
      = EntityTypeMapping.class;
     for (EntityTypeMapping typeMapping : typeMappings) {
       tmp.add(typeMapping);
     }
      = Collections.unmodifiableList(tmp);
   }
 
   public static EntityTypeMapping create(final Map<StringObjectmappingsthrows EntityProviderException {
     return create(nullmappings);
   }
 
   @SuppressWarnings("unchecked")
   public static EntityTypeMapping create(final String namefinal Map<StringObjectmappingsthrows EntityProviderException {
     if (mappings == null) {
       return ;
     }
     List<EntityTypeMappingtypeMappings = new ArrayList<EntityTypeMapping>();
     Set<Entry<StringObject>> entries = mappings.entrySet();
     for (Entry<StringObjectentry : entries) {
       EntityTypeMapping typeMapping;
       Object value = entry.getValue();
       if (value instanceof Map) {
         typeMapping = create(entry.getKey(), (Map<StringObject>) value);
       } else if (value instanceof Class) {
         typeMapping = new EntityTypeMapping(entry.getKey(), (Class<?>) value);
       } else {
       }
       typeMappings.add(typeMapping);
     }
 
     return new EntityTypeMapping(nametypeMappings);
   }
 
   boolean isComplex() {
     return  != null &&  == EntityTypeMapping.class;
   }

  
If this EntityTypeMapping is complex the mapping for the property with the given name is returned; otherwise an empty EntityTypeMapping is returned.

Parameters:
name
Returns:
the mapping for this entity type
 
   public EntityTypeMapping getEntityTypeMapping(final String name) {
     if (isComplex()) {
       for (EntityTypeMapping mapping : ) {
         if (mapping.propertyName.equals(name)) {
           return mapping;
         }
      }
    }
    return ;
  }

  
If this EntityTypeMapping is complex the mapping java.lang.Class for the property with the given name is returned; otherwise NULL is returned.

Parameters:
name
Returns:
mapping java.lang.Class for the property with given name or NULL.
  public Class<?> getMappingClass(final String name) {
    if (isComplex()) {
      for (EntityTypeMapping mapping : ) {
        if (mapping.propertyName.equals(name)) {
          return mapping.mapping;
        }
      }
    }
    return null;
  }
  public String toString() {
    if (isComplex()) {
      return "{'" +  + "'->" + .toString() + "}";
    }
    return "{'" +  + "' as " + ( == null ? "NULL" : .getSimpleName()) + "}";
  }
New to GrepCode? Check out our FAQ X