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


Java Type类代码示例

本文整理汇总了Java中javax.persistence.metamodel.Type的典型用法代码示例。如果您正苦于以下问题:Java Type类的具体用法?Java Type怎么用?Java Type使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: filter

import javax.persistence.metamodel.Type; //导入依赖的package包/类
public Attribute<?, ?> filter() {
    Type<?> type = forModel(metamodel).filter(rootType);
    Attribute<?, ?> result = null;
    for (int i = 1; i < pathElements.length; i++) {
        if (!(type instanceof ManagedType)) {
            throw new PersistenceException("Cannot navigate through simple property "
                    + pathElements[i] + " of type " + type.getJavaType());
        }
        result = ((ManagedType<?>)type).getAttribute(pathElements[i]);
        if (result.isCollection()) {
            type = ((PluralAttribute<?, ?, ?>)result).getElementType();
        } else {
            type = ((SingularAttribute<?, ?>)result).getType();
        }
    }
    return result;
}
 
开发者ID:ArneLimburg,项目名称:jpasecurity,代码行数:18,代码来源:TypeDefinition.java

示例2: toType

import javax.persistence.metamodel.Type; //导入依赖的package包/类
public static Type toType(Bindable bindable) {
	switch ( bindable.getBindableType() ) {
		case ENTITY_TYPE: {
			return (EntityType) bindable;
		}
		case SINGULAR_ATTRIBUTE: {
			return ( (SingularAttribute) bindable ).getType();
		}
		case PLURAL_ATTRIBUTE: {
			return ( (PluralAttribute) bindable ).getElementType();
		}
		default: {
			throw new ParsingException( "Unexpected Bindable type : " + bindable );
		}
	}
}
 
开发者ID:hibernate,项目名称:hibernate-semantic-query,代码行数:17,代码来源:Helper.java

示例3: getIdType

import javax.persistence.metamodel.Type; //导入依赖的package包/类
@Override
public Type<?> getIdType() {
	if ( getHierarchy().getIdentifierDescriptor() instanceof IdentifierDescriptorSingleAttribute ) {
		final SingularAttribute idAttribute = ( (IdentifierDescriptorSingleAttribute) getHierarchy().getIdentifierDescriptor() )
				.getIdAttribute();
		if ( idAttribute instanceof SingularAttributeBasic ) {
			return ( (SingularAttributeBasic) idAttribute ).getOrmType();
		}
		else if ( idAttribute instanceof SingularAttributeEmbedded ) {
			return ( (SingularAttributeEmbedded) idAttribute ).getEmbeddablePersister();
		}
		else {
			throw new IllegalStateException( "Expected BASIC or EMBEDDED attribute type for identifier" );
		}
	}
	return null;
}
 
开发者ID:hibernate,项目名称:hibernate-semantic-query,代码行数:18,代码来源:AbstractIdentifiableType.java

示例4: getElementType

