Пример #1
0
  /** Returns a property context. */
  @SuppressWarnings({"rawtypes", "unchecked"})
  private MappingContextImpl<Object, Object> propertyContextFor(
      MappingContextImpl<?, ?> context, Object source, Mapping mapping) {
    Class<?> sourceType;
    boolean cyclic = false;

    if (mapping instanceof PropertyMapping) {
      PropertyMappingImpl propertyMapping = (PropertyMappingImpl) mapping;
      sourceType = propertyMapping.getLastSourceProperty().getType();
      cyclic = propertyMapping.cyclic;
    } else if (mapping instanceof ConstantMapping) {
      Object constant = ((ConstantMapping) mapping).getConstant();
      sourceType = constant == null ? Object.class : Types.deProxy(constant.getClass());
    } else {
      sourceType = ((SourceMapping) mapping).getSourceType();
    }

    Class<Object> destinationType = (Class<Object>) mapping.getLastDestinationProperty().getType();
    return new MappingContextImpl(
        context, source, sourceType, null, destinationType, null, mapping, !cyclic);
  }