Package org.cyclos.impl.banking
Class TimeBasedRateTypeHandlerImpl<R extends TimeBasedRateParameters,D extends TimeBasedRateParametersDTO>
- java.lang.Object
-
- org.cyclos.impl.AbstractServerComponent
-
- org.cyclos.impl.AbstractNetworkedServerComponent
-
- org.cyclos.impl.BaseNetworkedHandlerImpl
-
- org.cyclos.impl.banking.BaseRateTypeHandlerImpl<Date,R,D>
-
- org.cyclos.impl.banking.TimeBasedRateTypeHandlerImpl<R,D>
-
- All Implemented Interfaces:
RateTypeHandler<Date,R,D>,TimeBasedRateTypeHandler<R,D>
- Direct Known Subclasses:
ARateTypeHandlerImpl,DRateTypeHandlerImpl
public abstract class TimeBasedRateTypeHandlerImpl<R extends TimeBasedRateParameters,D extends TimeBasedRateParametersDTO> extends BaseRateTypeHandlerImpl<Date,R,D> implements TimeBasedRateTypeHandler<R,D>
parent handler implementation for A- and D-rate. There is a specific version for each rate; here go the common methods for A- and D-rates.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.cyclos.impl.banking.BaseRateTypeHandlerImpl
BaseRateTypeHandlerImpl.RateParametersChangeAction
-
-
Field Summary
-
Fields inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
authHandler, conversionHandler, customFieldValueHandler, entityManagerHandler, groupsHandler, productsHandler, restBeanPropertyMapping, userLocatorHandler
-
Fields inherited from class org.cyclos.impl.AbstractServerComponent
accountHandler, configurationHandler, dataTranslationHandler, notificationHandler, profileFieldHandler, transactionHandler, translationHandler
-
Fields inherited from interface org.cyclos.impl.banking.RateTypeHandler
RATE_SCALE
-
-
Constructor Summary
Constructors Constructor Description TimeBasedRateTypeHandlerImpl()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected DateadjustIncomingRawRateInTransfer(Date incomingRawRate, Transfer transfer)adjusts a rate as a result of the transaction.protected abstract BigDecimalcalculateRateChange(BigDecimal oldRate, Date oldDate, Date newDate)Defines the business logic of rates developing over time.DateTimeconvert(BigDecimal rate, DateTime date)likeRateTypeHandler.convert(BigDecimal, Date), but with DateTime as parameters.BigDecimalconvert(Date rawRate, Date date)Converts the stored rawRate to the actual rate as a BigDecimal.BigDecimalconvert(DateTime rawRate, DateTime date)likeRateTypeHandler.convert(Object, Date), but with DateTimes as parameters.DategetInitValue(Currency currency, Date date)Reads the raw initialization value of the rate in case a null rate is encountered.protected booleanhasEqualProperties(R entity, D dto)checks if the RateParameters entity has equal property values compared to the dto, in order to determine if it has been updated.-
Methods inherited from class org.cyclos.impl.banking.BaseRateTypeHandlerImpl
applyIncomingTransfer, assignEntityToCurrency, assignValidator, calculateFromRates, convert, getAccountRatesFieldPath, getCreationValue, getCurrentRateParameters, getEnableDate, getEntityClass, getParametersList, getQuery, getRateParameters, immediateDisableActions, inverseMerge, isEnabled, isVisible, isVisibleToUser, merge, nullAllAccountRates, resolveValidator, toEntity
-
Methods inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
canManage, checkManagesUser, checkPermission, checkRelatesToUser, checkValue, clearAlreadyValidated, getBaseEntityManagerHandler, getConfiguration, getLoggedBasicUser, getLoggedUser, getProducts, getTranslatedName, getTranslatedValue, hasPermission, hasValue, inSameNetwork, inSameNetworkOrGlobal, isAdmin, isAlreadyValidated, isBroker, isGlobalAdmin, isGlobalAdminInNetwork, isGuest, isLoggedIn, isMember, isMemberOnly, isNetworkAdmin, isOperator, isRelatedToUser, isSystem, isUserManager, isUserManagerOf, message, message, permission, permission, permissionOptionalValue, permissionOptionalValue, setAlreadyValidated, toDate, toDateTime, validate
-
Methods inherited from class org.cyclos.impl.AbstractServerComponent
dataTranslationProxy, dataTranslationProxy, delete, detach, doDataTranslationProxy, find, flush, from, getApplicationContext, getFormatter, getFormatter, getFormatter, getLogger, getRemoteAddress, getSessionData, mailContentBuilder, message, message, persist, processBatch, processBatch, refresh, remove, selectFrom, subQuery, update
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.cyclos.impl.banking.RateTypeHandler
applyIncomingTransfer, calculateFromRates, complete, convert, copy, getCreationValue, getEnableDate, getNullSafeRawRate, getRateParameters, getRateParameters, getRateParametersDTO, getRateType, isEnabled, isVisible, isVisibleToUser, nullAllAccountRates, resolveValidator, setRate, setRawRate, toEntity
-
-
-
-
Method Detail
-
convert
public DateTime convert(BigDecimal rate, DateTime date)
Description copied from interface:TimeBasedRateTypeHandlerlikeRateTypeHandler.convert(BigDecimal, Date), but with DateTime as parameters.- Specified by:
convertin interfaceTimeBasedRateTypeHandler<R extends TimeBasedRateParameters,D extends TimeBasedRateParametersDTO>
-
convert
public BigDecimal convert(Date rawRate, Date date)
Description copied from interface:RateTypeHandlerConverts the stored rawRate to the actual rate as a BigDecimal.- Specified by:
convertin interfaceRateTypeHandler<Date,R extends TimeBasedRateParameters,D extends TimeBasedRateParametersDTO>- Parameters:
rawRate- the raw rate as a java.util.Datedate- The java.util.Date at which this actual rate is requested. If null, now() is used.- Returns:
- the actual rate on date, as a BigDecimal.
-
convert
public BigDecimal convert(DateTime rawRate, DateTime date)
Description copied from interface:TimeBasedRateTypeHandlerlikeRateTypeHandler.convert(Object, Date), but with DateTimes as parameters.- Specified by:
convertin interfaceTimeBasedRateTypeHandler<R extends TimeBasedRateParameters,D extends TimeBasedRateParametersDTO>
-
getInitValue
public Date getInitValue(Currency currency, Date date)
Description copied from interface:TimeBasedRateTypeHandlerReads the raw initialization value of the rate in case a null rate is encountered. The initialization fields are looked up on the currency. The actual initialization of the rates only takes place when a new ClosedAccountBalance is created. This method does NOT initialized rates, it only reads the initialization values.- Specified by:
getInitValuein interfaceTimeBasedRateTypeHandler<R extends TimeBasedRateParameters,D extends TimeBasedRateParametersDTO>date- the date for which this init value is valid- Returns:
- the value on which the rate is initialized. Returns null if the rate was not enabled at the given date.
-
adjustIncomingRawRateInTransfer
protected Date adjustIncomingRawRateInTransfer(Date incomingRawRate, Transfer transfer)
Description copied from class:BaseRateTypeHandlerImpladjusts a rate as a result of the transaction. For date based rates, this is meaningless, so the method does nothing. For transfer based rates (I-rate, future C-rate) this method adds 1 to the raw rate of the from account - except when the from-account is unlimited; in that case it does nothing.- Specified by:
adjustIncomingRawRateInTransferin classBaseRateTypeHandlerImpl<Date,R extends TimeBasedRateParameters,D extends TimeBasedRateParametersDTO>- Parameters:
incomingRawRate- the from account's raw ratetransfer- this is only relevant for iRate, so in other cases this may as well be null, because it is not used then.- Returns:
- the incoming rate, but increased by 1 for transfer based rates. For date based rates, it returns just the unchanged input.
-
calculateRateChange
protected abstract BigDecimal calculateRateChange(BigDecimal oldRate, Date oldDate, Date newDate)
Defines the business logic of rates developing over time. Gives the new rate, on basis of the old rate, the old date, and the new date.- Parameters:
oldRate- a BigDecimal representing the old rate.oldDate- the java.util.Date belonging to oldRatenewDate- the java.util.Date for which the new Rate is requested- Returns:
- the new rate belonging to newDate.
-
hasEqualProperties
protected boolean hasEqualProperties(R entity, D dto)
Description copied from class:BaseRateTypeHandlerImplchecks if the RateParameters entity has equal property values compared to the dto, in order to determine if it has been updated. Supposed to be overridden.- Overrides:
hasEqualPropertiesin classBaseRateTypeHandlerImpl<Date,R extends TimeBasedRateParameters,D extends TimeBasedRateParametersDTO>
-
-