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


Java CsdlEnumType类代码示例

本文整理汇总了Java中org.apache.olingo.commons.api.edm.provider.CsdlEnumType的典型用法代码示例。如果您正苦于以下问题:Java CsdlEnumType类的具体用法?Java CsdlEnumType怎么用?Java CsdlEnumType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CsdlEnumType类属于org.apache.olingo.commons.api.edm.provider包,在下文中一共展示了CsdlEnumType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateTypesMapWithType

import org.apache.olingo.commons.api.edm.provider.CsdlEnumType; //导入依赖的package包/类
private <T extends CsdlAbstractEdmItem> void updateTypesMapWithType(T type, Map<FullQualifiedName, T> types) {
    if (type != null) {
        FullQualifiedName fqn;
        if (type instanceof CsdlEntityType) {
            fqn = FullQualifiedNamesUtil.createFullQualifiedEntityName(((CsdlEntityType) type).getName());
        } else if (type instanceof CsdlEnumType) {
            fqn = FullQualifiedNamesUtil.createFullQualifiedEnumName(((CsdlEnumType) type).getName());
        } else if (type instanceof CsdlComplexType) {
            fqn = FullQualifiedNamesUtil.createFullQualifiedComplexTypeName(((CsdlComplexType) type).getName());
        } else {
            throw new IllegalStateException("Unsupported CSDL Type");
        }

        types.put(fqn, type);
    }
}
 
开发者ID:mat3e,项目名称:olingo-jpa,代码行数:17,代码来源:AbstractEdmProvider.java

示例2: EdmEnumTypeImpl

import org.apache.olingo.commons.api.edm.provider.CsdlEnumType; //导入依赖的package包/类
public EdmEnumTypeImpl(final Edm edm, final FullQualifiedName enumName, final CsdlEnumType enumType) {
  super(edm, enumName, EdmTypeKind.ENUM, enumType);

  if (enumType.getUnderlyingType() == null) {
    underlyingType = EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Int32);
  } else {
    final EdmPrimitiveTypeKind underlyingTypeKind = EdmPrimitiveTypeKind.valueOfFQN(enumType.getUnderlyingType());
    if (underlyingTypeKind == EdmPrimitiveTypeKind.Byte
        || underlyingTypeKind == EdmPrimitiveTypeKind.SByte
        || underlyingTypeKind == EdmPrimitiveTypeKind.Int16
        || underlyingTypeKind == EdmPrimitiveTypeKind.Int32
        || underlyingTypeKind == EdmPrimitiveTypeKind.Int64) {
      underlyingType = EdmPrimitiveTypeFactory.getInstance(underlyingTypeKind);
    } else {
      throw new EdmException("Not allowed as underlying type: " + underlyingTypeKind);
    }
  }

  this.enumType = enumType;
  this.enumName = enumName;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:22,代码来源:EdmEnumTypeImpl.java

示例3: getTypeReturnsEnumType

