Code cleanup

This commit is contained in:
serso 2016-01-30 22:28:58 +01:00
parent 51ced42d8e
commit 3797f26330
29 changed files with 51 additions and 73 deletions

View File

@ -23,19 +23,16 @@
package org.solovyev.android.calculator;
import android.app.Activity;
import jscl.NumeralBase;
import org.solovyev.android.calculator.units.CalculatorNumeralBase;
import org.solovyev.android.views.dragbutton.DirectionDragButton;
import org.solovyev.android.views.dragbutton.DragDirection;
import org.solovyev.android.calculator.units.CalculatorNumeralBase;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Nonnull;
import jscl.NumeralBase;
/**
* User: serso
* Date: 4/21/12
@ -95,7 +92,7 @@ public enum AndroidNumeralBase {
@Nonnull
private final CalculatorNumeralBase calculatorNumeralBase;
private AndroidNumeralBase(@Nonnull CalculatorNumeralBase calculatorNumeralBase) {
AndroidNumeralBase(@Nonnull CalculatorNumeralBase calculatorNumeralBase) {
this.calculatorNumeralBase = calculatorNumeralBase;
}

View File

@ -42,7 +42,7 @@ public interface CalculatorEventContainer {
void fireCalculatorEvents(@Nonnull List<CalculatorEvent> calculatorEvents);
public static class CalculatorEvent {
class CalculatorEvent {
@Nonnull
private CalculatorEventData calculatorEventData;

View File

@ -75,10 +75,7 @@ class CalculatorEventDataImpl implements CalculatorEventData {
if (this.sequenceId == NO_SEQUENCE) {
return false;
}
if (this.sequenceId == that.getSequenceId()) {
return true;
}
return false;
return this.sequenceId == that.getSequenceId();
}
@Override
@ -86,10 +83,7 @@ class CalculatorEventDataImpl implements CalculatorEventData {
if (this.sequenceId == NO_SEQUENCE) {
return false;
}
if (this.sequenceId > that.getSequenceId()) {
return true;
}
return false;
return this.sequenceId > that.getSequenceId();
}
@Override
@ -100,9 +94,8 @@ class CalculatorEventDataImpl implements CalculatorEventData {
CalculatorEventDataImpl that = (CalculatorEventDataImpl) o;
if (eventId != that.eventId) return false;
if (sequenceId != that.sequenceId) return false;
return sequenceId == that.sequenceId;
return true;
}
@Override

View File

@ -75,7 +75,7 @@ public enum CalculatorFragmentType {
private Class<? extends Fragment> fragmentClass;
private int defaultTitleResId;
private CalculatorFragmentType(@Nonnull Class<? extends Fragment> fragmentClass,
CalculatorFragmentType(@Nonnull Class<? extends Fragment> fragmentClass,
int defaultLayoutId,
int defaultTitleResId) {
this.fragmentClass = fragmentClass;

View File

@ -87,7 +87,7 @@ enum CalculatorMenu implements LabeledMenuItem<MenuItem> {
private final int captionResId;
private CalculatorMenu(int captionResId) {
CalculatorMenu(int captionResId) {
this.captionResId = captionResId;
}

View File

@ -36,11 +36,11 @@ import javax.annotation.Nullable;
public interface MathEntityBuilder<T extends MathEntity> extends JBuilder<T> {
@Nonnull
public MathEntityBuilder<T> setName(@Nonnull String name);
MathEntityBuilder<T> setName(@Nonnull String name);
@Nonnull
public MathEntityBuilder<T> setDescription(@Nullable String description);
MathEntityBuilder<T> setDescription(@Nullable String description);
@Nonnull
public MathEntityBuilder<T> setValue(@Nullable String value);
MathEntityBuilder<T> setValue(@Nullable String value);
}

View File

@ -407,7 +407,7 @@ public abstract class AbstractCalculatorPlotFragment extends CalculatorFragment
return super.onOptionsItemSelected(item) || fragmentMenu.onOptionsItemSelected(this.getActivity(), item);
}
private static enum PlotMenu implements IdentifiableMenuItem<MenuItem> {
private enum PlotMenu implements IdentifiableMenuItem<MenuItem> {
functions(R.id.menu_plot_functions) {
@Override
@ -425,7 +425,7 @@ public abstract class AbstractCalculatorPlotFragment extends CalculatorFragment
private final int itemId;
private PlotMenu(int itemId) {
PlotMenu(int itemId) {
this.itemId = itemId;
}

View File

@ -325,11 +325,7 @@ public class CalculatorPlotterImpl implements CalculatorPlotter {
maxArity = Math.max(maxArity, xyFunction.getArity());
}
if (maxArity > 1) {
plot3d = true;
} else {
plot3d = false;
}
plot3d = maxArity > 1;
if (functions.isEmpty()) {
// no functions => new plot => default boundaries

View File

@ -31,21 +31,21 @@ import javax.annotation.Nonnull;
public interface GraphView extends ZoomButtonsController.OnZoomListener, TouchHandler.TouchHandlerListener {
public void init(@Nonnull PlotViewDef plotViewDef);
void init(@Nonnull PlotViewDef plotViewDef);
@Nonnull
public List<PlotFunction> getPlotFunctions();
List<PlotFunction> getPlotFunctions();
public void setPlotFunctions(@Nonnull List<PlotFunction> plotFunctions);
void setPlotFunctions(@Nonnull List<PlotFunction> plotFunctions);
public void onDestroy();
void onDestroy();
public void onPause();
void onPause();
public void onResume();
void onResume();
@Nonnull
public Bitmap captureScreenshot();
Bitmap captureScreenshot();
void setXRange(float xMin, float xMax);

View File

@ -109,9 +109,8 @@ public final class PlotBoundaries implements Serializable {
if (Float.compare(that.xMax, xMax) != 0) return false;
if (Float.compare(that.xMin, xMin) != 0) return false;
if (Float.compare(that.yMax, yMax) != 0) return false;
if (Float.compare(that.yMin, yMin) != 0) return false;
return Float.compare(that.yMin, yMin) == 0;
return true;
}
@Override

View File

@ -124,9 +124,8 @@ public class PlotFunction {
PlotFunction that = (PlotFunction) o;
if (!xyFunction.equals(that.xyFunction)) return false;
return xyFunction.equals(that.xyFunction);
return true;
}
@Override

View File

@ -47,7 +47,7 @@ public enum PlotLineColor {
private final int color;
private PlotLineColor(int color) {
PlotLineColor(int color) {
this.color = color;
}

View File

@ -30,5 +30,5 @@ package org.solovyev.android.calculator.plot;
public enum PlotLineColorType {
monochrome,
color_map;
color_map
}

View File

@ -171,9 +171,8 @@ public class PlotLineDef {
if (lineColor != that.lineColor) return false;
if (Float.compare(that.lineWidth, lineWidth) != 0) return false;
if (lineColorType != that.lineColorType) return false;
if (lineStyle != that.lineStyle) return false;
return lineStyle == that.lineStyle;
return true;
}
@Override

View File

@ -33,6 +33,6 @@ public enum PlotLineStyle {
solid,
dashed,
dotted,
dash_dotted;
dash_dotted
}

View File

@ -104,7 +104,7 @@ class TouchHandler {
return velocityTracker.getYVelocity();
}
static interface TouchHandlerListener {
interface TouchHandlerListener {
void onTouchDown(float x, float y);
void onTouchMove(float x, float y);

View File

@ -22,14 +22,13 @@
package org.solovyev.android.calculator.plot;
import jscl.math.Generic;
import jscl.math.function.Constant;
import org.solovyev.common.text.Strings;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import jscl.math.Generic;
import jscl.math.function.Constant;
public class XyFunction implements FunctionEvaluator {
/*
@ -156,9 +155,8 @@ public class XyFunction implements FunctionEvaluator {
final XyFunction that = (XyFunction) o;
if (!id.equals(that.id)) return false;
return id.equals(that.id);
return true;
}
@Override

View File

@ -54,7 +54,7 @@ public enum CalculatorNumeralBase implements UnitType<String> {
@Nonnull
private final NumeralBase numeralBase;
private CalculatorNumeralBase(@Nonnull NumeralBase numeralBase) {
CalculatorNumeralBase(@Nonnull NumeralBase numeralBase) {
this.numeralBase = numeralBase;
}

View File

@ -132,9 +132,8 @@ public class CppVariable implements Jsonable, Parcelable {
CppVariable that = (CppVariable) o;
if (id != that.id) return false;
if (!name.equals(that.name)) return false;
return name.equals(that.name);
return true;
}
@Override

View File

@ -232,7 +232,7 @@ public class UnitConverterViewBuilder implements ViewBuilder<View> {
spinner.setAdapter(adapter);
}
public static interface CustomButtonOnClickListener {
public interface CustomButtonOnClickListener {
void onClick(@Nonnull Unit<String> fromUnits, @Nonnull Unit<String> toUnits);
}

View File

@ -131,7 +131,7 @@ public class DragButtonWizardStep extends WizardFragment {
}
}
private static enum DragButtonAction {
private enum DragButtonAction {
center(R.string.cpp_wizard_dragbutton_action_center, null),
up(R.string.cpp_wizard_dragbutton_action_up, DragDirection.up),
down(R.string.cpp_wizard_dragbutton_action_down, DragDirection.down),

View File

@ -33,7 +33,7 @@ import javax.annotation.Nonnull;
*/
public interface FragmentItem {
public void onSelected(@Nonnull FragmentTransaction ft);
void onSelected(@Nonnull FragmentTransaction ft);
public void onUnselected(@Nonnull FragmentTransaction ft);
void onUnselected(@Nonnull FragmentTransaction ft);
}

