java.lang.Object
de.grogra.xl.util.AggregateStateImpl<T>
- All Implemented Interfaces:
AggregateState,BooleanAggregateState,ByteAggregateState,CharAggregateState,DoubleAggregateState,FloatAggregateState,IntAggregateState,LongAggregateState,ObjectAggregateState<T>,ShortAggregateState
public final class AggregateStateImpl<T>
extends Object
implements BooleanAggregateState, ByteAggregateState, ShortAggregateState, CharAggregateState, IntAggregateState, LongAggregateState, FloatAggregateState, DoubleAggregateState, ObjectAggregateState<T>
Utility class which implements all
AggregateState
interfaces and provides some general fields for storing state.
Instances of this class are pooled so that heap traffic is reduced.- Author:
- Ole Kniemeyer
-
Field Summary
FieldsModifier and TypeFieldDescriptionThis field contains the result if the type is a reference type.This field may be used freely by aggregate methods.This field may be used freely by aggregate methods.This field may be used freely by aggregate methods.This field may be used freely by aggregate methods.doubleThis field contains the result if the type isdouble.doubleThis field may be used freely by aggregate methods.doubleThis field may be used freely by aggregate methods.doubleThis field may be used freely by aggregate methods.doubleThis field may be used freely by aggregate methods.floatThis field contains the result if the type isfloat.floatThis field may be used freely by aggregate methods.floatThis field may be used freely by aggregate methods.floatThis field may be used freely by aggregate methods.floatThis field may be used freely by aggregate methods.intThis field contains the result if the type isboolean,byte,short,char, orint.intThis field may be used freely by aggregate methods.intThis field may be used freely by aggregate methods.intThis field may be used freely by aggregate methods.intThis field may be used freely by aggregate methods.longThis field contains the result if the type islong.longThis field may be used freely by aggregate methods.longThis field may be used freely by aggregate methods.longThis field may be used freely by aggregate methods.longThis field may be used freely by aggregate methods. -
Method Summary
Modifier and TypeMethodDescriptionstatic AggregateStateImpl<?> allocate()booleanReturns the result of the aggregation.byteReturns the result of the aggregation.charReturns the result of the aggregation.doubleReturns the result of the aggregation.floatReturns the result of the aggregation.intReturns the result of the aggregation.longReturns the result of the aggregation.Returns the result of the aggregation.shortReturns the result of the aggregation.booleanReturnstrueto indicate the invoker of the aggregate method that the computation of the aggregate value has been completed by the aggregate method, even if there are values left for aggregation.voidSets thefinished-flag totrue.
-
Field Details
-
ival
public int ivalThis field contains the result if the type isboolean,byte,short,char, orint. -
lval
public long lvalThis field contains the result if the type islong. -
fval
public float fvalThis field contains the result if the type isfloat. -
dval
public double dvalThis field contains the result if the type isdouble. -
aval
This field contains the result if the type is a reference type. -
ival1
public int ival1This field may be used freely by aggregate methods. -
ival2
public int ival2This field may be used freely by aggregate methods. -
ival3
public int ival3This field may be used freely by aggregate methods. -
ival4
public int ival4This field may be used freely by aggregate methods. -
lval1
public long lval1This field may be used freely by aggregate methods. -
lval2
public long lval2This field may be used freely by aggregate methods. -
lval3
public long lval3This field may be used freely by aggregate methods. -
lval4
public long lval4This field may be used freely by aggregate methods. -
fval1
public float fval1This field may be used freely by aggregate methods. -
fval2
public float fval2This field may be used freely by aggregate methods. -
fval3
public float fval3This field may be used freely by aggregate methods. -
fval4
public float fval4This field may be used freely by aggregate methods. -
dval1
public double dval1This field may be used freely by aggregate methods. -
dval2
public double dval2This field may be used freely by aggregate methods. -
dval3
public double dval3This field may be used freely by aggregate methods. -
dval4
public double dval4This field may be used freely by aggregate methods. -
aval1
This field may be used freely by aggregate methods. -
aval2
This field may be used freely by aggregate methods. -
aval3
This field may be used freely by aggregate methods. -
aval4
This field may be used freely by aggregate methods.
-
-
Method Details
-
allocate
-
getBooleanResult
public boolean getBooleanResult()Description copied from interface:BooleanAggregateStateReturns the result of the aggregation. This is only valid after the aggregate method has been invoked for a last time with itsfinishedargument set totrue.- Specified by:
getBooleanResultin interfaceBooleanAggregateState- Returns:
- aggregated value
-
getByteResult
public byte getByteResult()Description copied from interface:ByteAggregateStateReturns the result of the aggregation. This is only valid after the aggregate method has been invoked for a last time with itsfinishedargument set totrue.- Specified by:
getByteResultin interfaceByteAggregateState- Returns:
- aggregated value
-
getShortResult
public short getShortResult()Description copied from interface:ShortAggregateStateReturns the result of the aggregation. This is only valid after the aggregate method has been invoked for a last time with itsfinishedargument set totrue.- Specified by:
getShortResultin interfaceShortAggregateState- Returns:
- aggregated value
-
getCharResult
public char getCharResult()Description copied from interface:CharAggregateStateReturns the result of the aggregation. This is only valid after the aggregate method has been invoked for a last time with itsfinishedargument set totrue.- Specified by:
getCharResultin interfaceCharAggregateState- Returns:
- aggregated value
-
getIntResult
public int getIntResult()Description copied from interface:IntAggregateStateReturns the result of the aggregation. This is only valid after the aggregate method has been invoked for a last time with itsfinishedargument set totrue.- Specified by:
getIntResultin interfaceIntAggregateState- Returns:
- aggregated value
-
getLongResult
public long getLongResult()Description copied from interface:LongAggregateStateReturns the result of the aggregation. This is only valid after the aggregate method has been invoked for a last time with itsfinishedargument set totrue.- Specified by:
getLongResultin interfaceLongAggregateState- Returns:
- aggregated value
-
getFloatResult
public float getFloatResult()Description copied from interface:FloatAggregateStateReturns the result of the aggregation. This is only valid after the aggregate method has been invoked for a last time with itsfinishedargument set totrue.- Specified by:
getFloatResultin interfaceFloatAggregateState- Returns:
- aggregated value
-
getDoubleResult
public double getDoubleResult()Description copied from interface:DoubleAggregateStateReturns the result of the aggregation. This is only valid after the aggregate method has been invoked for a last time with itsfinishedargument set totrue.- Specified by:
getDoubleResultin interfaceDoubleAggregateState- Returns:
- aggregated value
-
getObjectResult
Description copied from interface:ObjectAggregateStateReturns the result of the aggregation. This is only valid after the aggregate method has been invoked for a last time with itsfinishedargument set totrue.- Specified by:
getObjectResultin interfaceObjectAggregateState<T>- Returns:
- aggregated value
-
setFinished
public void setFinished() -
isFinished
public boolean isFinished()Description copied from interface:AggregateStateReturnstrueto indicate the invoker of the aggregate method that the computation of the aggregate value has been completed by the aggregate method, even if there are values left for aggregation. E.g., this is the case for a short circuit implementation of the boolean or where the result is known when the firsttrue-value is encountered. The invoker must not invoke the aggregate method again.- Specified by:
isFinishedin interfaceAggregateState- Returns:
trueiff the final aggregated value is already known
-