import org.apache.olingo.commons.api.edm.provider.CsdlEnumType; //导入依赖的package包/类
@Test
public void getTypeReturnsEnumType() throws Exception {
  CsdlEdmProvider provider = mock(CsdlEdmProvider.class);
  EdmProviderImpl edm = new EdmProviderImpl(provider);
  final FullQualifiedName enumTypeName = new FullQualifiedName("ns", "enum");
  CsdlEnumType enumTypeProvider = new CsdlEnumType();
  when(provider.getEnumType(enumTypeName)).thenReturn(enumTypeProvider);
  CsdlProperty propertyProvider = new CsdlProperty();
  propertyProvider.setType(enumTypeName);
  final EdmProperty property = new EdmPropertyImpl(edm, propertyProvider);
  assertFalse(property.isCollection());
  assertFalse(property.isPrimitive());
  final EdmType type = property.getType();
  assertEquals(EdmTypeKind.ENUM, type.getKind());
  assertEquals("ns", type.getNamespace());
  assertEquals("enum", type.getName());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:18,代码来源:EdmPropertyImplTest.java

示例4: getTypeReturnsEnumType

import org.apache.olingo.commons.api.edm.provider.CsdlEnumType; //导入依赖的package包/类
@Test
public void getTypeReturnsEnumType() throws Exception {
  CsdlEdmProvider provider = mock(CsdlEdmProvider.class);
  EdmProviderImpl edm = new EdmProviderImpl(provider);
  final FullQualifiedName enumTypeName = new FullQualifiedName("ns", "enum");
  CsdlEnumType enumTypeProvider = new CsdlEnumType();
  when(provider.getEnumType(enumTypeName)).thenReturn(enumTypeProvider);
  CsdlParameter parameterProvider = new CsdlParameter();
  parameterProvider.setType(enumTypeName);
  final EdmParameter parameter = new EdmParameterImpl(edm, parameterProvider);
  assertFalse(parameter.isCollection());
  final EdmType type = parameter.getType();
  assertEquals(EdmTypeKind.ENUM, type.getKind());
  assertEquals("ns", type.getNamespace());
  assertEquals("enum", type.getName());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:17,代码来源:EdmParameterImplTest.java

示例5: getEnumType

import org.apache.olingo.commons.api.edm.provider.CsdlEnumType; //导入依赖的package包/类
@Override
public CsdlEnumType getEnumType(final FullQualifiedName enumTypeName) throws ODataException {
  
  if (nameENString.equals(enumTypeName)) {
    
    CsdlAnnotation memberAnnotation = new CsdlAnnotation()
        .setTerm("Core.Description")
        .setQualifier("Target")
        .setExpression(new CsdlConstantExpression(ConstantExpressionType.String, "Description of Enum Member"));
    
    return new CsdlEnumType()
    .setName(nameENString.getName())
    .setFlags(true)
    .setUnderlyingType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName())
    .setMembers(Collections.singletonList(
        new CsdlEnumMember().setName("String1").setValue("1").setAnnotations(Arrays.asList(memberAnnotation))));
  }
  return null;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:20,代码来源:MetadataDocumentJsonSerializerTest.java

示例6: addEnumType

import org.apache.olingo.commons.api.edm.provider.CsdlEnumType; //导入依赖的package包/类
/**
 * create an enum with upto 0xffff values. This may be larger than a Java VM may accept. The Java
 * Language Specication is silent on what the largest number of enums can be.
 * <p>
 * Enums can be used in request filters. The enum can represents a mututally exclusive state, for
 * example a car color of RED or GREEN. In this case a filter use only RED or GREEN but not both.
 * </p
 * <p>
 * Enums may also represent a properties that are not mutually exclusive and can be combined using
 * bitwise operators. For example a file may have READ_ACCESS and WRITE_ACCESS. In this case a
 * filter may list both READ_ACCESS and WRITE_ACCESS.
 * </p>
 * <p>
 * When choosing between the two types of enums, think carefully about the enums use in a filter.
 * While it may be true that a car comes in RED or GREEN and that is multually exclusive there may
 * be an advantage to having a filter search for RED and GREEN cars.
 * </p>
 *
 * @param enumTypeName the name of the enum in the EDM.
 * @param isEnumValuesMututallyExclusive if true a query of the enums can only contain one enum.
 *        If false multiple enums of the same type can be listed in the query.
 * @param enumValues the values of the enum in the EDM.
 * @return the full qualified name of the enumeration. This value would be used by the caller when
 *         it needs to define the enum
 */
protected FullQualifiedName addEnumType(String enumTypeName,
    boolean isEnumValuesMututallyExclusive, String... enumValues) {
  List<CsdlEnumMember> list = new ArrayList<>();
  int i = 0;

  for (String currentName : enumValues) {
    CsdlEnumMember cem = new CsdlEnumMember().setName(currentName);

    cem.setValue(i + "");

    list.add(cem);
    ++i;
  }

  final EdmPrimitiveTypeKind primitiveTypeKind;

  if (i <= 255) {
    primitiveTypeKind = EdmPrimitiveTypeKind.SByte;
  } else if (i <= 0xffff) {
    primitiveTypeKind = EdmPrimitiveTypeKind.Int16;
  } else {
    primitiveTypeKind = EdmPrimitiveTypeKind.Int32;
  }

  final CsdlEnumType enumProvider = new CsdlEnumType().setName(enumTypeName).setMembers(list)
      .setUnderlyingType(primitiveTypeKind.getFullQualifiedName());

  enumTypeList.add(enumProvider);

  FullQualifiedName fqn =
      new FullQualifiedName(RedHxServiceEdmProvider.SCHEMA_NAME_SPACE, enumTypeName);

  return fqn;
}
 
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:60,代码来源:RedHxAbstractEdmEntityProvider.java

示例7: getEnumType

import org.apache.olingo.commons.api.edm.provider.CsdlEnumType; //导入依赖的package包/类
public CsdlEnumType getEnumType(final FullQualifiedName enumTypeName) throws ODataException {
  if (enumTypeName.equals(nameENString)) {
    return new CsdlEnumType().setName("ENString").setFlags(true)
        .setUnderlyingType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName())
        .setMembers(Arrays.asList(new CsdlEnumMember().setName("String1").setValue("1"),
            new CsdlEnumMember().setName("String2").setValue("2"),
            new CsdlEnumMember().setName("String3").setValue("4")));
  }

  return null;
}
 
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:12,代码来源:EnumTypeProvider.java

示例8: getEnumType

import org.apache.olingo.commons.api.edm.provider.CsdlEnumType; //导入依赖的package包/类
public CsdlEnumType getEnumType(final FullQualifiedName enumTypeName) throws ODataException {
  if (enumTypeName.equals(nameENString)) {
    return new CsdlEnumType()
        .setName("ENString")
        .setFlags(true)
        .setUnderlyingType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName())
        .setMembers(Arrays.asList(
            new CsdlEnumMember().setName("String1").setValue("1"),
            new CsdlEnumMember().setName("String2").setValue("2"),
            new CsdlEnumMember().setName("String3").setValue("4")));
  }

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

示例9: createEnumType

import org.apache.olingo.commons.api.edm.provider.CsdlEnumType; //导入依赖的package包/类
@Override
public EdmEnumType createEnumType(final FullQualifiedName enumName) {
  try {
    CsdlEnumType enumType = provider.getEnumType(enumName);
    if (enumType != null) {
      return new EdmEnumTypeImpl(this, enumName, enumType);
    }
    return null;
  } catch (ODataException e) {
    throw new EdmException(e);
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:13,代码来源:EdmProviderImpl.java

示例10: createEnumTypes

import org.apache.olingo.commons.api.edm.provider.CsdlEnumType; //导入依赖的package包/类
protected List<EdmEnumType> createEnumTypes() {
  final List<EdmEnumType> enumTyps = new ArrayList<EdmEnumType>();
  final List<CsdlEnumType> providerEnumTypes = schema.getEnumTypes();
  if (providerEnumTypes != null) {
    for (CsdlEnumType enumType : providerEnumTypes) {
      FullQualifiedName enumName = new FullQualifiedName(namespace, enumType.getName());
      EdmEnumType enumTypeImpl = new EdmEnumTypeImpl(edm, enumName, enumType);
      enumTyps.add(enumTypeImpl);
      edm.cacheEnumType(enumName, enumTypeImpl);
    }
  }
  return enumTyps;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:14,代码来源:EdmSchemaImpl.java

示例11: setup

import org.apache.olingo.commons.api.edm.provider.CsdlEnumType; //导入依赖的package包/类
@Before
public void setup() throws Exception {
  CsdlEdmProvider provider = mock(CsdlEdmProvider.class);
  CsdlEntityContainerInfo containerInfo = new CsdlEntityContainerInfo().setContainerName(FQN);
  when(provider.getEntityContainerInfo(FQN)).thenReturn(containerInfo);
  when(provider.getEntityContainerInfo(null)).thenReturn(containerInfo);

  CsdlEnumType enumType = new CsdlEnumType().setName(FQN.getName());
  when(provider.getEnumType(FQN)).thenReturn(enumType);

  CsdlTypeDefinition typeDefinition =
      new CsdlTypeDefinition().setName(FQN.getName()).setUnderlyingType(new FullQualifiedName("Edm", "String"));
  when(provider.getTypeDefinition(FQN)).thenReturn(typeDefinition);

  CsdlEntityType entityType = new CsdlEntityType().setName(FQN.getName()).setKey(new ArrayList<CsdlPropertyRef>());
  when(provider.getEntityType(FQN)).thenReturn(entityType);

  CsdlComplexType complexType = new CsdlComplexType().setName(FQN.getName());
  when(provider.getComplexType(FQN)).thenReturn(complexType);

  List<CsdlAliasInfo> aliasInfos = new ArrayList<CsdlAliasInfo>();
  aliasInfos.add(new CsdlAliasInfo().setAlias("alias").setNamespace("namespace"));
  when(provider.getAliasInfos()).thenReturn(aliasInfos);

  CsdlAnnotations annotationsGroup = new CsdlAnnotations();
  annotationsGroup.setTarget("FQN.FQN");
  when(provider.getAnnotationsGroup(FQN, null)).thenReturn(annotationsGroup);

  edm = new EdmProviderImpl(provider);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:31,代码来源:EdmProviderImplTest.java

示例12: expectErrorInUnderlyingType

import org.apache.olingo.commons.api.edm.provider.CsdlEnumType; //导入依赖的package包/类
private void expectErrorInUnderlyingType(final EdmPrimitiveTypeKind underlyingType) {
  try {
    new EdmEnumTypeImpl(null,
        new FullQualifiedName("testNamespace", "testName"),
        new CsdlEnumType()
            .setName("MyEnum")
            .setUnderlyingType(underlyingType.getFullQualifiedName()));
    fail("Expected exception not thrown");
  } catch (final EdmException e) {
    assertNotNull(e.getLocalizedMessage());
    assertThat(e.getLocalizedMessage(), containsString("underlying type"));
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:14,代码来源:EdmEnumTest.java

示例13: getEnumType

import org.apache.olingo.commons.api.edm.provider.CsdlEnumType; //导入依赖的package包/类
@Override
public CsdlEnumType getEnumType(final FullQualifiedName enumTypeName) throws ODataException {
  if (nameENString.equals(enumTypeName)) {
    return new CsdlEnumType()
    .setName(nameENString.getName())
    .setFlags(true)
    .setUnderlyingType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName())
    .setMembers(Collections.singletonList(new CsdlEnumMember().setName("String1").setValue("1")));
  }
  return null;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:12,代码来源:MetadataDocumentXmlSerializerTest.java

示例14: readEnumType

import org.apache.olingo.commons.api.edm.provider.CsdlEnumType; //导入依赖的package包/类
private void readEnumType(XMLEventReader reader, StartElement element, CsdlSchema schema)
    throws XMLStreamException {
  CsdlEnumType type = new CsdlEnumType();
  type.setMembers(new ArrayList<CsdlEnumMember>());
  type.setName(attr(element, "Name"));
  if (attr(element, "UnderlyingType") != null) {
    type.setUnderlyingType(new FullQualifiedName(attr(element, "UnderlyingType")));
  }
  type.setFlags(Boolean.parseBoolean(attr(element, "IsFlags")));

  readEnumMembers(reader, element, type);
  schema.getEnumTypes().add(type);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:14,代码来源:MetadataParser.java

示例15: getEnumType

import org.apache.olingo.commons.api.edm.provider.CsdlEnumType; //导入依赖的package包/类
@Override
public CsdlEnumType getEnumType(FullQualifiedName fqn) throws ODataException {
  CsdlSchema schema = getSchema(fqn.getNamespace());
  if (schema != null) {
    List<CsdlEnumType> types = schema.getEnumTypes();
    if (types != null) {
      for (CsdlEnumType type : types) {
        if (type.getName().equals(fqn.getName())) {
          return type;
        }
      }
    }
  }
  return null;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:16,代码来源:SchemaBasedEdmProvider.java


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