public Object getAnnotation(final Class<? extends AbstractTerm> term) { Object res = null; if (annotationsByTerm.containsKey(term)) { res = annotationsByTerm.get(term); } else { try { final Term termAnn = term.getAnnotation(Term.class); final Namespace namespaceAnn = term.getAnnotation(Namespace.class); ClientAnnotation annotation = null; for (ClientAnnotation _annotation : annotations) { if ((namespaceAnn.value() + "." + termAnn.name()).equals(_annotation.getTerm())) { annotation = _annotation; } } res = annotation == null || annotation.hasNullValue() ? null : CoreUtils.getObjectFromODataValue(annotation.getValue(), null, service); if (res != null) { annotationsByTerm.put(term, res); } } catch (Exception e) { throw new IllegalArgumentException("Error getting annotation for term '" + term.getName() + "'", e); } } return res; }
private void annotations(final ClientAnnotatable odataAnnotatable, final Annotatable annotatable) { for (ClientAnnotation odataAnnotation : odataAnnotatable.getAnnotations()) { final Annotation annotation = new Annotation(); annotation.setTerm(odataAnnotation.getTerm()); annotation.setType(odataAnnotation.getValue().getTypeName()); updateValuable(annotation, odataAnnotation); annotatable.getAnnotations().add(annotation); } }
public static Collection<Class<? extends AbstractTerm>> getAnnotationTerms( final AbstractService<?> service, final List<ClientAnnotation> annotations) { final List<Class<? extends AbstractTerm>> res = new ArrayList<Class<? extends AbstractTerm>>(); for (ClientAnnotation annotation : annotations) { final Class<? extends AbstractTerm> clazz = service.getTermClass(annotation.getTerm()); if (clazz != null) { res.add(clazz); } } return res; }
private void annotations(final ClientAnnotatable odataAnnotatable, final Annotatable annotatable) { for (ClientAnnotation odataAnnotation : odataAnnotatable.getAnnotations()) { final Annotation annotation = new Annotation(); annotation.setTerm(odataAnnotation.getTerm()); annotation.setType(odataAnnotation.getValue().getTypeName()); updateValuable(annotation, odataAnnotation); annotatable.getAnnotations().add(annotation); } }
public static Collection<Class<? extends AbstractTerm>> getAnnotationTerms( final AbstractService<?> service, final List<ClientAnnotation> annotations) { final List<Class<? extends AbstractTerm>> res = new ArrayList<Class<? extends AbstractTerm>>(); for (ClientAnnotation annotation : annotations) { final Class<? extends AbstractTerm> clazz = service.getTermClass(annotation.getTerm()); if (clazz != null) { res.add(clazz); } } return res; }
public Object getAnnotation(final Class<? extends AbstractTerm> term) { Object res = null; if (annotationsByTerm.containsKey(term)) { res = annotationsByTerm.get(term); } else { try { final Term termAnn = term.getAnnotation(Term.class); final Namespace namespaceAnn = term.getAnnotation(Namespace.class); ClientAnnotation annotation = null; for (ClientAnnotation _annotation : annotations) { if ((namespaceAnn.value() + "." + termAnn.name()).equals(_annotation.getTerm())) { annotation = _annotation; } } res = annotation == null || annotation.hasNullValue() ? null : CoreUtils.getObjectFromODataValue(annotation.getValue(), null, service); if (res != null) { annotationsByTerm.put(term, res); } } catch (Exception e) { throw new IllegalArgumentException("Error getting annotation for term '" + term.getName() + "'", e); } } return res; }
@Override public Object readAnnotation(final Class<? extends AbstractTerm> term) { Object res = null; if (annotations.containsKey(term)) { res = annotations.get(term); } else { try { final Term termAnn = term.getAnnotation(Term.class); final Namespace namespaceAnn = term.getAnnotation(Namespace.class); ClientAnnotation annotation = null; for (ClientAnnotation _annotation : internalAnnotations()) { if ((namespaceAnn.value() + "." + termAnn.name()).equals(_annotation.getTerm())) { annotation = _annotation; } } res = annotation == null || annotation.hasNullValue() ? null : CoreUtils.getObjectFromODataValue(annotation.getValue(), null, targetHandler.service); if (res != null) { annotations.put(term, res); } } catch (Exception e) { throw new IllegalArgumentException("Error getting annotation for term '" + term.getName() + "'", e); } } return res; }
@Override public Object readAnnotation(final Class<? extends AbstractTerm> term) { Object res = null; if (annotations.containsKey(term)) { res = annotations.get(term); } else { try { final Term termAnn = term.getAnnotation(Term.class); final Namespace namespaceAnn = term.getAnnotation(Namespace.class); ClientAnnotation annotation = null; for (ClientAnnotation _annotation : internalAnnotations()) { if ((namespaceAnn.value() + "." + termAnn.name()).equals(_annotation.getTerm())) { annotation = _annotation; } } res = annotation == null || annotation.hasNullValue() ? null : CoreUtils.getObjectFromODataValue(annotation.getValue(), null, targetHandler.service); if (res != null) { annotations.put(term, res); } } catch (Exception e) { throw new IllegalArgumentException("Error getting annotation for term '" + term.getName() + "'", e); } } return res; }
@Override public Object readAnnotation(final Class<? extends AbstractTerm> term) { Object res = null; if (annotations.containsKey(term)) { res = annotations.get(term); } else { try { final Term termAnn = term.getAnnotation(Term.class); final Namespace namespaceAnn = term.getAnnotation(Namespace.class); ClientAnnotation annotation = null; for (ClientAnnotation _annotation : getEntity().getAnnotations()) { if ((namespaceAnn.value() + "." + termAnn.name()).equals(_annotation.getTerm())) { annotation = _annotation; } } res = annotation == null || annotation.hasNullValue() ? null : CoreUtils.getObjectFromODataValue(annotation.getValue(), null, service); if (res != null) { annotations.put(term, res); } } catch (Exception e) { throw new IllegalArgumentException("Error getting annotation for term '" + term.getName() + "'", e); } } return res; }
@Override public Object readAnnotation(final Class<? extends AbstractTerm> term) { Object res = null; if (annotations.containsKey(term)) { res = annotations.get(term); } else { try { final Term termAnn = term.getAnnotation(Term.class); final Namespace namespaceAnn = term.getAnnotation(Namespace.class); ClientAnnotation annotation = null; for (ClientAnnotation _annotation : getEntity().getAnnotations()) { if ((namespaceAnn.value() + "." + termAnn.name()).equals(_annotation.getTerm())) { annotation = _annotation; } } res = annotation == null || annotation.hasNullValue() ? null : CoreUtils.getObjectFromODataValue(annotation.getValue(), null, service); if (res != null) { annotations.put(term, res); } } catch (Exception e) { throw new IllegalArgumentException("Error getting annotation for term '" + term.getName() + "'", e); } } return res; }