@Override public boolean equals (Object obj) { if (obj == null) { return false; } if (!(obj instanceof CsdlAnnotation)) { return false; } CsdlAnnotation csdlAnnot = (CsdlAnnotation) obj; return (this.getTerm() == null ? csdlAnnot.getTerm() == null : this.getTerm().equals(csdlAnnot.getTerm())) && (this.getQualifier() == null ? csdlAnnot.getQualifier() == null : this.getQualifier().equals(csdlAnnot.getQualifier())) && (this.getExpression() == null ? csdlAnnot.getExpression() == null : this.getExpression().equals(csdlAnnot.getExpression())) && (this.getAnnotations() == null ? csdlAnnot.getAnnotations() == null : checkAnnotations(csdlAnnot.getAnnotations())); }
private static void addStringAnnotation(CsdlAnnotatable recipent, String term, String value) { CsdlAnnotation annotation = new CsdlAnnotation(); annotation.setTerm(term); annotation.setExpression(new CsdlConstantExpression(ConstantExpressionType.String, value)); recipent.getAnnotations().add(annotation); }
private boolean compareAnnotations(List<CsdlAnnotation> annotations, CsdlAnnotation annotation) { for (CsdlAnnotation annot : annotations) { if (annot.equals(annotation)) { return true; } } return false; } }
private boolean checkAnnotations(List<CsdlAnnotation> csdlAnnots) { if (csdlAnnots == null) { return false; } if (this.getAnnotations().size() == csdlAnnots.size()) { for (int i = 0; i < this.getAnnotations().size(); i++) { if (!this.getAnnotations().get(i).equals(csdlAnnots.get(i))) { return false; } } } else { return false; } return true; }
/** * Gets annotation. * * @param term the term * @return the annotation */ public CsdlAnnotation getAnnotation(final String term) { CsdlAnnotation result = null; for (CsdlAnnotation annot : getAnnotations()) { if (term.equals(annot.getTerm())) { result = annot; } } return result; }
private void extractAnnotations(List<CsdlAnnotation> edmAnnotations, AnnotatedElement element, String internalName) throws ODataJPAModelException { final EdmAnnotation jpaAnnotation = element.getAnnotation(EdmAnnotation.class); if (jpaAnnotation != null) { CsdlAnnotation edmAnnotation = new CsdlAnnotation(); edmAnnotation.setTerm(jpaAnnotation.term()); edmAnnotation.setQualifier(jpaAnnotation.qualifier()); if (!(jpaAnnotation.constantExpression().type() == ConstantExpressionType.Int && jpaAnnotation.constantExpression().value().equals("default")) && !(jpaAnnotation.dynamicExpression().path().isEmpty())) { throw new ODataJPAModelException( ODataJPAModelException.MessageKeys.ODATA_ANNOTATION_TWO_EXPRESSIONS, internalName); } else if (jpaAnnotation.constantExpression() != null) { edmAnnotation.setExpression(new CsdlConstantExpression(jpaAnnotation.constantExpression().type(), jpaAnnotation.constantExpression().value())); } edmAnnotations.add(edmAnnotation); } }
.filter(csdlAnnotation -> ETAG_ANNOTATION_TERM1.equals(csdlAnnotation.getTerm()) || ETAG_ANNOTATION_TERM2.equals(csdlAnnotation.getTerm())) .filter(csdlAnnotation -> { return (csdlAnnotation.getExpression() != null && csdlAnnotation.getExpression().asDynamic() != null && csdlAnnotation.getExpression().asDynamic().asCollection() != null) ? true : false; }).flatMap(csdlAnnotation -> { List<CsdlExpression> items = csdlAnnotation.getExpression().asDynamic().asCollection() .getItems(); if (items != null && !items.isEmpty())
@Override public EdmExpression getExpression() { if (expression == null && annotation.getExpression() != null) { expression = AbstractEdmExpression.getExpression(edm, annotation.getExpression()); } return expression; } }
private <T> void write(T t, CsdlExpression expr) throws XMLStreamException { if(t instanceof CsdlAnnotation) { ((CsdlAnnotation)t).setExpression(expr); } else if (t instanceof CsdlUrlRef) { ((CsdlUrlRef)t).setValue(expr); } else if (t instanceof CsdlCast) { ((CsdlCast)t).setValue(expr); } else if (t instanceof CsdlLabeledElement) { ((CsdlLabeledElement)t).setValue(expr); } else if (t instanceof CsdlIsOf) { ((CsdlIsOf)t).setValue(expr); } else if (t instanceof CsdlCollection) { ((CsdlCollection)t).getItems().add(((CsdlCollection)t).getItems().size(), expr); } else if (t instanceof CsdlApply) { ((CsdlApply)t).getParameters().add(expr); } else if (t instanceof CsdlIf) { if (((CsdlIf)t).getGuard() == null) { ((CsdlIf)t).setGuard(expr); } else if (((CsdlIf)t).getThen() == null) { ((CsdlIf)t).setThen(expr); } else { ((CsdlIf)t).setElse(expr); } } else if (t instanceof CsdlPropertyValue) { ((CsdlPropertyValue)t).setValue(expr); } else { throw new XMLStreamException("Unknown expression parent in Annoatation"); } }
@Override public String getQualifier() { return annotation.getQualifier(); }
/** * Gets annotation. * * @param term the term * @return the annotation */ public CsdlAnnotation getAnnotation(final String term) { CsdlAnnotation result = null; for (CsdlAnnotation annot : getAnnotations()) { if (term.equals(annot.getTerm())) { result = annot; } } return result; }
@Override public EdmExpression getExpression() { if (expression == null && annotation.getExpression() != null) { expression = AbstractEdmExpression.getExpression(edm, annotation.getExpression()); } return expression; } }
private <T> void write(T t, CsdlExpression expr) throws XMLStreamException { if(t instanceof CsdlAnnotation) { ((CsdlAnnotation)t).setExpression(expr); } else if (t instanceof CsdlUrlRef) { ((CsdlUrlRef)t).setValue(expr); } else if (t instanceof CsdlCast) { ((CsdlCast)t).setValue(expr); } else if (t instanceof CsdlLabeledElement) { ((CsdlLabeledElement)t).setValue(expr); } else if (t instanceof CsdlIsOf) { ((CsdlIsOf)t).setValue(expr); } else if (t instanceof CsdlCollection) { ((CsdlCollection)t).getItems().add(((CsdlCollection)t).getItems().size(), expr); } else if (t instanceof CsdlApply) { ((CsdlApply)t).getParameters().add(expr); } else if (t instanceof CsdlIf) { if (((CsdlIf)t).getGuard() == null) { ((CsdlIf)t).setGuard(expr); } else if (((CsdlIf)t).getThen() == null) { ((CsdlIf)t).setThen(expr); } else { ((CsdlIf)t).setElse(expr); } } else if (t instanceof CsdlPropertyValue) { ((CsdlPropertyValue)t).setValue(expr); } else { throw new XMLStreamException("Unknown expression parent in Annoatation"); } }
@Override public String getQualifier() { return annotation.getQualifier(); }
private static void addIntAnnotation(CsdlAnnotatable recipent, String term, int value) { CsdlAnnotation annotation = new CsdlAnnotation(); annotation.setTerm(term); annotation.setExpression(new CsdlConstantExpression(ConstantExpressionType.Int, String.valueOf(value))); recipent.getAnnotations().add(annotation); }
/** * Gets annotation. * * @param term the term * @return the annotation */ public CsdlAnnotation getAnnotation(final String term) { CsdlAnnotation result = null; for (CsdlAnnotation annotation : getAnnotations()) { if (term.equals(annotation.getTerm())) { result = annotation; } } return result; } }
private boolean compareAnnotations(List<CsdlAnnotation> annotations, CsdlAnnotation annotation) { for (CsdlAnnotation annot : annotations) { if (annot.equals(annotation)) { return true; } } return false; } }
private static void addBooleanAnnotation(CsdlAnnotatable recipent, String term, boolean value) { CsdlAnnotation annotation = new CsdlAnnotation(); annotation.setTerm(term); annotation.setExpression(new CsdlConstantExpression(ConstantExpressionType.Bool, String.valueOf(value))); recipent.getAnnotations().add(annotation); }
/** * Gets annotation. * * @param term the term * @return the annotation */ public CsdlAnnotation getAnnotation(final String term) { CsdlAnnotation result = null; for (CsdlAnnotation annotation : getAnnotations()) { if (term.equals(annotation.getTerm())) { result = annotation; } } return result; } }
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; }