当前位置: 首页>>代码示例>>Java>>正文


Java ClientValue.isComplex方法代码示例

本文整理汇总了Java中org.apache.olingo.client.api.domain.ClientValue.isComplex方法的典型用法代码示例。如果您正苦于以下问题:Java ClientValue.isComplex方法的具体用法?Java ClientValue.isComplex怎么用?Java ClientValue.isComplex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.olingo.client.api.domain.ClientValue的用法示例。


在下文中一共展示了ClientValue.isComplex方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: asJavaCollection

import org.apache.olingo.client.api.domain.ClientValue; //导入方法依赖的package包/类
@Override
public Collection<Object> asJavaCollection() {
  final List<Object> result = new ArrayList<Object>();
  for (ClientValue value : values) {
    if (value.isPrimitive()) {
      result.add(value.asPrimitive().toValue());
    } else if (value.isComplex()) {
      result.add(value.asComplex().asJavaMap());
    } else if (value.isCollection()) {
      result.add(value.asCollection().asJavaCollection());
    } else if (value.isEnum()) {
      result.add(value.asEnum().toString());
    }
  }

  return result;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:18,代码来源:ClientCollectionValueImpl.java

示例2: prettyPrint

import org.apache.olingo.client.api.domain.ClientValue; //导入方法依赖的package包/类
private static String prettyPrint(Collection<ClientProperty> properties, int level) {
  StringBuilder b = new StringBuilder();

  for (ClientProperty entry : properties) {
    intend(b, level);
    ClientValue value = entry.getValue();
    if (value.isCollection()) {
      ClientCollectionValue cclvalue = value.asCollection();
      b.append(prettyPrint(cclvalue.asJavaCollection(), level + 1));
    } else if (value.isComplex()) {
      ClientComplexValue cpxvalue = value.asComplex();
      b.append(prettyPrint(cpxvalue.asJavaMap(), level + 1));
    } else if (value.isEnum()) {
      ClientEnumValue cnmvalue = value.asEnum();
      b.append(entry.getName()).append(": ");
      b.append(cnmvalue.getValue()).append("\n");
    } else if (value.isPrimitive()) {
      b.append(entry.getName()).append(": ");
      b.append(entry.getValue()).append("\n");
    }
  }
  return b.toString();
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:24,代码来源:OlingoSampleApp.java

示例3: updateValuable

import org.apache.olingo.client.api.domain.ClientValue; //导入方法依赖的package包/类
private void updateValuable(final Valuable propertyResource, final ClientValuable odataValuable) {
  final Object propertyValue = getValue(odataValuable.getValue());
  if (odataValuable.hasPrimitiveValue()) {
    propertyResource.setType(odataValuable.getPrimitiveValue().getTypeName());
    propertyResource.setValue(
        propertyValue instanceof Geospatial ? ValueType.GEOSPATIAL : ValueType.PRIMITIVE,
        propertyValue);
  } else if (odataValuable.hasEnumValue()) {
    propertyResource.setType(odataValuable.getEnumValue().getTypeName());
    propertyResource.setValue(ValueType.ENUM, propertyValue);
  } else if (odataValuable.hasComplexValue()) {
    propertyResource.setType(odataValuable.getComplexValue().getTypeName());
    propertyResource.setValue(ValueType.COMPLEX, propertyValue);
  } else if (odataValuable.hasCollectionValue()) {
    final ClientCollectionValue<ClientValue> collectionValue =
        odataValuable.getCollectionValue();
    propertyResource.setType(collectionValue.getTypeName());
    final ClientValue value = collectionValue.iterator().hasNext() ? collectionValue.iterator().next() : null;
    ValueType valueType = ValueType.COLLECTION_PRIMITIVE;
    if (value == null) {
      valueType = ValueType.COLLECTION_PRIMITIVE;
    } else if (value.isPrimitive()) {
      valueType = value.asPrimitive().toValue() instanceof Geospatial
          ? ValueType.COLLECTION_GEOSPATIAL : ValueType.COLLECTION_PRIMITIVE;
    } else if (value.isEnum()) {
      valueType = ValueType.COLLECTION_ENUM;
    } else if (value.isComplex()) {
      valueType = ValueType.COLLECTION_COMPLEX;
    }
    propertyResource.setValue(valueType, propertyValue);
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:33,代码来源:ODataBinderImpl.java

示例4: populate

import org.apache.olingo.client.api.domain.ClientValue; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked" })
private static void populate(
    final EdmEnabledODataClient client,
    final EntityInvocationHandler typeHandler,
    final Object bean,
    final Class<?> typeRef,
    final Class<? extends Annotation> getterAnn,
    final Iterator<? extends ClientProperty> propItor) {

  if (bean != null) {
    while (propItor.hasNext()) {
      final ClientProperty property = propItor.next();

      final Method getter = ClassUtils.findGetterByAnnotatedName(typeRef, getterAnn, property.getName());

      if (getter == null) {
        LOG.warn("Could not find any property annotated as {} in {}",
            property.getName(), bean.getClass().getName());
      } else {
        try {
          if (property.hasNullValue()) {
            setPropertyValue(bean, getter, null);
          } else if (property.hasPrimitiveValue()) {
            setPropertyValue(bean, getter, primitiveValueToObject(
                property.getPrimitiveValue(), getPropertyClass(typeRef, property.getName())));
          } else if (property.hasComplexValue()) {
            final Object complex = Proxy.newProxyInstance(
                Thread.currentThread().getContextClassLoader(),
                new Class<?>[] { getter.getReturnType() },
                ComplexInvocationHandler.getInstance(typeHandler, getter.getReturnType()));

            populate(client, typeHandler, complex, Property.class, property.getValue().asComplex().iterator());
            setPropertyValue(bean, getter, complex);
          } else if (property.hasCollectionValue()) {
            final ParameterizedType collType = (ParameterizedType) getter.getGenericReturnType();
            final Class<?> collItemClass = (Class<?>) collType.getActualTypeArguments()[0];

            Collection<Object> collection = (Collection<Object>) getter.invoke(bean);
            if (collection == null) {
              collection = new ArrayList<Object>();
              setPropertyValue(bean, getter, collection);
            }

            final Iterator<ClientValue> collPropItor = property.getValue().asCollection().iterator();
            while (collPropItor.hasNext()) {
              final ClientValue value = collPropItor.next();
              if (value.isPrimitive()) {
                collection.add(primitiveValueToObject(
                    value.asPrimitive(), getPropertyClass(typeRef, property.getName())));
              } else if (value.isComplex()) {
                final Object collItem = Proxy.newProxyInstance(
                    Thread.currentThread().getContextClassLoader(),
                    new Class<?>[] { collItemClass },
                    ComplexInvocationHandler.getInstance(typeHandler, collItemClass));

                populate(client, typeHandler, collItem, Property.class, value.asComplex().iterator());
                collection.add(collItem);
              }
            }
          }
        } catch (Exception e) {
          LOG.error("Could not set property {} on {}", getter, bean, e);
        }
      }
    }
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:68,代码来源:CoreUtils.java


注:本文中的org.apache.olingo.client.api.domain.ClientValue.isComplex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。