@Override public boolean equals (Object obj) { if (obj == null) { return false; } if (!(obj instanceof CsdlRecord)) { return false; } CsdlRecord csdlRecord = (CsdlRecord) obj; return (this.getType() == null ? csdlRecord.getType() == null : this.getType().equals(csdlRecord.getType())) && (this.getAnnotations() == null ? csdlRecord.getAnnotations() == null : checkAnnotations(csdlRecord.getAnnotations())) && (this.getPropertyValues() == null ? csdlRecord.getPropertyValues() == null : checkPropertyValues(csdlRecord.getPropertyValues())); }
@Override public List<EdmPropertyValue> getPropertyValues() { if (propertyValues == null) { List<EdmPropertyValue> localValues = new ArrayList<EdmPropertyValue>(); if (record.getPropertyValues() != null) { for (CsdlPropertyValue value : record.getPropertyValues()) { localValues.add(new EdmPropertyValueImpl(edm, value)); } } propertyValues = Collections.unmodifiableList(localValues); } return propertyValues; }
@Override public EdmStructuredType getType() { if (type == null && record.getType() != null) { // record MAY have a type information. final EdmTypeInfo typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(record.getType()).build(); if (typeInfo.isEntityType() || typeInfo.isComplexType()) { type = typeInfo.isEntityType() ? typeInfo.getEntityType() : typeInfo.getComplexType(); } else { throw new EdmException("Record expressions must specify a complex or entity type."); } } return type; }
write(target, new CsdlNull()); } else if ("Record".equals(name)) { CsdlRecord expr = new CsdlRecord(); expr.setType(attr(element, "Type")); readPropertyValues(reader, element, expr); write(target, expr);
private boolean checkAnnotations(List<CsdlAnnotation> csdlRecordAnnot) { if (csdlRecordAnnot == null) { return false; } if (this.getAnnotations().size() == csdlRecordAnnot.size()) { for (int i = 0; i < this.getAnnotations().size() ; i++) { if (!this.getAnnotations().get(i).equals(csdlRecordAnnot.get(i))) { return false; } } } else { return false; } return true; }
@Override public List<EdmPropertyValue> getPropertyValues() { if (propertyValues == null) { List<EdmPropertyValue> localValues = new ArrayList<EdmPropertyValue>(); if (record.getPropertyValues() != null) { for (CsdlPropertyValue value : record.getPropertyValues()) { localValues.add(new EdmPropertyValueImpl(edm, value)); } } propertyValues = Collections.unmodifiableList(localValues); } return propertyValues; }
@Override public EdmStructuredType getType() { if (type == null && record.getType() != null) { // record MAY have a type information. final EdmTypeInfo typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(record.getType()).build(); if (typeInfo.isEntityType() || typeInfo.isComplexType()) { type = typeInfo.isEntityType() ? typeInfo.getEntityType() : typeInfo.getComplexType(); } else { throw new EdmException("Record expressions must specify a complex or entity type."); } } return type; }
write(target, new CsdlNull()); } else if ("Record".equals(name)) { CsdlRecord expr = new CsdlRecord(); expr.setType(attr(element, "Type")); readPropertyValues(reader, element, expr); write(target, expr);
private boolean checkPropertyValues(List<CsdlPropertyValue> csdlRecordpropertyValues) { if (csdlRecordpropertyValues == null) { return false; } if (this.getPropertyValues().size() == csdlRecordpropertyValues.size()) { for (int i = 0; i < this.getPropertyValues().size(); i++) { if (!this.getPropertyValues().get(i).equals( csdlRecordpropertyValues.get(i))) { return false; } } } else { return false; } return true; }
@Override void build(XMLEventReader reader, StartElement element, CsdlRecord record, String name) throws XMLStreamException { if ("PropertyValue".equals(name)) { CsdlPropertyValue value = new CsdlPropertyValue(); value.setProperty(attr(element, "Property")); readAttributeExpressions(element, value); readExpressions(reader, element, value); record.getPropertyValues().add(value); } else if ("Annotation".equals(name)) { readAnnotations(reader, element, record); } } }.read(reader, element, record, "PropertyValue", "Annotation");
@Override void build(XMLEventReader reader, StartElement element, CsdlRecord record, String name) throws XMLStreamException { if ("PropertyValue".equals(name)) { CsdlPropertyValue value = new CsdlPropertyValue(); value.setProperty(attr(element, "Property")); readAttributeExpressions(element, value); readExpressions(reader, element, value); record.getPropertyValues().add(value); } else if ("Annotation".equals(name)) { readAnnotations(reader, element, record); } } }.read(reader, element, record, "PropertyValue", "Annotation");