private Value getValue(
      final ODataValue value, final Class<? extends Entry> reference, final boolean setType) {
    Value valueResource = null;

    if (value == null) {
      valueResource = new NullValueImpl();
    } else if (value.isPrimitive()) {
      valueResource = new PrimitiveValueImpl(value.asPrimitive().toString());
    } else if (value.isGeospatial()) {
      valueResource = new GeospatialValueImpl(value.asGeospatial().toValue());
    } else if (value.isComplex()) {
      final ODataComplexValue _value = value.asComplex();
      valueResource = new ComplexValueImpl();

      for (final Iterator<ODataProperty> itor = _value.iterator(); itor.hasNext(); ) {
        valueResource.asComplex().get().add(getProperty(itor.next(), reference, setType));
      }
    } else if (value.isCollection()) {
      final ODataCollectionValue _value = value.asCollection();
      valueResource = new CollectionValueImpl();

      for (final Iterator<ODataValue> itor = _value.iterator(); itor.hasNext(); ) {
        valueResource.asCollection().get().add(getValue(itor.next(), reference, setType));
      }
    }

    return valueResource;
  }
  private ODataValue getODataValue(final Property resource) {
    ODataValue value = null;

    if (resource.getValue().isSimple()) {
      value =
          client
              .getPrimitiveValueBuilder()
              .setText(resource.getValue().asSimple().get())
              .setType(
                  resource.getType() == null
                      ? null
                      : EdmPrimitiveTypeKind.valueOfFQN(
                          client.getServiceVersion(), resource.getType()))
              .build();
    } else if (resource.getValue().isGeospatial()) {
      value =
          client
              .getGeospatialValueBuilder()
              .setValue(resource.getValue().asGeospatial().get())
              .setType(
                  resource.getType() == null
                          || EdmPrimitiveTypeKind.Geography.getFullQualifiedName()
                              .toString()
                              .equals(resource.getType())
                          || EdmPrimitiveTypeKind.Geometry.getFullQualifiedName()
                              .toString()
                              .equals(resource.getType())
                      ? null
                      : EdmPrimitiveTypeKind.valueOfFQN(
                          client.getServiceVersion(), resource.getType()))
              .build();
    } else if (resource.getValue().isComplex()) {
      value = new ODataComplexValue(resource.getType());

      for (Property property : resource.getValue().asComplex().get()) {
        value.asComplex().add(getODataProperty(property));
      }
    } else if (resource.getValue().isCollection()) {
      value = new ODataCollectionValue(resource.getType());

      for (Value _value : resource.getValue().asCollection().get()) {
        final JSONPropertyImpl fake = new JSONPropertyImpl();
        fake.setValue(_value);
        value.asCollection().add(getODataValue(fake));
      }
    }

    return value;
  }