protected boolean compatibleTypes(Type targetType, Type sourceType) { if (!sourceType.getName().equals(targetType.getName())) { return false; } if (sourceType.isComplexType()) { for (Field field : ((ComplexType) sourceType).getFields()) { Field targetField = ((ComplexType) targetType).getField(field.getName()); if (targetField == null || !field.getType().equals(targetField.getType())) { return false; } } } if (sourceType.isListType()) { if (!((ListType) sourceType).getFieldType().equals(((ListType) targetType).getFieldType())) { return false; } if (((ListType) sourceType).getFieldType().isComplexType()) { return compatibleTypes(((ListType) targetType).getFieldType(), ((ListType) sourceType).getFieldType()); } } return true; } }
protected Serializable convert(Collection<?> value) throws PropertyConversionException { Property typedProperty = getRoot().createProperty(null, getType().getField(), NONE); Collection<Object> col = new ArrayList<>(value.size()); for (Object v : value) { if (v == null) { col.add(null); } else { col.add(typedProperty.normalize(v)); } } return col.toArray((Object[]) Array.newInstance(typedProperty.newInstance().getClass(), col.size())); }
/** * TODO FIXME XXX uncommented <code>return true;</code> see NXP-1653. * * @see DefaultPropertyFactory line 216 * @see {@link ListProperty#getValue} * @see {@link ListProperty#accept} */ @Override public boolean isContainer() { // return true; // - this can be uncommented when scalar list will be // fixed return !getType().isScalarList(); }
protected Field resolveSubField(ListType listType, String subName, boolean fallbackOnSubElement) { Type itemType = listType.getFieldType(); if (itemType.isComplexType() && subName != null) { ComplexType complexType = (ComplexType) itemType; Field subField = complexType.getField(subName); return subField; } if (fallbackOnSubElement) { return listType.getField(); } return null; }
int index = Integer.parseInt(segments[i + 1]); i++; if (!type.isListType() || ((ListType) type).getFieldType().isSimpleType()) { throw new PropertyNotFoundException(xpath, "Cannot use index after segment: " + segment); field = ((ListType) type).getField(); if (i == segments.length - 1) { if (listType.isArray()) {
if (type.isListType()) { ListType ltype = (ListType) type; if (ltype.isScalarList() && !decodeStringListAsJSON) { p.setValue(readStringList(value, (SimpleType) ltype.getFieldType())); return; } else {
int index = Integer.parseInt(segments[i + 1]); i++; if (!type.isListType() || ((ListType) type).getFieldType().isSimpleType()) { throw new PropertyNotFoundException(xpath, "Cannot use index after segment: " + segment); parentType = (ComplexType) ((ListType) type).getFieldType(); if (i == segments.length - 1) { if (listType.isArray()) {
ListType listType = (ListType) complexProperty.getField().getType(); if (!listType.getFieldType().isComplexType() && !listType.isListType()) { throw new OperationException("Property type is not supported by this operation"); ListType listType = (ListType) complexProperty.getField().getType(); if (!listType.getFieldType().isComplexType() && !listType.isListType()) { throw new OperationException("Property type is not supported by this operation");
return new MapProperty(parent, field, flags); } else if (type.isListType()) { if (((ListType) type).isArray()) { return new ArrayProperty(parent, field, flags); } else {
} else if (fieldType.isListType()) { ListType listType = (ListType) fieldType; if (!listType.getFieldType().isSimpleType()) { break; field = listType.getField(); parts.add("*"); } else {
ListType listType = ((ListType) type); if (listType.isScalarList()) { typeId = SCALAR_LIST_TYPE_ID; else if (TypeConstants.isContentType(listType.getFieldType())) { typeId = CONTENT_LIST_TYPE_ID;
Schema array = Schema.createArray(context.createSchema(((ListType) input).getFieldType())); String logicalType = ((ListType) input).isArray() ? "array" : "list"; new LogicalType(logicalType).addToSchema(array); return array;
if (input.getType().isListType()) { Collection<Object> objects; if (((ListType) input.getType()).isArray()) { objects = Arrays.asList((Object[]) input.getValue()); } else {
/** * This method should be the only one to create {@link ConstraintViolation}. * * @since 7.1 */ private List<ConstraintViolation> validateSimpleTypeField(Schema schema, List<PathNode> path, Field field, Object value) { Type type = field.getType(); assert type.isSimpleType() || type.isListType(); // list type to manage ArrayProperty List<ConstraintViolation> violations = new ArrayList<>(); Set<Constraint> constraints; if (type.isListType()) { // ArrayProperty constraints = ((ListType) type).getFieldType().getConstraints(); } else { constraints = field.getConstraints(); } for (Constraint constraint : constraints) { if (!constraint.validate(value)) { ConstraintViolation violation = new ConstraintViolation(schema, path, constraint, value); violations.add(violation); } } return violations; }
Type fieldType = listType.getFieldType(); if (fieldType.isSimpleType()) { updateList(state, name, listType.getField(), xpath, values);
@Override public Property addEmpty() { Field lfield = getType().getField(); Property property = getRoot().createProperty(this, lfield, 0); children.add(property); return property; }
continue; // not binary text } else if (type.isListType()) { Type fieldType = ((ListType) type).getFieldType(); if (fieldType.isComplexType()) { findBlobPaths((ComplexType) fieldType, fieldPath + "/*", schema, paths);
if (type.isListType()) { ListType lt = (ListType) type; if (lt.getFieldType().isComplexType()) { if (lt.getFieldType().getName().equals("content")) { jg.writeStringField(field.getName().getLocalName(), "blob[]"); buildComplexFields(jg, lt.getField()); jg.writeStringField("type", "complex[]"); jg.writeEndObject(); Type fieldType = lt.getFieldType(); if (fieldType instanceof SimpleType) { SimpleType stype = (SimpleType) fieldType;
@Override public Property addValue(int index, Object value) throws PropertyException { Field lfield = getType().getField(); Property property = getRoot().createProperty(this, lfield, IS_NEW); property.setValue(value); children.add(index, property); return property; }
/** * Returns the MongoDB field for this reference. */ public FieldInfo walkReference(Reference ref) { FieldInfo fieldInfo = walkReference(ref.name); if (DATE_CAST.equals(ref.cast)) { Type type = fieldInfo.type; if (!(type instanceof DateType || (type instanceof ListType && ((ListType) type).getFieldType() instanceof DateType))) { throw new QueryParseException("Cannot cast to " + ref.cast + ": " + ref.name); } // fieldInfo.isDateCast = true; } return fieldInfo; }