/** * Copy-constructor, creates a shallow copy of the provided expression. * * @param expr the expre */ public Expr(final Expr expr) { set(expr); }
break; case NOT: set(this.left); break; default:
dest.set(expr);
/** * Utility, combine this expression with another, using conjunction. * The expression will only match if both conditions are met. * * @param expr the other expression * @return self for chaining */ public Expr and(Expr expr) { if (type == Type.TRUE) { set(expr); } else if (expr.type != Type.TRUE) { if (type.isLogical() && !expr.type.isLogical()) { if (type == AND) right.and(expr); else setLogical(Type.AND, expr, new Expr(this)); } else { setLogical(Type.AND, new Expr(this), expr); } } return this; }
/** * Create a new query atom with the given an expression. * * <pre>{@code * // oxygen in a ring * Expr expr = new Expr(IS_IN_RING); * expr.and(new Expr(ELEMENT, 8)); * new QueryAtom(expr); * }</pre> * * @param expr the expr */ public QueryAtom(Expr expr) { this((IChemObjectBuilder) null); this.expr.set(expr); }
/** * Utility, combine this expression with another, using disjunction. * The expression will match if either conditions is met. * @param expr the other expression * @return self for chaining */ public Expr or(Expr expr) { if (type == Type.TRUE || type == Type.FALSE || type == NONE) { set(expr); } else if (expr.type != Type.TRUE && expr.type != Type.FALSE && expr.type != Type.NONE) { if (type.isLogical() && !expr.type.isLogical()) { if (type == OR) right.or(expr); else setLogical(Type.OR, expr, new Expr(this)); } else setLogical(Type.OR, new Expr(this), expr); } return this; }
/** * Constructs an query bond from an expression. * * <pre>{@code * // pi-bond in a ring * Expr e = new Expr(IS_IN_RING); * e.and(new Expr(ALIPHATIC_ORDER, 2)); * new QueryBond(beg, end, e); * }</pre> * * @param expr the expression */ public QueryBond(IAtom beg, IAtom end, Expr expr) { this(beg, end, null, IQueryBond.Stereo.NONE, beg.getBuilder()); this.expr.set(expr); atomCount = 2; }
dest.set(hExpr); return true; } else {
dest.set(expr);