diff --git a/admin/admin-api/src/main/java/org/marketcetera/admin/AdminClient.java b/admin/admin-api/src/main/java/org/marketcetera/admin/AdminClient.java index d2690d7501..66bd111f1c 100644 --- a/admin/admin-api/src/main/java/org/marketcetera/admin/AdminClient.java +++ b/admin/admin-api/src/main/java/org/marketcetera/admin/AdminClient.java @@ -107,6 +107,7 @@ void updateFixSession(String inIncomingName, * * @param inNewUser a User value * @param inPassword a String value + * @return a User value */ User createUser(User inNewUser, String inPassword); diff --git a/client/src/test/java/org/marketcetera/client/ClientTest.java b/client/src/test/java/org/marketcetera/client/ClientTest.java index 8ea0eb52e5..3e5b789f1d 100644 --- a/client/src/test/java/org/marketcetera/client/ClientTest.java +++ b/client/src/test/java/org/marketcetera/client/ClientTest.java @@ -8,7 +8,6 @@ import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.marketcetera.trade.TypesTestBase.assertCancelRejectEquals; import static org.marketcetera.trade.TypesTestBase.assertExecReportEquals; @@ -31,6 +30,7 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.atomic.AtomicLong; +import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.After; import org.junit.AfterClass; @@ -437,7 +437,7 @@ protected void run() throws Exception { Map, BigDecimal> positions = getClient(). getOptionPositionsAsOf(date, "XYZ", "PQR"); assertEquals(2, positions.size()); - assertThat(positions, allOf(hasEntry( + MatcherAssert.assertThat(positions, allOf(hasEntry( PositionKeyFactory.createOptionKey("XYZ", option.getExpiry(), option.getStrikePrice(), option.getType(), "acc", "tra"), @@ -452,7 +452,7 @@ protected void run() throws Exception { //getAllOptionPositionsAsOf() positions = getClient().getAllOptionPositionsAsOf(date); assertEquals(1, positions.size()); - assertThat(positions, Matchers.hasEntry( + MatcherAssert.assertThat(positions, Matchers.hasEntry( PositionKeyFactory.createOptionKey("OPT", option.getExpiry(), option.getStrikePrice(), option.getType(), "acc", "tra"), @@ -486,7 +486,7 @@ protected void run() throws Exception { roots = getClient().getOptionRoots(symbol); assertEquals(symbol.length(), roots.size()); - assertThat(roots, Matchers.hasItem(symbol)); + MatcherAssert.assertThat(roots, Matchers.hasItem(symbol)); //verify caching sServer.getServiceImpl().resetServiceInvoked(); assertSame(roots, getClient().getOptionRoots(symbol)); @@ -1104,7 +1104,7 @@ protected void run() throws Exception { } /** - * Verifies the interplay between client initialization, reconnect & close. + * Verifies the interplay between client initialization, reconnect & close. * * @throws Exception if there were errors */ diff --git a/client/src/test/java/org/marketcetera/client/MockClient.java b/client/src/test/java/org/marketcetera/client/MockClient.java index bb1470a297..3c8f2efa9f 100644 --- a/client/src/test/java/org/marketcetera/client/MockClient.java +++ b/client/src/test/java/org/marketcetera/client/MockClient.java @@ -536,7 +536,7 @@ public void setSendOrderSingleException(ConnectionException inException) /** * Sets the sendOrderReplaceConnectionException value. * - * @param a ConnectionException value + * @param inSendOrderReplaceConnectionException a ConnectionException value */ public void setSendOrderReplaceConnectionException(ConnectionException inSendOrderReplaceConnectionException) { @@ -545,7 +545,7 @@ public void setSendOrderReplaceConnectionException(ConnectionException inSendOrd /** * Sets the sendOrderCancelConnectionException value. * - * @param a ConnectionException value + * @param inSendOrderCancelConnectionException a ConnectionException value */ public void setSendOrderCancelConnectionException(ConnectionException inSendOrderCancelConnectionException) { @@ -554,7 +554,7 @@ public void setSendOrderCancelConnectionException(ConnectionException inSendOrde /** * Sets the sendOrderSingleValidationException value. * - * @param an OrderValidationException value + * @param inSendOrderSingleValidationException an OrderValidationException value */ public void setSendOrderSingleValidationException(OrderValidationException inSendOrderSingleValidationException) { @@ -563,7 +563,7 @@ public void setSendOrderSingleValidationException(OrderValidationException inSen /** * Sets the sendOrderReplaceValidationException value. * - * @param an OrderValidationException value + * @param inSendOrderReplaceValidationException an OrderValidationException value */ public void setSendOrderReplaceValidationException(OrderValidationException inSendOrderReplaceValidationException) { @@ -572,7 +572,7 @@ public void setSendOrderReplaceValidationException(OrderValidationException inSe /** * Sets the sendOrderCancelValidationException value. * - * @param an OrderValidationException value + * @param inSendOrderCancelValidationException an OrderValidationException value */ public void setSendOrderCancelValidationException(OrderValidationException inSendOrderCancelValidationException) { diff --git a/client/src/test/java/org/marketcetera/client/MockServer.java b/client/src/test/java/org/marketcetera/client/MockServer.java index d10c8d3c90..c858b8718c 100644 --- a/client/src/test/java/org/marketcetera/client/MockServer.java +++ b/client/src/test/java/org/marketcetera/client/MockServer.java @@ -237,7 +237,7 @@ message, new BrokerID("default"), /** * The URL for the broker hosted by this server. - * Do note that this URL is changed, the mock_server.xml & broker.xml + * Do note that this URL is changed, the mock_server.xml & broker.xml * files need to be updated as well. */ public static final String URL = "tcp://localhost:61616"; diff --git a/cluster/cluster-api/src/main/java/org/marketcetera/cluster/service/ClusterService.java b/cluster/cluster-api/src/main/java/org/marketcetera/cluster/service/ClusterService.java index 23dc7908f3..500d598a8b 100644 --- a/cluster/cluster-api/src/main/java/org/marketcetera/cluster/service/ClusterService.java +++ b/cluster/cluster-api/src/main/java/org/marketcetera/cluster/service/ClusterService.java @@ -25,6 +25,7 @@ public interface ClusterService /** * Adds the given object to the given cluster queue. * + * @param the type of object * @param inQueueDescriptor a QueueDescriptor<Class> value * @param inObject a Clazz value */ @@ -33,6 +34,7 @@ void addToQueue(QueueDescriptor inQueueDescr /** * Peeks the top value in the given queue. * + * @param the type of object held by the queue * @param inQueueDescriptor a QueueDescriptor<Class> value * @return a Clazz value or null */ @@ -42,6 +44,8 @@ void addToQueue(QueueDescriptor inQueueDescr * *

This call will block until a value becomes available. * + * @param the type of object held by the queue + * @param inQueueDescriptor a QueueDescriptor<Class> value * @return a QueueDescriptor<Class> value * @throws InterruptedException if this call is interrupted */ @@ -56,6 +60,7 @@ Clazz takeFromQueue(QueueDescriptor inQueueD /** * Asynchronously executes the given task on members of the cluster as determined by the task. * + * @param the type of object returned by the task * @param inTask a CallableClusterTask<Clazz> value * @return an Map<Object,Future<Clazz> value containing the result tokens by cluster member * @throws Exception if an error occurs executing the task diff --git a/cluster/cluster-core/src/main/java/org/marketcetera/cluster/service/AbstractClusterService.java b/cluster/cluster-core/src/main/java/org/marketcetera/cluster/service/AbstractClusterService.java index ba110c67e9..6716816f54 100644 --- a/cluster/cluster-core/src/main/java/org/marketcetera/cluster/service/AbstractClusterService.java +++ b/cluster/cluster-core/src/main/java/org/marketcetera/cluster/service/AbstractClusterService.java @@ -547,10 +547,10 @@ protected ClusterWorkUnitDescriptor generateWorkUnitDescriptor(ClusterWorkUnitSp * Returns a candidate that suits the given work unit spec if one exists. * * @param inWorkUnitSpec a ClusterWorkUnitSpec value - * @return an Object value - * @throws InvocationTargetException - * @throws IllegalArgumentException - * @throws IllegalAccessException + * @return an Object value or null + * @throws InvocationTargetException if the candidate cannot be instantiated + * @throws IllegalArgumentException if an error occurs finding the candidate + * @throws IllegalAccessException if the candidate cannot be instatiated */ protected Object findCandidateFor(ClusterWorkUnitSpec inWorkUnitSpec) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException @@ -590,10 +590,10 @@ protected void activateWorkUnit(Object inCandidate) * Finds a candidate bean for the given work unit spec and activates it. * * @param inWorkUnitSpec a ClusterWorkUnitSpec value - * @return an Objectvalue - * @throws InvocationTargetException - * @throws IllegalArgumentException - * @throws IllegalAccessException + * @return an Objectvalue or null + * @throws InvocationTargetException if the work unit cannot be activated + * @throws IllegalArgumentException if an error occurs finding the work unit + * @throws IllegalAccessException if the work unit cannot be activated */ protected Object findAndActivateWorkUnit(ClusterWorkUnitSpec inWorkUnitSpec) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException @@ -723,6 +723,8 @@ protected Map findAllBeansWith(Class inAnno /** * Gets the annotation of the given type from the given argument. * + * @param the class of the given object + * @param the type of the given annotation * @param inInstance an Object value * @param inAnnotation a Class<AnnotationClazz> value * @return an AnnotationClazz value @@ -859,6 +861,7 @@ protected void logClusterMetaData() /** * Marshals the given value as XML. * + * @param the type of the provided data * @param inData a Clazz value * @return a String value * @throws JAXBException if the given object cannot be marshaled diff --git a/core/src/main/java/org/marketcetera/core/ApplicationBase.java b/core/src/main/java/org/marketcetera/core/ApplicationBase.java index a5dd8af7d7..d2ccda03ac 100644 --- a/core/src/main/java/org/marketcetera/core/ApplicationBase.java +++ b/core/src/main/java/org/marketcetera/core/ApplicationBase.java @@ -132,8 +132,11 @@ public void stopWaitingForever() public boolean isWaitingForever() { return waitingForever; } - - /** Get the FIX version associated with this application */ + /** + * Get the FIX version associated with this application. + * + * @return a FIXVersion value + */ public FIXVersion getFIXVersion() { return fixVersion; @@ -153,8 +156,11 @@ public long getApproximateTime() { // TODO: make this read a variable that is updated periodically by a thread return System.currentTimeMillis(); //i18n_datetime } - - /** Returns a pointer to the Spring application context that started this app */ + /** + * Returns a pointer to the Spring application context that started this app. + * + * @return a ClassPathXmlApplicationContext value + */ public ClassPathXmlApplicationContext getAppCtx() { return appCtx; } diff --git a/core/src/main/java/org/marketcetera/core/BigDecimalUtil.java b/core/src/main/java/org/marketcetera/core/BigDecimalUtil.java index af3522c435..3b57eeaf01 100644 --- a/core/src/main/java/org/marketcetera/core/BigDecimalUtil.java +++ b/core/src/main/java/org/marketcetera/core/BigDecimalUtil.java @@ -40,22 +40,32 @@ * */ public final class BigDecimalUtil { + /** + * constant used to round float values up + */ private static final double ROUNDING_UP_FLOAT = 0.5d; + /** + * maximum scale value for inverting + */ private static final int MAX_SCALE_FOR_INVERSE = 20; + /** + * number format instance + */ private static final NumberFormat NUMBER_FORMAT = NumberFormat.getInstance(); - + /** + * Create a new BigDecimalUtil instance. + */ private BigDecimalUtil() { } - /** * Convenience method to create a BigDecimal with a String, can be statically imported. + * * @param val a string representing the BigDecimal * @return the new BigDecimal */ public static BigDecimal bd(final String val) { return new BigDecimal(val); } - /** * Return the inverse of value if not null or zero, using scale. * @param value the nullable BigDecimal @@ -68,7 +78,6 @@ public static BigDecimal inverse(final BigDecimal value, final int scale) { } return null; } - /** * Return the inverse of value if no tnull of zero * @param value the nullable BigDecimal @@ -80,48 +89,54 @@ public static BigDecimal inverse(final BigDecimal value) { } return null; } - /** - * @param value the nullable BigDecimal - * @return true if value !=null and <gt; 0. + * Indicate if the given value is not zero. + * + * @param value the nullable BigDecimal + * @return true if value !=null and <gt; 0. */ public static boolean isNotZero(final BigDecimal value) { return value != null && value.signum() != 0; } - /** + * Indicate if the given value is zero. + * * @param value the nullable BigDecimal * @return true if value !=null and 0. */ public static boolean isZero(final BigDecimal value) { return value != null && value.signum() == 0; } - /** - * @param value the nullable BigDecimal - * @return true if value !=null and < 0. + * Indicate if the given value is negative. + * + * @param value the nullable BigDecimal + * @return true if value !=null and < 0. */ public static boolean isNegative(final BigDecimal value) { return value != null && value.signum() == -1; } - /** - * @param value the nullable BigDecimal - * @return true if value !=null and >0. + * Indicate if the given value is strictly positive. + * + * @param value the nullable BigDecimal + * @return true if value !=null and >0. */ public static boolean isStrictlyPositive(final BigDecimal value) { return value != null && value.signum() == 1; } - /** - * @param value the nullable BigDecimal - * @return true if value ==null OR 0. + * Indicate if the given value is null or zero. + * + * @param value the nullable BigDecimal + * @return true if value == null OR 0. */ public static boolean isNullOrZero(final BigDecimal value) { return value == null || value.signum() == 0; } - /** + * Indicate the two given values are the same value. + * * @param val1 the nullable BigDecimal * @param val2 the nullable BigDecimal * @return true if val1 == val2 (ignoring scale and null are treated as 0) @@ -129,8 +144,9 @@ public static boolean isNullOrZero(final BigDecimal value) { public static boolean isSameValue(final BigDecimal val1, final BigDecimal val2) { return val1 == null && val2 == null || val1 != null && val2 != null && val1.compareTo(val2) == 0; } - /** + * Indicate if the two values are the same value, treating null values as zero. + * * @param val1 the nullable BigDecimal * @param val2 the nullable BigDecimal * @return true if val1 == val2 (ignoring scale and null are treated as 0) @@ -138,9 +154,9 @@ public static boolean isSameValue(final BigDecimal val1, final BigDecimal val2) public static boolean isSameValueTreatNullAsZero(final BigDecimal val1, final BigDecimal val2) { return val1 == null && val2 == null || signum(val1) == 0 && signum(val2) == 0 || val1 != null && val2 != null && val1.compareTo(val2) == 0; } - /** - * Add 2 BigDecimal safely (i.e. handles nulls as zeros) + * Add 2 BigDecimal safely (i.e. handles nulls as zeros). + * * @param v1 the nullable BigDecimal * @param v2 the nullable BigDecimal * @return the sum of the 2 BigDecimal @@ -154,9 +170,9 @@ private static BigDecimal doAdd(final BigDecimal v1, final BigDecimal v2) { } return total; } - /** - * Add n BigDecimal safely (i.e. handles nulls) + * Add n BigDecimal safely (i.e. handles nulls). + * * @param start initial BigDecimal * @param values series of BigDecimals can be null/empty * @return the sum of the n non null BigDecimals @@ -170,9 +186,9 @@ public static BigDecimal add(final BigDecimal start, final BigDecimal... values) } return total; } - /** * Subtract n BigDecimal safely from the start value (i.e. handles nulls as zeros), returns 0 + * * @param start starting point, if null, use 0 * @param values series of BigDecimal to subtract from start, can be null / empty * @return start - the series of values @@ -186,9 +202,12 @@ public static BigDecimal subtract(final BigDecimal start, final BigDecimal... va } return total; } - /** - * Subtract 2 BigDecimal safely (i.e. handles nulls) v1 - v2 + * Subtract 2 BigDecimal safely (i.e. handles nulls) v1 - v2. + * + * @param v1 a BigDecimal value or null + * @param v2 a BigDecimal value or null + * @return a BigDecimal value */ private static BigDecimal doSubtract(final BigDecimal v1, final BigDecimal v2) { BigDecimal diff = v1; @@ -199,8 +218,12 @@ private static BigDecimal doSubtract(final BigDecimal v1, final BigDecimal v2) { } return diff; } - /** + * Divide the given numerator by the given denominator with the given rounding mode. + * + * @param numerator a BigDecimal value + * @param denominator a BigDecimal value + * @param rounding an int value * @return numerator / denominator if they are not null and the denominator is not zero, it returns null otherwise. */ public static BigDecimal divide(final BigDecimal numerator, final BigDecimal denominator, final int rounding) { @@ -210,13 +233,24 @@ public static BigDecimal divide(final BigDecimal numerator, final BigDecimal den } return diff; } - + /** + * Calculate the weighted average value from the given value and total. + * + * @param value a BigDecimal value + * @param total a BigDecimal value + * @return a BigDecimal value + */ public static BigDecimal calculateWeight(final BigDecimal value, final BigDecimal total) { return BigDecimalUtil.setScale( BigDecimalUtil.divide(BigDecimalUtil.setScale(value, 9), BigDecimalUtil.setScale(total, 9), BigDecimal.ROUND_HALF_UP), 9); } - /** + * Divide the given numerator by the given denominator with the given numerator scale and rounding modes. + * + * @param numeratorScale an int value + * @param numerator a BigDecimal value + * @param denominator a BigDecimal value + * @param rounding an int value * @return numerator / denominator if they are not null and the denominator is not zero, it returns null otherwise. */ public static BigDecimal divide(final int numeratorScale, final BigDecimal numerator, final BigDecimal denominator, final int rounding) { @@ -226,8 +260,13 @@ public static BigDecimal divide(final int numeratorScale, final BigDecimal numer } return diff; } - /** + * Divide the given numerator by the given denominator using the given scale for the result and the given rounding mode. + * + * @param numerator a BigDecimal value + * @param denominator a BigDecimal value + * @param scale an int value + * @param rounding an int value * @return numerator / denominator if they are not null and the denominator is not zero, it returns null otherwise. */ public static BigDecimal divide(final BigDecimal numerator, final BigDecimal denominator, final int scale, final int rounding) { @@ -237,7 +276,13 @@ public static BigDecimal divide(final BigDecimal numerator, final BigDecimal den } return BigDecimalUtil.setScale(diff, scale, rounding); } - + /** + * Multiply the given values, returning null if either input value is null. + * + * @param value a BigDecimal value or null + * @param multiplicand a BigDecimal value or null + * @return a BigDecimal value or null + */ public static BigDecimal multiply(final BigDecimal value, final BigDecimal multiplicand) { BigDecimal diff = null; if (value != null && multiplicand != null) { @@ -245,7 +290,13 @@ public static BigDecimal multiply(final BigDecimal value, final BigDecimal multi } return diff; } - + /** + * Multiply the given value by all the additional values. + * + * @param value a BigDecimal value + * @param multiplicand a BigDecimal[] value + * @return a BigDecimal value + */ public static BigDecimal multiply(final BigDecimal value, final BigDecimal... multiplicand) { BigDecimal diff = null; if (value != null && multiplicand != null) { @@ -258,7 +309,6 @@ public static BigDecimal multiply(final BigDecimal value, final BigDecimal... mu } return diff; } - /** * Returns the ABS of the value, handles null. * @param value nullable BigDecimal @@ -267,7 +317,6 @@ public static BigDecimal multiply(final BigDecimal value, final BigDecimal... mu public static BigDecimal abs(final BigDecimal value) { return value != null ? value.abs() : null; } - /** * Returns the negate of the value, handles null. * @param value nullable BigDecimal @@ -318,9 +367,13 @@ public static boolean isSameAbsValue(final BigDecimal v1, final BigDecimal v2) { } /** + * Compare two values. + * + * @param v1 a BigDecimal value + * @param v2 a BigDecimal value * @return 1 if v1 > v2 or v2==null and v2!=null - * @return 0 if v1 == v2 or v1==null and v2==null - * @return -1 if v1 < v2 or v1==null and v2!=null + * 0 if v1 == v2 or v1==null and v2==null + * -1 if v1 < v2 or v1==null and v2!=null */ public static int compareTo(final BigDecimal v1, final BigDecimal v2) { int ret = 1; @@ -333,28 +386,36 @@ public static int compareTo(final BigDecimal v1, final BigDecimal v2) { } return ret; } - /** + * Compare the absolute values of two values. + * + * @param v1 a BigDecimal value + * @param v2 a BigDecimal value * @return true if the ABS(v1) > ABS(v2) */ public static int absCompareTo(final BigDecimal v1, final BigDecimal v2) { return compareTo(abs(v1), abs(v2)); } - /** + * Calculate the absolute difference between two values. + * + * @param v1 a BigDecimal value + * @param v2 a BigDecimal value * @return true if the ABS( ABS(v1) - ABS(v2) ) */ public static BigDecimal absDiff(final BigDecimal v1, final BigDecimal v2) { return abs(doSubtract(abs(v1), abs(v2))); } - /** * Safe shift (check for null), shift RIGHT if shift>0. + * + * @param v1 a BigDecimal value + * @param shift an int value + * @return a BigDecimal value */ public static BigDecimal movePoint(final BigDecimal v1, final int shift) { return v1 == null ? null : v1.movePointRight(shift); } - /** * returns a new BigDecimal with correct scale after being round to n dec places. * @@ -366,32 +427,33 @@ public static BigDecimal movePoint(final BigDecimal v1, final int shift) { public static BigDecimal roundTo(final BigDecimal bd, final int numberOfDecPlaces, final int finalScale) { return setScale(setScale(bd, numberOfDecPlaces, BigDecimal.ROUND_HALF_UP), finalScale); } - /** * returns a new BigDecimal with correct scale. * - * @param bd + * @param bd a BigDecimal value + * @param scale an int value * @return new bd or null */ public static BigDecimal setScale(final BigDecimal bd, final int scale) { return setScale(bd, scale, BigDecimal.ROUND_HALF_UP); } - /** * returns a new BigDecimal with correct Scale. * - * @param bd + * @param bd a BigDecimal value + * @param scale an int value * @return new bd or null */ public static BigDecimal setScale(final BigDecimal bd, final Integer scale) { return setScale(bd, scale, BigDecimal.ROUND_HALF_UP); } - /** * returns a new BigDecimal with correct Scales.PERCENT_SCALE. This is used * by the table renderer. * - * @param bd + * @param bd a BigDecimal value + * @param scale an int value + * @param rounding an int value * @return new bd or null */ public static BigDecimal setScale(final BigDecimal bd, final Integer scale, final int rounding) { @@ -400,24 +462,29 @@ public static BigDecimal setScale(final BigDecimal bd, final Integer scale, fina } return null; } - /** * If value is null return 0 otherwise the signum(). - * @param value + * @param value a BigDecimal value * @return an int value */ public static int signum(final BigDecimal value) { return value == null ? 0 : value.signum(); } - /** + * Indicate if the two values are the same sign. + * + * @param v1 a BigDecimal value or null + * @param v2 a BigDecimal value or null * @return true if both v1/v2 are null or same sign. */ public static boolean isSameSignum(final BigDecimal v1, final BigDecimal v2) { return signum(v1) == signum(v2); } - /** + * Indicate if the two numbers are of opposite signs and both not zero. + * + * @param v1 a BigDecimal value + * @param v2 a BigDecimal value * @return true if both v1.signum() != v2.signum() and NOT zero. */ public static boolean hasSignedFlippedAndNotZero(final BigDecimal v1, final BigDecimal v2) { @@ -425,48 +492,55 @@ public static boolean hasSignedFlippedAndNotZero(final BigDecimal v1, final BigD final int v2Sign = signum(v2); return v1Sign != v2Sign && v1Sign != 0 && v2Sign != 0; } - /** + * Indicate if the two numbers are of opposite signs. + * + * @param v1 a BigDecimal value + * @param v2 a BigDecimal value * @return true if v1.signum() != v2.signum(). */ public static boolean hasSignedChanged(final BigDecimal v1, final BigDecimal v2) { return signum(v1) != signum(v2); } - /** - * @param bd - * @param lowerLimit - * @param upperLimit + * Indicate if the given value is out of the inclusive range established by the given parameters. + * + * @param bd a BigDecimal value + * @param lowerLimit a BigDecimal value + * @param upperLimit a BigDecimal value * @return true if outside the range */ public static boolean isOutsideRange(final BigDecimal bd, final BigDecimal lowerLimit, final BigDecimal upperLimit) { return !isInsideInclusiveRange(bd, lowerLimit, upperLimit); } - /** - * @param bd - * @param lowerLimit - * @param upperLimit + * Indicate if the given value is inside of the inclusive range established by the given parameters. + * + * @param bd a BigDecimal value + * @param lowerLimit a BigDecimal value + * @param upperLimit a BigDecimal value * @return true if inside the inclusive range */ public static boolean isInsideInclusiveRange(final BigDecimal bd, final BigDecimal lowerLimit, final BigDecimal upperLimit) { return ObjectUtil.noneNull(bd, lowerLimit, upperLimit) && bd.compareTo(lowerLimit) >= 0 && bd.compareTo(upperLimit) <= 0; } - /** + * Return the given value or the fallback value if the given value is null. + * + * @param o1 a BigDecimal value + * @param fallBack a BigDecimal value * @return o1 if not null, otherwise fallBack */ public static BigDecimal assignNonNull(final BigDecimal o1, final BigDecimal fallBack) { return o1 != null ? o1 : fallBack; } - /** * Calculate the weight of the constituent and add it to the running weighted value. * runningWeightedVal + valueToAdd * weightForValueToAdd / totalWeight - * @param runningWeightedVal - * @param valueToAdd - * @param weightForValueToAdd - * @param totalWeight + * @param runningWeightedVal a BigDecimal value + * @param valueToAdd a BigDecimal value + * @param weightForValueToAdd a BigDecimal value + * @param totalWeight a BigDecimal value * @return a BigDecimal value */ public static BigDecimal addWeightedConstituent(final BigDecimal runningWeightedVal, final BigDecimal valueToAdd, @@ -475,8 +549,10 @@ public static BigDecimal addWeightedConstituent(final BigDecimal runningWeighted BigDecimalUtil.multiply(valueToAdd, BigDecimalUtil.abs(weightForValueToAdd)), BigDecimalUtil.abs(totalWeight), BigDecimal.ROUND_HALF_UP)); } - /** + * Indicate if all the values are null or zero. + * + * @param values a BigDecimal[] value * @return true if all values are either null or zero */ public static boolean allNullOrZero(final BigDecimal... values) { @@ -487,39 +563,41 @@ public static boolean allNullOrZero(final BigDecimal... values) { } return true; } - /** - * return a Number formatted or empty string if null. - * @param bd + * Return a number formatted with {@link #NUMBER_FORMAT} or an empty string if null. + * + * @param bd a BigDecimal value + * @return a formatted number or empty string if null. */ public static String format(final BigDecimal bd) { return bd != null ? NUMBER_FORMAT.format(bd) : ""; } - /** - * return a Number formatted or empty string if null. - * @param bd + * Return a number interpreted as a percentage formatted with {@link #NUMBER_FORMAT} or an empty string if null. + * + * @param bd a BigDecimal value + * @return a String value */ public static String percentFormat(final BigDecimal bd) { return bd != null ? NUMBER_FORMAT.format(bd.movePointRight(2)) : ""; } - /** - * true if ABS((startValue-newValue)/startValue) <= abs(thresholdPercent) - * @param startValue - * @param newValue - * @param thresholdPercent + * Return true if ABS((startValue-newValue)/startValue) <= abs(thresholdPercent). + * + * @param startValue a BigDecimal value + * @param newValue a BigDecimal value + * @param thresholdPercent a BigDecimal value * @return a boolean value */ public static boolean movedInsideThresholdPercentage(final BigDecimal startValue, final BigDecimal newValue, final BigDecimal thresholdPercent) { return !movedStrictlyOutsideThresholdPercentage(startValue, newValue, thresholdPercent); } - /** - * true if ABS((startValue-newValue)/startValue) > abs(thresholdPercent) - * @param startValue - * @param newValue - * @param thresholdPercent + * Return true if ABS((startValue-newValue)/startValue) > abs(thresholdPercent). + * + * @param startValue a BigDecimal value + * @param newValue a BigDecimal value + * @param thresholdPercent a BigDecimal value * @return a boolean value */ public static boolean movedStrictlyOutsideThresholdPercentage(final BigDecimal startValue, final BigDecimal newValue, @@ -587,7 +665,6 @@ private static double roundDown(final double n, final int p) { private static short sign(final double d) { return (short) (d == 0 ? 0 : d < 0 ? -1 : 1); } - /** * Returns a value rounded-up to p digits after decimal. * If p is negative, then the number is rounded to @@ -600,8 +677,8 @@ private static short sign(final double d) { * by the sign value of n (@see MathX.sign(double d)). * Thus, -0.2 rounded-up to p=0 will give -1 not 0. *

If n is NaN, returned value is NaN. - * @param n - * @param p + * @param n a BigDecimal value + * @param p an int value * @return a BigDecimal value */ public static BigDecimal roundUp(final BigDecimal n, final int p) { @@ -611,7 +688,6 @@ public static BigDecimal roundUp(final BigDecimal n, final int p) { final int scale = n.scale(); return BigDecimalUtil.setScale(new BigDecimal(roundUp(n.doubleValue(), p)), scale); } - /** * Returns a value rounded to p digits after decimal. * If p is negative, then the number is rounded to @@ -624,8 +700,8 @@ public static BigDecimal roundUp(final BigDecimal n, final int p) { * by the sign value of n (@see MathX.sign(double d)). * Thus, -0.8 rounded-down to p=0 will give 0 not -1. *

If n is NaN, returned value is NaN. - * @param n - * @param p + * @param n a BigDecimal value + * @param p an int value * @return a BigDecimal value */ public static BigDecimal roundDown(final BigDecimal n, final int p) { @@ -653,29 +729,40 @@ public static BigDecimal roundDownForIncrement(final BigDecimal n, final BigDeci final int scale = n.scale(); return BigDecimalUtil.setScale(new BigDecimal(roundDown(n.doubleValue(), p)), scale); } - /** * Return minimum if the value is < minimum. + * + * @param minimum a BigDecimal value + * @param value a BigDecimal value + * @return a BigDecimal value */ public static BigDecimal ensureMin(final BigDecimal minimum, final BigDecimal value) { return BigDecimalUtil.compareTo(minimum, value) == 1 ? minimum : value; } - /** * Return a negative amount based on amount. + * + * @param amount a BigDecimal value + * @return a BigDecimal value */ public static BigDecimal forceNegative(final BigDecimal amount) { return BigDecimalUtil.negate(BigDecimalUtil.abs(amount)); } - /** * Return a negative amount based on amount if true, otherwise return the ABS. + * + * @param condition a boolean value + * @param amount a BigDecimal value + * @return a BigDecimal value */ public static BigDecimal forceNegativeIfTrue(final boolean condition, final BigDecimal amount) { return condition ? BigDecimalUtil.negate(BigDecimalUtil.abs(amount)) : BigDecimalUtil.abs(amount); } - /** + * Return the minimum of the two values. + * + * @param v1 a BigDecimal value + * @param v2 a BigDecimal value * @return return the min amount */ public static BigDecimal min(final BigDecimal v1, final BigDecimal v2) { @@ -686,8 +773,10 @@ public static BigDecimal min(final BigDecimal v1, final BigDecimal v2) { } return v1.compareTo(v2) <= 0 ? v1 : v2; } - /** + * Return the maximum of all the given values. + * + * @param v1 a BigDecimal[] value * @return return the max amount */ public static BigDecimal max(final BigDecimal... v1) { @@ -700,10 +789,12 @@ public static BigDecimal max(final BigDecimal... v1) { } return max; } - /** * Move by 2 DEC place to the left and take the long value, this * takes care of values like 0.18 in fractions. + * + * @param v a BigDecimal value + * @return a long value */ public static long longForFraction(final BigDecimal v) { if (v == null) { @@ -711,8 +802,12 @@ public static long longForFraction(final BigDecimal v) { } return BigDecimalUtil.movePoint(v, 2).longValue(); } - /** + * Indicate if the absolute difference is more than the given threshold. + * + * @param v1 a BigDecimal value + * @param v2 a BigDecimal value + * @param threshold a BigDecimal value * @return true if abs(abs(v1)-abs(v2)) < abs(threshold) */ public static boolean isDiffMoreThanAbsThreshold(final BigDecimal v1, final BigDecimal v2, final BigDecimal threshold) { @@ -723,17 +818,20 @@ public static boolean isDiffMoreThanAbsThreshold(final BigDecimal v1, final BigD public static double doubleValue(final BigDecimal val) { return val != null ? val.doubleValue() : 0.0; } - /** + * Indicate if the given value is zero or less. + * + * @param value a BigDecimal value * @return true if value !=null and <=0. */ public static boolean isZeroOrLess(final BigDecimal value) { return value != null && value.signum() <= 0; } - /** * Return the decimal part of the value. - * @param val + * + * @param val a BigDecimal value + * @return a BigDecimal value */ public static BigDecimal decimalPart(final BigDecimal val) { return BigDecimalUtil.subtract(val, val.setScale(0, BigDecimal.ROUND_DOWN)); diff --git a/core/src/main/java/org/marketcetera/core/BigDecimalUtils.java b/core/src/main/java/org/marketcetera/core/BigDecimalUtils.java index d7c0262972..fb531783c5 100644 --- a/core/src/main/java/org/marketcetera/core/BigDecimalUtils.java +++ b/core/src/main/java/org/marketcetera/core/BigDecimalUtils.java @@ -9,59 +9,61 @@ @ClassVersion("$Id$") //$NON-NLS-1$ public class BigDecimalUtils { -// default to read a double primitive value of 18 digit -// precision - public static final NumberFormat DEFAULT_DECIMAL_FORMAT = - new DecimalFormat ("#.0#################",new DecimalFormatSymbols(Locale.US)); //$NON-NLS-1$ - + // default to read a double primitive value of 18 digit + // precision + public static final NumberFormat DEFAULT_DECIMAL_FORMAT = new DecimalFormat ("#.0#################", + new DecimalFormatSymbols(Locale.US)); //$NON-NLS-1$ public static final MathContext DEFAULT_CONTEXT = new MathContext(4); - public static BigDecimal add (BigDecimal a, BigDecimal b) { - if (a == null) return (b == null) ? BigDecimal.ZERO : b; - return a.add (b); - } + public static BigDecimal add (BigDecimal a, BigDecimal b) { + if (a == null) return (b == null) ? BigDecimal.ZERO : b; + return a.add (b); + } - public static BigDecimal subtract (BigDecimal a, BigDecimal b) { - if (a == null) return (b == null) ? BigDecimal.ZERO : b; - return a.subtract (b); - } + public static BigDecimal subtract (BigDecimal a, BigDecimal b) { + if (a == null) return (b == null) ? BigDecimal.ZERO : b; + return a.subtract (b); + } - public static BigDecimal multiply (double a, double b) { - String s = DEFAULT_DECIMAL_FORMAT.format(a); - BigDecimal bd = new BigDecimal (s); //non-i18n - return multiply (bd, b); - } + public static BigDecimal multiply (double a, double b) { + String s = DEFAULT_DECIMAL_FORMAT.format(a); + BigDecimal bd = new BigDecimal (s); //non-i18n + return multiply (bd, b); + } - public static BigDecimal multiply (BigDecimal a, double b) { - String s = DEFAULT_DECIMAL_FORMAT.format(b); - BigDecimal bd = new BigDecimal (s); //non-i18n - return multiply (a, bd); - } + public static BigDecimal multiply (BigDecimal a, double b) { + String s = DEFAULT_DECIMAL_FORMAT.format(b); + BigDecimal bd = new BigDecimal (s); //non-i18n + return multiply (a, bd); + } - public static BigDecimal multiply (BigDecimal a, BigDecimal b) { - if (a == null) return (b == null) ? BigDecimal.ZERO : b; - return a.multiply (b); - } + public static BigDecimal multiply (BigDecimal a, BigDecimal b) { + if (a == null) return (b == null) ? BigDecimal.ZERO : b; + return a.multiply (b); + } - public static BigDecimal divide (BigDecimal a, BigDecimal b) { return divide(a, b, MathContext.DECIMAL128); } + public static BigDecimal divide (BigDecimal a, BigDecimal b) { return divide(a, b, MathContext.DECIMAL128); } - public static BigDecimal divide (BigDecimal a, BigDecimal b, MathContext context) { - if (a == null) return (b == null) ? BigDecimal.ZERO : b; - return a.divide (b, context); - } - - /** Returns the BigDecimal value n with trailing zeroes removed. */ - public static BigDecimal trim(BigDecimal n) { - try { + public static BigDecimal divide (BigDecimal a, BigDecimal b, MathContext context) { + if (a == null) return (b == null) ? BigDecimal.ZERO : b; + return a.divide (b, context); + } + /** + * Returns the BigDecimal value n with trailing zeroes removed. + * + * @param n a BigDecimal value + * @return a BigDecimal value + */ + public static BigDecimal trim(BigDecimal n) { + try { int scale; while((scale = n.scale()) > 0) { n = n.setScale(scale - 1); } - } catch (ArithmeticException e) { - // no more trailing zeroes so exit. - } - return n; - } - + } catch (ArithmeticException e) { + // no more trailing zeroes so exit. + } + return n; + } } diff --git a/core/src/main/java/org/marketcetera/core/ExternalIDFactory.java b/core/src/main/java/org/marketcetera/core/ExternalIDFactory.java index 6f30dd381c..20a56035ba 100644 --- a/core/src/main/java/org/marketcetera/core/ExternalIDFactory.java +++ b/core/src/main/java/org/marketcetera/core/ExternalIDFactory.java @@ -40,8 +40,11 @@ public String getNext() throws NoMoreIDsException return prefix + (mNextID++); } } - - /** Returns the value of the next ID, but does not increment the id - this is more of a peek */ + /** + * Returns the value of the next ID, but does not increment the id - this is more of a peek + * + * @return a long value + */ protected long peekNextAsInt() { return mNextID; diff --git a/core/src/main/java/org/marketcetera/core/IDFactory.java b/core/src/main/java/org/marketcetera/core/IDFactory.java index 31de120dac..99f5636907 100644 --- a/core/src/main/java/org/marketcetera/core/IDFactory.java +++ b/core/src/main/java/org/marketcetera/core/IDFactory.java @@ -14,8 +14,12 @@ public interface IDFactory { * @throws NoMoreIDsException When there are no more exceptions to get from the DB * @return the next unique identifier as a string */ - public String getNext() throws NoMoreIDsException; - - /** Do your init thing, you factory, you! */ - public void init() throws ClassNotFoundException, NoMoreIDsException ; + String getNext() throws NoMoreIDsException; + /** + * Do your init thing, you factory, you! + * + * @throws ClassNotFoundException if the ID factory cannot be initialized + * @throws NoMoreIDsException if no more IDs are available + */ + void init() throws ClassNotFoundException, NoMoreIDsException ; } diff --git a/core/src/main/java/org/marketcetera/core/InMemoryIDFactory.java b/core/src/main/java/org/marketcetera/core/InMemoryIDFactory.java index 361a192a99..b843432981 100644 --- a/core/src/main/java/org/marketcetera/core/InMemoryIDFactory.java +++ b/core/src/main/java/org/marketcetera/core/InMemoryIDFactory.java @@ -1,6 +1,5 @@ package org.marketcetera.core; - /** * Implementation of IDFactory that provides identifiers unique to this run of the * Java VM. They are simply the string representation of a counter that is incremented @@ -19,23 +18,22 @@ public class InMemoryIDFactory implements IDFactory { * @param startAt the value at which to start the unique identifiers. */ public InMemoryIDFactory(long startAt) { - this(startAt, ""); //$NON-NLS-1$ + this(startAt, ""); //$NON-NLS-1$ } - /** * Creates a new instance of InMemoryOrderIDFactory, with the given starting * number, and a prefix for the identifiers * @param startAt the value at which to start the unique identifiers. + * @param suffix a String value */ public InMemoryIDFactory(long startAt, String suffix) { mNextID = startAt; - this.prefix = suffix; + this.prefix = suffix; } - /** * Returns the next unique identifier as a string * @return the next unique identifier - * @throws NoMoreIDsException + * @throws NoMoreIDsException if no more IDs are available */ public String getNext() throws NoMoreIDsException { long retVal = 0; @@ -43,12 +41,10 @@ public String getNext() throws NoMoreIDsException { retVal = mNextID++; } if (retVal == Long.MAX_VALUE){ - throw new NoMoreIDsException(Messages.ERROR_IN_MEMORY_ID_FACTORY_OVERRUN); + throw new NoMoreIDsException(Messages.ERROR_IN_MEMORY_ID_FACTORY_OVERRUN); } return prefix+retVal; } - - public void init() { // no-op } diff --git a/core/src/main/java/org/marketcetera/core/LockHelper.java b/core/src/main/java/org/marketcetera/core/LockHelper.java index 90af2af3f5..72938acee7 100644 --- a/core/src/main/java/org/marketcetera/core/LockHelper.java +++ b/core/src/main/java/org/marketcetera/core/LockHelper.java @@ -24,6 +24,7 @@ public class LockHelper * Executes the given {@link Callable} block within the context of a * write lock. * + * @param a T value * @param inBlock a Callable<T> value * @return a T value * @throws Exception if an error occurs during block execution @@ -57,6 +58,7 @@ public void executeWrite(Runnable inBlock) * Executes the given {@link Callable} block within the context of a * read lock. * + * @param a T value * @param inBlock a Callable<T> value * @return a T value * @throws Exception if an error occurs during block execution diff --git a/core/src/main/java/org/marketcetera/core/ObjectUtil.java b/core/src/main/java/org/marketcetera/core/ObjectUtil.java index 50a976709c..759e08b86a 100644 --- a/core/src/main/java/org/marketcetera/core/ObjectUtil.java +++ b/core/src/main/java/org/marketcetera/core/ObjectUtil.java @@ -34,13 +34,15 @@ import java.math.BigDecimal; -public final class ObjectUtil { - private ObjectUtil() { - } - +public final class ObjectUtil +{ /** * Return true if i1 equals (according to {@link Integer#equals(Object)}) 12. * Also returns true if 11 is null and 12 is null! Is safe on either 11 or 12 being null. + * + * @param i1 an Integer value + * @param i2 an Integer value + * @return a boolean value */ public static boolean equalsValue(final Integer i1, final Integer i2) { if (i1 == null) { @@ -48,12 +50,15 @@ public static boolean equalsValue(final Integer i1, final Integer i2) { } return i1.equals(i2); } - /** * Return true if bd1 has the same value (according to * {@link BigDecimalUtil#isSameValue(BigDecimal, BigDecimal)}, which takes care of different scales) * as bd2. * Also returns true if bd1 is null and bd2 is null! Is safe on either bd1 or bd2 being null. + * + * @param bd1 a BigDecimal value + * @param bd2 a BigDecimal value + * @return a boolean value */ public static boolean equalsValue(final BigDecimal bd1, final BigDecimal bd2) { if (bd1 == null) { @@ -61,10 +66,13 @@ public static boolean equalsValue(final BigDecimal bd1, final BigDecimal bd2) { } return BigDecimalUtil.isSameValue(bd1, bd2); } - /** * Return true if o1 equals (according to {@link Object#equals(Object)}) o2. * Also returns true if o1 is null and o2 is null! Is safe on either o1 or o2 being null. + * + * @param o1 an Object value + * @param o2 an Object value + * @return a boolean value */ public static boolean equalsValue(final Object o1, final Object o2) { if (o1 == null) { @@ -72,10 +80,13 @@ public static boolean equalsValue(final Object o1, final Object o2) { } return o1.equals(o2); } - /** * Return true if o1 equals (according to {@link Object#equals(Object)} any of the given objects. * Also returns true if o1 is null and any of the given objects is null as well! + * + * @param o1 an Object value + * @param o2s an Object[] value + * @return a boolean value */ public static boolean equalsAny(final Object o1, final Object... o2s) { for (final Object o2 : o2s) { @@ -92,9 +103,12 @@ public static boolean equalsAny(final Object o1, final Object... o2s) { } return false; } - /** * Return true if o1 equals (according to {@link Object#equals(Object)} ALL of the given objects. + * + * @param o1 an Object value + * @param o2s an Object[] value + * @return a boolean value */ public static boolean equalsAll(final Object o1, final Object... o2s) { for (final Object o2 : o2s) { @@ -111,17 +125,22 @@ public static boolean equalsAll(final Object o1, final Object... o2s) { } return true; } - /** * Return true if o1 does NOT equal (according to {@link Object#equals(Object)} any of the given objects. * Also returns false if o1 is null and any of the given objects is null as well! + * + * @param o1 an Object value + * @param o2s an Object[] value + * @return a boolean value */ public static boolean notEqualsAny(final Object o1, final Object... o2s) { return !equalsAny(o1, o2s); } - /** * Return true if any of the given objects are null. + * + * @param o1s an Object[] value + * @return a boolean value */ public static boolean anyNull(final Object... o1s) { for (final Object o1 : o1s) { @@ -131,9 +150,11 @@ public static boolean anyNull(final Object... o1s) { } return false; } - /** * Return true if ALL of the given objects are null. + * + * @param o1s an Object[] value + * @return a boolean value */ public static boolean allNull(final Object... o1s) { for (final Object o1 : o1s) { @@ -143,9 +164,11 @@ public static boolean allNull(final Object... o1s) { } return true; } - /** * Return true if at least one of the given objects is not null. + * + * @param o1s an Object[] value + * @return a boolean value */ public static boolean atLeastOneNotNull(final Object... o1s) { for (final Object o1 : o1s) { @@ -155,11 +178,17 @@ public static boolean atLeastOneNotNull(final Object... o1s) { } return false; } - /** * Return true if NONE of the given objects are null. + * + * @param o1s an Object[] value + * @return a boolean value */ public static boolean noneNull(final Object... o1s) { return !anyNull(o1s); } + /** + * Create a new ObjectUtil instance. + */ + private ObjectUtil() {} } diff --git a/core/src/main/java/org/marketcetera/core/Pair.java b/core/src/main/java/org/marketcetera/core/Pair.java index ae30706a86..b75ca3eadb 100644 --- a/core/src/main/java/org/marketcetera/core/Pair.java +++ b/core/src/main/java/org/marketcetera/core/Pair.java @@ -19,6 +19,8 @@ public class Pair /** * Creates a new Pair with the given attributes. * + * @param a Clazz1 value + * @param a Clazz2 value * @param inType1 a Clazz1 value * @param inType2 a Clazz2 value * @return a Pair<Clazz1,Clazz2> value diff --git a/core/src/main/java/org/marketcetera/core/ThreadLocalSimpleDateFormat.java b/core/src/main/java/org/marketcetera/core/ThreadLocalSimpleDateFormat.java index 55192bef5f..6b6b574d21 100644 --- a/core/src/main/java/org/marketcetera/core/ThreadLocalSimpleDateFormat.java +++ b/core/src/main/java/org/marketcetera/core/ThreadLocalSimpleDateFormat.java @@ -21,59 +21,60 @@ */ public class ThreadLocalSimpleDateFormat extends ThreadLocal { - private final String formatString; - private final Locale locale; - private TimeZone timeZone; + private final String formatString; + private final Locale locale; + private TimeZone timeZone; - /** - * Constructor that invokes the String construtor of SimpleDateFormat - * on each accessing thread. - * + /** + * Constructor that invokes the String constructor of SimpleDateFormat + * on each accessing thread. + * + * @param formatString a String value * @exception NullPointerException if the given pattern is null * @exception IllegalArgumentException if the given pattern is invalid - * @see SimpleDateFormat#SimpleDateFormat(String) - */ - public ThreadLocalSimpleDateFormat(String formatString) { - this(formatString, null); - } - - - /** - * Constructor that invokes the (String, Locale) constructor - * on each accessing thread. - * + * @see SimpleDateFormat#SimpleDateFormat(String) + */ + public ThreadLocalSimpleDateFormat(String formatString) { + this(formatString, null); + } + /** + * Constructor that invokes the (String, Locale) constructor + * on each accessing thread. + * + * @param formatString a String value + * @param locale a Locale value * @exception NullPointerException if the given pattern is null * @exception IllegalArgumentException if the given pattern is invalid - * @see SimpleDateFormat#SimpleDateFormat(String, Locale) - */ - public ThreadLocalSimpleDateFormat(String formatString, Locale locale) { - this.formatString = formatString; - this.locale = locale; - new SimpleDateFormat(formatString); - } + * @see SimpleDateFormat#SimpleDateFormat(String, Locale) + */ + public ThreadLocalSimpleDateFormat(String formatString, Locale locale) { + this.formatString = formatString; + this.locale = locale; + new SimpleDateFormat(formatString); + } - @Override - protected SimpleDateFormat initialValue() { //i18n_datetime - SimpleDateFormat simpleDateFormat; - if (locale != null){ - simpleDateFormat = new SimpleDateFormat(formatString, locale); - } else { - simpleDateFormat = new SimpleDateFormat(formatString); - } - if (timeZone != null){ - simpleDateFormat.setTimeZone(timeZone); - } - return simpleDateFormat; - } + @Override + protected SimpleDateFormat initialValue() { //i18n_datetime + SimpleDateFormat simpleDateFormat; + if (locale != null){ + simpleDateFormat = new SimpleDateFormat(formatString, locale); + } else { + simpleDateFormat = new SimpleDateFormat(formatString); + } + if (timeZone != null){ + simpleDateFormat.setTimeZone(timeZone); + } + return simpleDateFormat; + } - /** - * Sets the timeZone string that will be set on each - * instance of SimpleDateFormat created by this object. - * - * @param timeZone the time zone as a string - * @see SimpleDateFormat#setTimeZone(TimeZone) - */ - public void setTimeZone(TimeZone timeZone) { - this.timeZone = timeZone; - } + /** + * Sets the timeZone string that will be set on each + * instance of SimpleDateFormat created by this object. + * + * @param timeZone the time zone as a string + * @see SimpleDateFormat#setTimeZone(TimeZone) + */ + public void setTimeZone(TimeZone timeZone) { + this.timeZone = timeZone; + } } diff --git a/core/src/main/java/org/marketcetera/core/Total.java b/core/src/main/java/org/marketcetera/core/Total.java index 27110f9a8f..38f61f6f61 100644 --- a/core/src/main/java/org/marketcetera/core/Total.java +++ b/core/src/main/java/org/marketcetera/core/Total.java @@ -76,10 +76,11 @@ public void setTotal(final BigDecimal total) { this.value = total; } } - /** + * Add the given values if the condition evaluates to true. + * * @param condition if true, do the addition. - * @param values + * @param values a BigDecimal[] value * @return the total with changed value if condition is true. * @since 1.4.0 */ @@ -89,8 +90,10 @@ public Total addIfTrue(final boolean condition, final BigDecimal... values) { } return this; } - /** + * Add the given values to the Total value and return the new value. + * + * @param value a BigDecimal[] value * @return the current Sum with new total. */ public Total add(final BigDecimal... value) { @@ -100,10 +103,11 @@ public Total add(final BigDecimal... value) { } return this; } - /** + * Subtract the given values if the condition evaluates to true. + * * @param condition if true, do the subtraction. - * @param values + * @param values a BigDecimal[] value * @return the total with changed value if condition is true. * @since 1.4.0 */ @@ -129,8 +133,10 @@ public Total add(final Integer value) { } return this; } - /** + * Add the given Total and return the new value. + * + * @param value a Total value * @return the current Sum with new total. */ public Total add(final Total value) { @@ -140,8 +146,10 @@ public Total add(final Total value) { } return this; } - /** + * Subtract the given values and return the new value. + * + * @param value a BigDecimal[] value * @return the current Sum with new total. */ public Total minus(final BigDecimal... value) { @@ -151,8 +159,10 @@ public Total minus(final BigDecimal... value) { } return this; } - /** + * Subtract the given value and return the new value. + * + * @param value a Total value * @return the current Sum with new total. */ public Total minus(final Total value) { diff --git a/core/src/main/java/org/marketcetera/core/Util.java b/core/src/main/java/org/marketcetera/core/Util.java index 3a964a58b5..f5e9b5e33e 100644 --- a/core/src/main/java/org/marketcetera/core/Util.java +++ b/core/src/main/java/org/marketcetera/core/Util.java @@ -30,7 +30,7 @@ public class Util /** Tries to load the named file from a classpath * If the file name doesn't start with a leading / then * if we fail to load it we prepend the / and try again - * @param inFileName + * @param inFileName a String value * @param inObj some object to get the classloader from * @return The URL to the resource or NULL if it's not found */ @@ -44,15 +44,15 @@ public static URL loadFileFromClasspath(String inFileName, Object inObj) } return resource; } - /** * Reads the entire file and stuffs it into a StringBuffer and returns the string * The file is loaded from classpath. * Use wisely, this will choke on very large files. * - * @param inFileName + * @param inFileName a String value * @param inObj some object to get the classloader from * @return The entire contents of the file + * @throws Exception if an error occurs reading the file */ public static String getStringFromFile(String inFileName, Object inObj) throws Exception { @@ -69,10 +69,11 @@ public static String getStringFromFile(String inFileName, Object inObj) throws E /** * Deep copies the given object. * + * @param the type of the object to copy * @param inOriginalObject a Clazz value * @return a Clazz value - * @throws IOException - * @throws ClassNotFoundException + * @throws IOException if an error occurs copying the object + * @throws ClassNotFoundException if the new copy cannot be created */ @SuppressWarnings("unchecked") public static Clazz deepCopy(Clazz inOriginalObject) diff --git a/core/src/main/java/org/marketcetera/core/instruments/CFICodeUtils.java b/core/src/main/java/org/marketcetera/core/instruments/CFICodeUtils.java index 4b3fa21289..ac2cc3f0f2 100644 --- a/core/src/main/java/org/marketcetera/core/instruments/CFICodeUtils.java +++ b/core/src/main/java/org/marketcetera/core/instruments/CFICodeUtils.java @@ -144,13 +144,12 @@ static String getCFICode(Currency inInstrument) } return code.toString(); } - /** - * - * + * Get the CFI code from the given instrument. * - * @param inInstrument - * @return + * @param inInstrument an Instrument value + * @return a String value + * @throws UnsupportedOperationException if the given instrument does not have a CFI code */ public static String getCFICode(Instrument inInstrument) { diff --git a/core/src/main/java/org/marketcetera/core/instruments/package-info.java b/core/src/main/java/org/marketcetera/core/instruments/package-info.java index 2c16efaa08..fbdb5cb4f1 100644 --- a/core/src/main/java/org/marketcetera/core/instruments/package-info.java +++ b/core/src/main/java/org/marketcetera/core/instruments/package-info.java @@ -18,6 +18,7 @@ * instrument instance is available is abstracted out by * implementing it in a subclass of * {@link org.marketcetera.core.instruments.InstrumentFunctionHandler}. + *

*

* A {@link org.marketcetera.core.instruments.StaticInstrumentFunctionSelector} * instance can be used to dynamically select the appropriate handler @@ -26,10 +27,10 @@ * The selector chooses the appropriate instrument specific subclass of * {@link org.marketcetera.core.instruments.StaticInstrumentFunctionSelector} * based on the runtime type of the instrument. + *

*

* See {@link org.marketcetera.core.instruments.InstrumentToMessage} for an - * example. - *

+ * example.

*

DynamicInstrumentHandler

* In cases when an instrument instance is not available and instrument * specific functionality needs to be invoked based on an arbitrary data, diff --git a/core/src/main/java/org/marketcetera/core/position/PositionKeyFactory.java b/core/src/main/java/org/marketcetera/core/position/PositionKeyFactory.java index 3b75e50d3f..9d63c27286 100644 --- a/core/src/main/java/org/marketcetera/core/position/PositionKeyFactory.java +++ b/core/src/main/java/org/marketcetera/core/position/PositionKeyFactory.java @@ -24,14 +24,11 @@ public class PositionKeyFactory { * Creates an equity position key. Note that account and traderId are * converted to null if they only contain whitespace. * - * @param symbol - * symbol, cannot be null or whitespace - * @param account - * account - * @param traderId - * trader id - * @throws IllegalArgumentException - * if symbol is null or whitespace + * @param symbol symbol, cannot be null or whitespace + * @param account account + * @param traderId trader id + * @return a PositionKey<Equity> value + * @throws IllegalArgumentException if symbol is null or whitespace */ public static PositionKey createEquityKey(String symbol, @Nullable String account, @Nullable String traderId) { @@ -79,6 +76,7 @@ public static PositionKey createFutureKey(String inSymbol, * @param inSymbol a String value * @param inAccount a String value * @param inTraderId a String value + * @return a PositionKey<ConvertibleBond> value * @throws IllegalArgumentException if one of the given parameters are invalid */ public static PositionKey createConvertibleBondKey(String inSymbol, @@ -99,14 +97,15 @@ public static PositionKey createConvertibleBondKey(String inSym * @param farTenor a String value * @param inAccount a String value * @param inTraderId a String value + * @return a PositionKey<Currency> value * @throws IllegalArgumentException if one of the given parameters are invalid */ public static PositionKey createCurrencyKey(String baseCCY, - String plCCY, - String nearTenor, - @Nullable String farTenor, - @Nullable String inAccount, - @Nullable String inTraderId) + String plCCY, + String nearTenor, + @Nullable String farTenor, + @Nullable String inAccount, + @Nullable String inTraderId) { return createKey(new Currency(baseCCY, plCCY, nearTenor, farTenor),inAccount, inTraderId); @@ -118,6 +117,9 @@ public static PositionKey createCurrencyKey(String baseCCY, * @param inExpiry a String value * @param inStrikePrice a BigDecimal value * @param inType an OptionType value + * @param inAccount a String value + * @param inTraderId a String value + * @return a PositionKey<Currency> value * @throws IllegalArgumentException if any argument is null, or if symbol or expiry is whitespace */ public static PositionKey