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
Modifier 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.double
This field contains the result if the type isdouble
.double
This field may be used freely by aggregate methods.double
This field may be used freely by aggregate methods.double
This field may be used freely by aggregate methods.double
This field may be used freely by aggregate methods.float
This field contains the result if the type isfloat
.float
This field may be used freely by aggregate methods.float
This field may be used freely by aggregate methods.float
This field may be used freely by aggregate methods.float
This field may be used freely by aggregate methods.int
This field contains the result if the type isboolean
,byte
,short
,char
, orint
.int
This field may be used freely by aggregate methods.int
This field may be used freely by aggregate methods.int
This field may be used freely by aggregate methods.int
This field may be used freely by aggregate methods.long
This field contains the result if the type islong
.long
This field may be used freely by aggregate methods.long
This field may be used freely by aggregate methods.long
This field may be used freely by aggregate methods.long
This field may be used freely by aggregate methods. -
Method Summary
Modifier and TypeMethodDescriptionstatic AggregateStateImpl<?>
allocate()
boolean
Returns the result of the aggregation.byte
Returns the result of the aggregation.char
Returns the result of the aggregation.double
Returns the result of the aggregation.float
Returns the result of the aggregation.int
Returns the result of the aggregation.long
Returns the result of the aggregation.Returns the result of the aggregation.short
Returns the result of the aggregation.boolean
Returnstrue
to 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.void
Sets 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:BooleanAggregateState
Returns the result of the aggregation. This is only valid after the aggregate method has been invoked for a last time with itsfinished
argument set totrue
.- Specified by:
getBooleanResult
in interfaceBooleanAggregateState
- Returns:
- aggregated value
-
getByteResult
public byte getByteResult()Description copied from interface:ByteAggregateState
Returns the result of the aggregation. This is only valid after the aggregate method has been invoked for a last time with itsfinished
argument set totrue
.- Specified by:
getByteResult
in interfaceByteAggregateState
- Returns:
- aggregated value
-
getShortResult
public short getShortResult()Description copied from interface:ShortAggregateState
Returns the result of the aggregation. This is only valid after the aggregate method has been invoked for a last time with itsfinished
argument set totrue
.- Specified by:
getShortResult
in interfaceShortAggregateState
- Returns:
- aggregated value
-
getCharResult
public char getCharResult()Description copied from interface:CharAggregateState
Returns the result of the aggregation. This is only valid after the aggregate method has been invoked for a last time with itsfinished
argument set totrue
.- Specified by:
getCharResult
in interfaceCharAggregateState
- Returns:
- aggregated value
-
getIntResult
public int getIntResult()Description copied from interface:IntAggregateState
Returns the result of the aggregation. This is only valid after the aggregate method has been invoked for a last time with itsfinished
argument set totrue
.- Specified by:
getIntResult
in interfaceIntAggregateState
- Returns:
- aggregated value
-
getLongResult
public long getLongResult()Description copied from interface:LongAggregateState
Returns the result of the aggregation. This is only valid after the aggregate method has been invoked for a last time with itsfinished
argument set totrue
.- Specified by:
getLongResult
in interfaceLongAggregateState
- Returns:
- aggregated value
-
getFloatResult
public float getFloatResult()Description copied from interface:FloatAggregateState
Returns the result of the aggregation. This is only valid after the aggregate method has been invoked for a last time with itsfinished
argument set totrue
.- Specified by:
getFloatResult
in interfaceFloatAggregateState
- Returns:
- aggregated value
-
getDoubleResult
public double getDoubleResult()Description copied from interface:DoubleAggregateState
Returns the result of the aggregation. This is only valid after the aggregate method has been invoked for a last time with itsfinished
argument set totrue
.- Specified by:
getDoubleResult
in interfaceDoubleAggregateState
- Returns:
- aggregated value
-
getObjectResult
Description copied from interface:ObjectAggregateState
Returns the result of the aggregation. This is only valid after the aggregate method has been invoked for a last time with itsfinished
argument set totrue
.- Specified by:
getObjectResult
in interfaceObjectAggregateState<T>
- Returns:
- aggregated value
-
setFinished
public void setFinished() -
isFinished
public boolean isFinished()Description copied from interface:AggregateState
Returnstrue
to 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:
isFinished
in interfaceAggregateState
- Returns:
true
iff the final aggregated value is already known
-