View File

@ -12,8 +12,8 @@ public interface Wizards {
Class<? extends Activity> getActivityClassName();
@Nonnull
public Wizard getWizard(@Nullable String name, @Nullable Bundle arguments) throws IllegalArgumentException;
Wizard getWizard(@Nullable String name, @Nullable Bundle arguments) throws IllegalArgumentException;
@Nonnull
public Wizard getWizard(@Nullable String name) throws IllegalArgumentException;
Wizard getWizard(@Nullable String name) throws IllegalArgumentException;
}

View File

@ -55,9 +55,8 @@ public abstract class AbstractJsclArithmeticException extends ArithmeticExceptio
AbstractJsclArithmeticException that = (AbstractJsclArithmeticException) o;
if (!message.equals(that.message)) return false;
return message.equals(that.message);
return true;
}
@Override

View File

@ -108,9 +108,8 @@ public class ExtendedConstant implements Comparable<ExtendedConstant>, IConstant
ExtendedConstant that = (ExtendedConstant) o;
if (!constant.equals(that.constant)) return false;
return constant.equals(that.constant);
return true;
}
@Override

View File

@ -196,7 +196,7 @@ public class Pow extends Algebraic {
}
public Generic selfNumeric() {
return ((NumericWrapper) parameters[0]).pow((NumericWrapper) parameters[1]);
return ((NumericWrapper) parameters[0]).pow(parameters[1]);
}
public String toString() {

View File

@ -144,7 +144,7 @@ final class TreePolynomial extends Polynomial {
Iterator it = content.entrySet().iterator();
while (it.hasNext()) {
Map.Entry e = (Map.Entry) it.next();
p.content.put(((Monomial) e.getKey()).multiply(monomial), (Generic) e.getValue());
p.content.put(((Monomial) e.getKey()).multiply(monomial), e.getValue());
}
p.degree = degree + monomial.degree();
p.sugar = sugar + monomial.degree();
@ -171,7 +171,7 @@ final class TreePolynomial extends Polynomial {
Iterator it = content.entrySet().iterator();
while (it.hasNext()) {
Map.Entry e = (Map.Entry) it.next();
p.content.put(((Monomial) e.getKey()).divide(monomial), (Generic) e.getValue());
p.content.put(((Monomial) e.getKey()).divide(monomial), e.getValue());
}
p.degree = degree + monomial.degree();
p.sugar = sugar + monomial.degree();

View File

@ -130,7 +130,7 @@ public class ParserUtils {
}
public static <T, U> T[] copyOf(U[] array, int newLength, Class<? extends T[]> newType) {
T[] copy = ((Object) newType == (Object) Object[].class)
T[] copy = (newType == Object[].class)
? (T[]) new Object[newLength]
: (T[]) Array.newInstance(newType.getComponentType(), newLength);

View File

@ -48,7 +48,7 @@ public abstract class AbstractExpressionGenerator<T> {
return Math.random() * MAX_VALUE;
}
protected static enum Operation {
protected enum Operation {
addition(0, "+"),
subtraction(1, "-"),
multiplication(2, "*"),
@ -79,7 +79,7 @@ public abstract class AbstractExpressionGenerator<T> {
}
}
protected static enum Function {
protected enum Function {
sin(0, "sin"),
cos(1, "cos"),
sqrt(2, ""),