public boolean isAnyResource() { return UID.class == getType(); }
public boolean isMap() { return Map.class.isAssignableFrom(getType()); }
public boolean isSortedSet() { return SortedSet.class.isAssignableFrom(getType()); }
public boolean isSet() { return Set.class.isAssignableFrom(getType()); }
public Class<?> getTargetType() { Class<?> clazz = getComponentType(); if (clazz == null) { clazz = getType(); } return clazz; }
public boolean isWildcard() { return isWildcard(mappedProperty.getType()); }
@SuppressWarnings("unchecked") @Nullable private Object convertSingleValue(MappedPath propertyPath, Set<? extends NODE> values) { MappedProperty<?> propertyDefinition = propertyPath.getMappedProperty(); Class targetType = propertyDefinition.getType(); if (!values.isEmpty()) { return convertValue(values.iterator().next(), targetType, propertyPath); } else { return null; } }
public boolean isList() { // refers to List RDF mapping, not the java.util.List type Container container = getAnnotation(Container.class); if (container != null) { return ContainerType.LIST == container.value(); } else { return List.class.isAssignableFrom(getType()) || type.isArray(); } }
@SuppressWarnings("unchecked") @Nullable public Class<? extends Collection> getCollectionType() { if (isCollection()) { return getConcreteCollectionType(getType()); } else { return null; } }
public void validate(MappedPath path) { if (isMixin()) { Member member = getMember(); if (getType().isAssignableFrom(member.getDeclaringClass())) { throw new IllegalArgumentException("Illegal mixin reference to oneself: " + toString()); } } }
private boolean isPolymorphic(MappedProperty<?> mappedProperty) { if (mappedProperty.isCollection() || mappedProperty.isMap()) { return configuration.isPolymorphic(mappedProperty.getComponentType()); } else { return configuration.isPolymorphic(mappedProperty.getType()); } }
MappedProperty<?> property = mappedPath.getMappedProperty(); if (!property.isList()) { Class<?> type = property.getType(); if (property.isCollection() || property.isMap()) { type = property.getComponentType();
/** * Create a new Query-by-example query * * @param session * @param entity */ @SuppressWarnings("unchecked") public ExampleQuery(Configuration configuration, Session session, T entity) { this.session = Assert.notNull(session, "session"); this.entityPath = (PathBuilder) pathBuilderFactory.create(entity.getClass()); this.conditions = new BooleanBuilder(); BeanMap beanMap = new BeanMap(entity); MappedClass mappedClass = configuration.getMappedClass(entity.getClass()); for (MappedPath mappedPath : mappedClass.getProperties()) { MappedProperty<?> property = mappedPath.getMappedProperty(); Object value = property.getValue(beanMap); if (value != null // date/time values are skipped && !DATE_TIME_TYPES.contains(value.getClass()) // collection values are skipped && !property.isCollection() // map values are skipped && !property.isMap() // blank nodes are skipped && !(value instanceof BID)) { Expression<Object> propertyPath = (Expression) entityPath.get(property.getName(), property.getType()); conditions.and(ExpressionUtils.eqConst(propertyPath, value)); } } }
if (mappedProperty.isMap()) { convertedValue = convertLocalizedMap(propertyPath, values); } else if (mappedProperty.getType().equals(String.class)) { convertedValue = convertLocalized(propertyPath, values); } else { throw new SessionException("Illegal use of @Localized with " + mappedProperty.getType() + " at " + propertyPath);
Object id = null; Identifier identifier; Class<?> type = idProperty.getType(); IDType idType = idProperty.getIDType(); if (idType == IDType.LOCAL) {
if (statements.containsKey(predicate)) { for (STMT statement : statements.get(predicate)) { if (property.isLocalized() && String.class.equals(property.getType())) { LIT lit = (LIT) statement.getObject(); if (Objects.equal(getCurrentLocale(), lit.getLang())) {
private void collectTypes() { for (MappedClass mappedClass : configuration.getMappedClasses()) { if (mappedClass.isEnum()) { // skip enum types continue; } EntityType entityType = (EntityType) createType(mappedClass.getJavaClass()); for (MappedPath mappedPath : mappedClass.getProperties()) { MappedProperty<?> mappedProperty = mappedPath.getMappedProperty(); Class<?> type = mappedPath.getMappedProperty().getType(); Type propertyType = null; if (type.equals(Map.class)) { propertyType = new SimpleType(Types.MAP, createType(mappedProperty.getKeyType()), createType(mappedProperty.getComponentType())); } else if (type.equals(List.class)) { propertyType = new SimpleType(Types.LIST, createType(mappedProperty.getComponentType())); } else if (type.equals(Set.class)) { propertyType = new SimpleType(Types.SET, createType(mappedProperty.getComponentType())); } else if (type.equals(Collection.class)) { propertyType = new SimpleType(Types.COLLECTION, createType(mappedProperty.getComponentType())); } else { propertyType = createType(type); } entityType.addProperty(createProperty(entityType, mappedPath.getName(), propertyType, mappedProperty.getAnnotations())); } } }
assertEquals(Parent.class, path.getMappedProperty().getType()); assertFalse(path.isInherited()); assertEquals(Object.class, path.getMappedProperty().getType()); assertFalse(path.getMappedProperty().isRequired()); assertFalse(path.isInherited()); assertEquals(FirstChild.class, path.getMappedProperty().getType()); assertFalse(path.isInherited()); assertEquals(Integer.class, path.getMappedProperty().getType()); assertFalse(path.getMappedProperty().isRequired()); assertFalse(path.isInherited()); assertEquals(NestedChild.class, path.getMappedProperty().getType()); assertFalse(path.isInherited()); assertEquals(String.class, path.getMappedProperty().getType()); assertTrue(path.getMappedProperty().isRequired()); assertTrue(path.isInherited()); assertEquals(SecondChild.class, path.getMappedProperty().getType()); assertFalse(path.isInherited()); assertEquals(String.class, path.getMappedProperty().getType()); assertTrue(path.getMappedProperty().isRequired()); assertFalse(path.isInherited()); assertEquals(Parent.class, path.getMappedProperty().getType());