本文整理汇总了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);
}
}
示例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;
}
示例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());
}
示例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());
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
示例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"));
}
}
示例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;
}
示例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);
}
示例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;
}