@Test public void testGetPathDescriptor_BadPath() { EntityPathCache cache = new EntityPathCache(metadataService.getAgEntity(X.class)); assertThrows(AgException.class, () -> cache.getPathDescriptor(new ASTObjPath("y.xyz"))); }
PathDescriptor getPathDescriptor(final ASTObjPath path) { PathDescriptor entry = pathCache.get(path.getPath()); if (entry == null) { String stringPath = (String) path.getOperand(0); final Object last = lastPathComponent(entity, stringPath); if (last instanceof AgAttribute) { entry = new PathDescriptor() { AgAttribute attribute = (AgAttribute) last; @Override public boolean isAttribute() { return true; } @Override public Class<?> getType() { return attribute.getType(); } @Override public ASTPath getPathExp() { return path; } }; } else { entry = new PathDescriptor() { AgRelationship relationship = (AgRelationship) last; Class<?> type = relationship.getTargetEntity().getType(); @Override public boolean isAttribute() { return false; } @Override public Class<?> getType() { return type; } @Override public ASTPath getPathExp() { return path; } }; } pathCache.put(path.getPath(), entry); } return entry; }
EntityPathCache { PathDescriptor getPathDescriptor(final ASTObjPath path) { PathDescriptor entry = pathCache.get(path.getPath()); if (entry == null) { String stringPath = (String) path.getOperand(0); final Object last = lastPathComponent(entity, stringPath); if (last instanceof AgAttribute) { entry = new PathDescriptor() { AgAttribute attribute = (AgAttribute) last; @Override public boolean isAttribute() { return true; } @Override public Class<?> getType() { return attribute.getType(); } @Override public ASTPath getPathExp() { return path; } }; } else { entry = new PathDescriptor() { AgRelationship relationship = (AgRelationship) last; Class<?> type = relationship.getTargetEntity().getType(); @Override public boolean isAttribute() { return false; } @Override public Class<?> getType() { return type; } @Override public ASTPath getPathExp() { return path; } }; } pathCache.put(path.getPath(), entry); } return entry; } }
EntityPathCache { PathDescriptor getPathDescriptor(final ASTObjPath path) { PathDescriptor entry = pathCache.get(path.getPath()); if (entry == null) { String stringPath = (String) path.getOperand(0); final Object last = lastPathComponent(entity, stringPath); if (last instanceof AgAttribute) { entry = new PathDescriptor() { AgAttribute attribute = (AgAttribute) last; @Override public boolean isAttribute() { return true; } @Override public Class<?> getType() { return attribute.getType(); } @Override public ASTPath getPathExp() { return path; } }; } else { entry = new PathDescriptor() { AgRelationship relationship = (AgRelationship) last; Class<?> type = relationship.getTargetEntity().getType(); @Override public boolean isAttribute() { return false; } @Override public Class<?> getType() { return type; } @Override public ASTPath getPathExp() { return path; } }; } pathCache.put(path.getPath(), entry); } return entry; } EntityPathCache(final AgEntity<?> entity); }
EntityPathCache { PathDescriptor getPathDescriptor(final ASTObjPath path) { PathDescriptor entry = pathCache.get(path.getPath()); if (entry == null) { String stringPath = (String) path.getOperand(0); final Object last = lastPathComponent(entity, stringPath); if (last instanceof AgAttribute) { entry = new PathDescriptor() { AgAttribute attribute = (AgAttribute) last; @Override public boolean isAttribute() { return true; } @Override public Class<?> getType() { return attribute.getType(); } @Override public ASTPath getPathExp() { return path; } }; } else { entry = new PathDescriptor() { AgRelationship relationship = (AgRelationship) last; Class<?> type = relationship.getTargetEntity().getType(); @Override public boolean isAttribute() { return false; } @Override public Class<?> getType() { return type; } @Override public ASTPath getPathExp() { return path; } }; } pathCache.put(path.getPath(), entry); } return entry; } EntityPathCache(final AgEntity<?> entity);  }
EntityPathCache { PathDescriptor getPathDescriptor(final ASTObjPath path) { PathDescriptor entry = pathCache.get(path.getPath()); if (entry == null) { String stringPath = (String) path.getOperand(0); final Object last = lastPathComponent(entity, stringPath); if (last instanceof AgAttribute) { entry = new PathDescriptor() { AgAttribute attribute = (AgAttribute) last; @Override public boolean isAttribute() { return true; } @Override public Class<?> getType() { return attribute.getType(); } @Override public ASTPath getPathExp() { return path; } }; } else { entry = new PathDescriptor() { AgRelationship relationship = (AgRelationship) last; Class<?> type = relationship.getTargetEntity().getType(); @Override public boolean isAttribute() { return false; } @Override public Class<?> getType() { return type; } @Override public ASTPath getPathExp() { return path; } }; } pathCache.put(path.getPath(), entry); } return entry; } EntityPathCache(final AgEntity<?> entity);   }