import javax.persistence.metamodel.Type; //导入依赖的package包/类
@Override
public Type<java.lang.String> getElementType() {
  return new Type<java.lang.String>() {

    @Override
    public Class<java.lang.String> getJavaType() {
      return java.lang.String.class;
    }

    @Override
    public javax.persistence.metamodel.Type.PersistenceType getPersistenceType() {
      return null;
    }

  };
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:17,代码来源:JPAEdmPropertyTest.java

示例5: getSelectedPath

import javax.persistence.metamodel.Type; //导入依赖的package包/类
private Path getSelectedPath(int index, javax.persistence.criteria.Path<?> path) {
    if (path.getParentPath() != null) {
        Type<?> type = getType(path.getModel());
        if (type.getPersistenceType() == PersistenceType.BASIC
            || type.getPersistenceType() == PersistenceType.EMBEDDABLE) {
            return getSelectedPath(index, path.getParentPath());
        }
        return getSelectedPath(index, path.getParentPath()).append(getName(path.getModel()));
    }
    if (path.getAlias() == null) {
        path.alias("alias" + index);
    }
    return new Path(path.getAlias());
}
 
开发者ID:ArneLimburg,项目名称:jpasecurity,代码行数:15,代码来源:CriteriaEntityFilter.java

示例6: getSelectedType

import javax.persistence.metamodel.Type; //导入依赖的package包/类
private Class<?> getSelectedType(javax.persistence.criteria.Path<?> path) {
    Type<?> type = getType(path.getModel());
    if (type.getPersistenceType() == PersistenceType.BASIC
        || type.getPersistenceType() == PersistenceType.EMBEDDABLE) {
        return getSelectedType(path.getParentPath());
    } else {
        return type.getJavaType();
    }
}
 
开发者ID:ArneLimburg,项目名称:jpasecurity,代码行数:10,代码来源:CriteriaEntityFilter.java

示例7: getElementType

import javax.persistence.metamodel.Type; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static <R> Type<R> getElementType(Attribute<?, ?> attr) {
    if (attr instanceof SingularAttribute) {
        return ((SingularAttribute<?,R>) attr).getType();
    } else {
        return ((PluralAttribute<?,?,R>)attr).getElementType();
    }
}
 
开发者ID:solita,项目名称:query-utils,代码行数:9,代码来源:QueryUtils.java

示例8: getSubclasses

import javax.persistence.metamodel.Type; //导入依赖的package包/类
public static Set<Class> getSubclasses(Class<?> parent, EntityManager entityManager) {
    return entityManager.getMetamodel().getEntities().stream()
            .filter(entityType -> parent != entityType.getJavaType() && parent.isAssignableFrom(entityType.getJavaType()))
            .map(Type::getJavaType)
            .collect(Collectors.toCollection(HashSet::new));
}
 
开发者ID:encircled,项目名称:Joiner,代码行数:7,代码来源:ReflectionUtils.java

示例9: initialize

import javax.persistence.metamodel.Type; //导入依赖的package包/类
@Before
public void initialize() throws ParseException, NoSuchMethodException {
    Metamodel metamodel = mock(Metamodel.class);
    SecurePersistenceUnitUtil persistenceUnitUtil = mock(SecurePersistenceUnitUtil.class);
    accessManager = mock(DefaultAccessManager.class);
    SecurityContext securityContext = mock(SecurityContext.class);
    EntityType entityType = mock(EntityType.class);
    SingularAttribute idAttribute = mock(SingularAttribute.class);
    SingularAttribute nameAttribute = mock(SingularAttribute.class);
    SingularAttribute parentAttribute = mock(SingularAttribute.class);
    PluralAttribute childrenAttribute = mock(PluralAttribute.class);
    MapAttribute relatedAttribute = mock(MapAttribute.class);
    Type integerType = mock(Type.class);
    when(metamodel.getEntities()).thenReturn(Collections.<EntityType<?>>singleton(entityType));
    when(metamodel.managedType(MethodAccessTestBean.class)).thenReturn(entityType);
    when(metamodel.entity(MethodAccessTestBean.class)).thenReturn(entityType);
    when(accessManager.getContext()).thenReturn(securityContext);
    when(securityContext.getAliases()).thenReturn(Collections.singleton(CURRENT_PRINCIPAL));
    when(securityContext.getAliasValue(CURRENT_PRINCIPAL)).thenReturn(NAME);
    when(entityType.getName()).thenReturn(MethodAccessTestBean.class.getSimpleName());
    when(entityType.getJavaType()).thenReturn((Class)MethodAccessTestBean.class);
    when(entityType.getAttributes()).thenReturn(new HashSet(Arrays.asList(
            idAttribute, nameAttribute, parentAttribute, childrenAttribute, relatedAttribute)));
    when(entityType.getAttribute("id")).thenReturn(idAttribute);
    when(entityType.getAttribute("name")).thenReturn(nameAttribute);
    when(entityType.getAttribute("parent")).thenReturn(parentAttribute);
    when(entityType.getAttribute("children")).thenReturn(childrenAttribute);
    when(entityType.getAttribute("related")).thenReturn(relatedAttribute);
    when(idAttribute.getName()).thenReturn("id");
    when(idAttribute.isCollection()).thenReturn(false);
    when(idAttribute.getType()).thenReturn(integerType);
    when(idAttribute.getPersistentAttributeType()).thenReturn(PersistentAttributeType.BASIC);
    when(idAttribute.getJavaType()).thenReturn(Integer.TYPE);
    when(idAttribute.getJavaMember()).thenReturn(MethodAccessTestBean.class.getDeclaredMethod("getId"));
    when(nameAttribute.getName()).thenReturn("name");
    when(nameAttribute.isCollection()).thenReturn(false);
    when(nameAttribute.getType()).thenReturn(integerType);
    when(nameAttribute.getPersistentAttributeType()).thenReturn(PersistentAttributeType.BASIC);
    when(nameAttribute.getJavaType()).thenReturn(String.class);
    when(nameAttribute.getJavaMember()).thenReturn(MethodAccessTestBean.class.getDeclaredMethod("getName"));
    when(parentAttribute.getName()).thenReturn("parent");
    when(parentAttribute.isCollection()).thenReturn(false);
    when(parentAttribute.getType()).thenReturn(entityType);
    when(parentAttribute.getPersistentAttributeType()).thenReturn(PersistentAttributeType.MANY_TO_ONE);
    when(parentAttribute.getJavaType()).thenReturn(MethodAccessTestBean.class);
    when(parentAttribute.getJavaMember()).thenReturn(MethodAccessTestBean.class.getDeclaredMethod("getParent"));
    when(childrenAttribute.getName()).thenReturn("children");
    when(childrenAttribute.isCollection()).thenReturn(true);
    when(childrenAttribute.getElementType()).thenReturn(entityType);
    when(childrenAttribute.getJavaMember())
        .thenReturn(MethodAccessTestBean.class.getDeclaredMethod("getChildren"));
    when(relatedAttribute.getName()).thenReturn("related");
    when(relatedAttribute.isCollection()).thenReturn(true);
    when(relatedAttribute.getKeyJavaType()).thenReturn(MethodAccessTestBean.class);
    when(relatedAttribute.getBindableJavaType()).thenReturn(MethodAccessTestBean.class);
    when(relatedAttribute.getElementType()).thenReturn(entityType);
    when(relatedAttribute.getJavaMember())
        .thenReturn(MethodAccessTestBean.class.getDeclaredMethod("getRelated"));

    entityFilter = new EntityFilter(metamodel, persistenceUnitUtil, initializeAccessRules(metamodel));
    DefaultAccessManager.Instance.register(accessManager);
}
 
开发者ID:ArneLimburg,项目名称:jpasecurity,代码行数:63,代码来源:EntityFilterTest.java

示例10: getElementType

import javax.persistence.metamodel.Type; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Type<E> getElementType() {
	return getElementDescriptor();
}
 
开发者ID:hibernate,项目名称:hibernate-semantic-query,代码行数:6,代码来源:CollectionPersisterImpl.java

示例11: getType

import javax.persistence.metamodel.Type; //导入依赖的package包/类
@Override
public Type getType() {
	return getEmbeddablePersister();
}
 
开发者ID:hibernate,项目名称:hibernate-semantic-query,代码行数:5,代码来源:SingularAttributeEmbedded.java

示例12: getType

import javax.persistence.metamodel.Type; //导入依赖的package包/类
@Override
public Type getType() {
	return getOrmType();
}
 
开发者ID:hibernate,项目名称:hibernate-semantic-query,代码行数:5,代码来源:SingularAttributeBasic.java

示例13: getIdType

import javax.persistence.metamodel.Type; //导入依赖的package包/类
@Override
public Type<?> getIdType() {
  return null;
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:5,代码来源:JPAEntityTypeMock.java

示例14: getPersistenceType

import javax.persistence.metamodel.Type; //导入依赖的package包/类
@Override
public javax.persistence.metamodel.Type.PersistenceType getPersistenceType() {
  return null;
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:5,代码来源:JPAEntityTypeMock.java

示例15: getType

import javax.persistence.metamodel.Type; //导入依赖的package包/类
@Override
public Type<T> getType() {
  return null;
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:5,代码来源:JPASingularAttributeMock.java


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