/** * Constructor for when there is an associated {@link JClass}. * * @param jclass Java model class * @param annotationType annotation to scan for */ protected AnnotationScanner(JClass<T> jclass, Class<A> annotationType) { super(jclass.getType(), annotationType); this.jclass = jclass; }
SortKeyContainer(Permazen jdb, JClass<?> jclass) { this(jdb, jclass, jclass.getType()); }
public Node(JClass<?> jclass) { this(jclass.getType(), jclass); }
/** * Constructor. * * @param jdb underlying database * @param type type restrictions, or null for none */ public TypeContainer(Permazen jdb, Class<?> type) { super(Node.class); Preconditions.checkArgument(jdb != null, "null jdb"); this.jdb = jdb; // Get the types of all JClasses assignable to the given type, and use lowest common ancestor as the "top type" final HashSet<Class<?>> types = this.jdb.getJClasses().values().stream() .filter(jclass -> type == null || type.isAssignableFrom(jclass.getType())) .map(JClass::getType) .collect(Collectors.toCollection(HashSet::new)); this.rootType = !types.isEmpty() ? Util.findLowestCommonAncestorOfClasses(types).getRawType() : Object.class; }
/** * Constructor. * * <p> * Uses a default {@code objectMapper} that creates new exported objects using the default constructor of the model class. * * @param jtx the transaction from which to export objects * @throws IllegalArgumentException if {@code jtx} is null */ public ExportContext(JTransaction jtx) { Preconditions.checkArgument(jtx != null); this.jtx = jtx; this.objectMapper = id -> { final Class<?> type = this.jtx.jdb.getJClass(id).getType(); try { return type.newInstance(); } catch (Exception e) { throw new IllegalArgumentException("can't instatiate " + type + " using default constructor for POJO export", e); } }; }
@Override public Object get(ParseSession session) { return JTransaction.getCurrent().getAll(jclass.getType()); } };
/** * Create a new instance of the given type in this transaction. * * @param jclass object type * @param <T> Java model type * @return newly created instance * @throws IllegalArgumentException if {@code jclass} is not valid for this instance * @throws StaleTransactionException if this transaction is no longer usable */ public <T> T create(JClass<T> jclass) { final ObjId id = this.tx.create(jclass.storageId); return jclass.getType().cast(this.get(id)); }
@Override public Class<?> getType(ParseSession session) { try { return session.getPermazen().getJClass(id).getType(); } catch (TypeNotInSchemaVersionException e) { return UntypedJObject.class; } catch (IllegalArgumentException e) { return Object.class; } } };
private void newButtonClicked() { final JClass<?> jclass = this.objectChooser.getJClass(); if (jclass == null) { Notification.show("Can't create object having unknown type", "Please select an object type first", Notification.Type.WARNING_MESSAGE); return; } this.log.info("creating new object of type " + jclass.getType().getName()); new JObjectEditorWindow(this.getUI(), this.session, jclass).show(); }
final ArrayList<Class<?>> newPathTypes = ReferencePath.copyAndAppend(this.pathTypes, targetJClass.getType()); newCursors.add(new Cursor(newReferenceFields, newPathTypes, targetJClass, null, this.fieldNames, false));
String description = "field `" + fieldName + "' in " + jclass.getType(); if (matchingField == null || (explicitStorageId != 0 && matchingField.storageId != explicitStorageId)) { throw new IllegalArgumentException("there is no field named `" + searchName + "'" + (explicitStorageId != 0 ? " with storage ID " + explicitStorageId : "") + " in " + jclass.getType()); this.log.trace("RefPath.findField(): found field " + matchingField + " in " + jclass.getType());
final SchemaObjectType schemaType = ReferencePath.this.jdb.getNameIndex().getSchemaObjectType(typeName); if (schemaType != null) type = ReferencePath.this.jdb.getJClass(schemaType.getStorageId()).getType(); else { try {
.map(jclass -> new Cursor(jclass, jclass.getType(), fieldNames)) .forEach(remainingCursors::add); if (this.startType.isAssignableFrom(UntypedJObject.class))
@Override public Object get(ParseSession session) { if (session.getMode().hasPermazen()) { final Class<?> type = param instanceof ObjType ? session.getPermazen().getJClass(((ObjType)param).getStorageId()).getType() : param instanceof Node ? ((Node)param).evaluate(session).checkType(session, QueryVersionFunction.this.getName(), Class.class) : Object.class; return JTransaction.getCurrent().queryVersion(type); } else { CoreIndex<Integer, ObjId> index = session.getTransaction().queryVersion(); final int storageId = param instanceof Node ? ((Node)param).evaluate(session).checkType(session, QueryVersionFunction.this.getName(), Integer.class) : param instanceof ObjType ? ((ObjType)param).getStorageId() : -1; if (storageId != -1) index = index.filter(1, new KeyRanges(ObjId.getKeyRange(storageId))); return index.asMap(); } } };
throw new ParseException(ctx); ctx.setIndex(mark); param1 = new LiteralNode(session.getPermazen().getJClass(objType.getStorageId()).getType()); } catch (ParseException e) { ctx.setIndex(typeStart);