diff --git a/src/api/java/AST.java b/src/api/java/AST.java index 43002c714..b57246356 100644 --- a/src/api/java/AST.java +++ b/src/api/java/AST.java @@ -53,15 +53,10 @@ public class AST extends Z3Object implements Comparable @Override public int compareTo(AST other) { - if (other == null) + if (other == null) { return 1; - - if (getId() < other.getId()) - return -1; - else if (getId() > other.getId()) - return +1; - else - return 0; + } + return Integer.compare(getId(), other.getId()); } /** @@ -94,11 +89,12 @@ public class AST extends Z3Object implements Comparable public AST translate(Context ctx) { - if (getContext() == ctx) + if (getContext() == ctx) { return this; - else + } else { return new AST(ctx, Native.translate(getContext().nCtx(), - getNativeObject(), ctx.nCtx())); + getNativeObject(), ctx.nCtx())); + } } /** diff --git a/src/api/java/Context.java b/src/api/java/Context.java index 40b597be4..29f353f07 100644 --- a/src/api/java/Context.java +++ b/src/api/java/Context.java @@ -110,8 +110,9 @@ public class Context extends IDisposable **/ public BoolSort getBoolSort() { - if (m_boolSort == null) + if (m_boolSort == null) { m_boolSort = new BoolSort(this); + } return m_boolSort; } @@ -120,8 +121,9 @@ public class Context extends IDisposable **/ public IntSort getIntSort() { - if (m_intSort == null) + if (m_intSort == null) { m_intSort = new IntSort(this); + } return m_intSort; } @@ -130,8 +132,9 @@ public class Context extends IDisposable **/ public RealSort getRealSort() { - if (m_realSort == null) + if (m_realSort == null) { m_realSort = new RealSort(this); + } return m_realSort; } @@ -148,8 +151,9 @@ public class Context extends IDisposable **/ public SeqSort getStringSort() { - if (m_stringSort == null) + if (m_stringSort == null) { m_stringSort = mkStringSort(); + } return m_stringSort; } diff --git a/src/api/java/Expr.java b/src/api/java/Expr.java index b59a41e1d..065ee5f32 100644 --- a/src/api/java/Expr.java +++ b/src/api/java/Expr.java @@ -53,14 +53,16 @@ public class Expr extends AST public Expr simplify(Params p) { - if (p == null) + if (p == null) { return Expr.create(getContext(), - Native.simplify(getContext().nCtx(), getNativeObject())); - else + Native.simplify(getContext().nCtx(), getNativeObject())); + } + else { return Expr.create( - getContext(), - Native.simplifyEx(getContext().nCtx(), getNativeObject(), - p.getNativeObject())); + getContext(), + Native.simplifyEx(getContext().nCtx(), getNativeObject(), + p.getNativeObject())); + } } /** @@ -106,9 +108,10 @@ public class Expr extends AST { int n = getNumArgs(); Expr[] res = new Expr[n]; - for (int i = 0; i < n; i++) + for (int i = 0; i < n; i++) { res[i] = Expr.create(getContext(), - Native.getAppArg(getContext().nCtx(), getNativeObject(), i)); + Native.getAppArg(getContext().nCtx(), getNativeObject(), i)); + } return res; } @@ -122,10 +125,11 @@ public class Expr extends AST public void update(Expr[] args) { getContext().checkContextMatch(args); - if (isApp() && args.length != getNumArgs()) + if (isApp() && args.length != getNumArgs()) { throw new Z3Exception("Number of arguments does not match"); + } setNativeObject(Native.updateTerm(getContext().nCtx(), getNativeObject(), - (int) args.length, Expr.arrayToNative(args))); + args.length, Expr.arrayToNative(args))); } /** @@ -144,10 +148,11 @@ public class Expr extends AST { getContext().checkContextMatch(from); getContext().checkContextMatch(to); - if (from.length != to.length) + if (from.length != to.length) { throw new Z3Exception("Argument sizes do not match"); + } return Expr.create(getContext(), Native.substitute(getContext().nCtx(), - getNativeObject(), (int) from.length, Expr.arrayToNative(from), + getNativeObject(), from.length, Expr.arrayToNative(from), Expr.arrayToNative(to))); } @@ -160,7 +165,6 @@ public class Expr extends AST **/ public Expr substitute(Expr from, Expr to) { - return substitute(new Expr[] { from }, new Expr[] { to }); } @@ -179,7 +183,7 @@ public class Expr extends AST getContext().checkContextMatch(to); return Expr.create(getContext(), Native.substituteVars(getContext().nCtx(), - getNativeObject(), (int) to.length, Expr.arrayToNative(to))); + getNativeObject(), to.length, Expr.arrayToNative(to))); } /** @@ -193,14 +197,14 @@ public class Expr extends AST **/ public Expr translate(Context ctx) { - - if (getContext() == ctx) + if (getContext() == ctx) { return this; - else + } else { return Expr.create( - ctx, - Native.translate(getContext().nCtx(), getNativeObject(), - ctx.nCtx())); + ctx, + Native.translate(getContext().nCtx(), getNativeObject(), + ctx.nCtx())); + } } /** @@ -2123,8 +2127,9 @@ public class Expr extends AST { if (!Native.isApp(getContext().nCtx(), obj) && Native.getAstKind(getContext().nCtx(), obj) != Z3_ast_kind.Z3_VAR_AST.toInt() && - Native.getAstKind(getContext().nCtx(), obj) != Z3_ast_kind.Z3_QUANTIFIER_AST.toInt()) + Native.getAstKind(getContext().nCtx(), obj) != Z3_ast_kind.Z3_QUANTIFIER_AST.toInt()) { throw new Z3Exception("Underlying object is not a term"); + } super.checkNativeObject(obj); } @@ -2188,10 +2193,10 @@ public class Expr extends AST return new FPRMExpr(ctx, obj); case Z3_FINITE_DOMAIN_SORT: return new FiniteDomainExpr(ctx, obj); - case Z3_SEQ_SORT: - return new SeqExpr(ctx, obj); - case Z3_RE_SORT: - return new ReExpr(ctx, obj); + case Z3_SEQ_SORT: + return new SeqExpr(ctx, obj); + case Z3_RE_SORT: + return new ReExpr(ctx, obj); default: ; } diff --git a/src/api/java/FiniteDomainNum.java b/src/api/java/FiniteDomainNum.java index 73613e4e0..e53ed22b2 100644 --- a/src/api/java/FiniteDomainNum.java +++ b/src/api/java/FiniteDomainNum.java @@ -36,8 +36,9 @@ public class FiniteDomainNum extends FiniteDomainExpr public int getInt() { Native.IntPtr res = new Native.IntPtr(); - if (Native.getNumeralInt(getContext().nCtx(), getNativeObject(), res) ^ true) + if (!Native.getNumeralInt(getContext().nCtx(), getNativeObject(), res)) { throw new Z3Exception("Numeral is not an int"); + } return res.value; } @@ -47,8 +48,9 @@ public class FiniteDomainNum extends FiniteDomainExpr public long getInt64() { Native.LongPtr res = new Native.LongPtr(); - if (Native.getNumeralInt64(getContext().nCtx(), getNativeObject(), res) ^ true) + if (!Native.getNumeralInt64(getContext().nCtx(), getNativeObject(), res)) { throw new Z3Exception("Numeral is not an int64"); + } return res.value; } diff --git a/src/api/java/Global.java b/src/api/java/Global.java index 67a051792..74106d8e9 100644 --- a/src/api/java/Global.java +++ b/src/api/java/Global.java @@ -57,10 +57,11 @@ public final class Global public static String getParameter(String id) { Native.StringPtr res = new Native.StringPtr(); - if (!Native.globalParamGet(id, res)) + if (!Native.globalParamGet(id, res)) { return null; - else + } else { return res.value; + } } /** diff --git a/src/api/java/Optimize.java b/src/api/java/Optimize.java index 9d62873e2..76c0d1204 100644 --- a/src/api/java/Optimize.java +++ b/src/api/java/Optimize.java @@ -183,11 +183,12 @@ public class Optimize extends Z3Object **/ public Model getModel() { - long x = Native.optimizeGetModel(getContext().nCtx(), getNativeObject()); - if (x == 0) - return null; - else - return new Model(getContext(), x); + long x = Native.optimizeGetModel(getContext().nCtx(), getNativeObject()); + if (x == 0) { + return null; + } else { + return new Model(getContext(), x); + } } /** diff --git a/src/api/java/Solver.java b/src/api/java/Solver.java index e58b140a6..425ccbbc6 100644 --- a/src/api/java/Solver.java +++ b/src/api/java/Solver.java @@ -201,13 +201,14 @@ public class Solver extends Z3Object public Status check(Expr... assumptions) { Z3_lbool r; - if (assumptions == null) + if (assumptions == null) { r = Z3_lbool.fromInt(Native.solverCheck(getContext().nCtx(), - getNativeObject())); - else + getNativeObject())); + } else { r = Z3_lbool.fromInt(Native.solverCheckAssumptions(getContext() - .nCtx(), getNativeObject(), (int) assumptions.length, AST - .arrayToNative(assumptions))); + .nCtx(), getNativeObject(), assumptions.length, AST + .arrayToNative(assumptions))); + } switch (r) { case Z3_L_TRUE: @@ -243,10 +244,11 @@ public class Solver extends Z3Object public Model getModel() { long x = Native.solverGetModel(getContext().nCtx(), getNativeObject()); - if (x == 0) + if (x == 0) { return null; - else + } else { return new Model(getContext(), x); + } } /** @@ -261,10 +263,11 @@ public class Solver extends Z3Object public Expr getProof() { long x = Native.solverGetProof(getContext().nCtx(), getNativeObject()); - if (x == 0) + if (x == 0) { return null; - else + } else { return Expr.create(getContext(), x); + } } /** diff --git a/src/api/java/Statistics.java b/src/api/java/Statistics.java index 051912468..5af0cf863 100644 --- a/src/api/java/Statistics.java +++ b/src/api/java/Statistics.java @@ -72,12 +72,13 @@ public class Statistics extends Z3Object **/ public String getValueString() { - if (isUInt()) + if (isUInt()) { return Integer.toString(m_int); - else if (isDouble()) + } else if (isDouble()) { return Double.toString(m_double); - else + } else { throw new Z3Exception("Unknown statistical entry type"); + } } /** @@ -150,14 +151,15 @@ public class Statistics extends Z3Object { Entry e; String k = Native.statsGetKey(getContext().nCtx(), getNativeObject(), i); - if (Native.statsIsUint(getContext().nCtx(), getNativeObject(), i)) + if (Native.statsIsUint(getContext().nCtx(), getNativeObject(), i)) { e = new Entry(k, Native.statsGetUintValue(getContext().nCtx(), - getNativeObject(), i)); - else if (Native.statsIsDouble(getContext().nCtx(), getNativeObject(), i)) + getNativeObject(), i)); + } else if (Native.statsIsDouble(getContext().nCtx(), getNativeObject(), i)) { e = new Entry(k, Native.statsGetDoubleValue(getContext().nCtx(), - getNativeObject(), i)); - else + getNativeObject(), i)); + } else { throw new Z3Exception("Unknown data entry value"); + } res[i] = e; } return res; @@ -186,9 +188,11 @@ public class Statistics extends Z3Object { int n = size(); Entry[] es = getEntries(); - for (int i = 0; i < n; i++) - if (es[i].Key == key) + for (int i = 0; i < n; i++) { + if (es[i].Key.equals(key)) { return es[i]; + } + } return null; }