Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,8 @@ public int getBottomLevelDepth() {
int resultDepth = 0;
for (int i = 0; i < list.size(); i++) {
HierarchyAccess hierarchyAccess = list.get(i);
if (hierarchyAccess instanceof AllHierarchyAccess
? ((AllHierarchyAccess) hierarchyAccess).getAccess()
!= AccessHierarchy.NONE : true)
if (!(hierarchyAccess instanceof AllHierarchyAccess allAccess)
|| allAccess.getAccess() != AccessHierarchy.NONE)
{
int currentDepth =
hierarchyAccess.getBottomLevelDepth();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,11 @@ protected Object convert(Object value) {
if (value instanceof List list && !(value instanceof TupleList)) {
return TupleCollections.asTupleList(list);
}
if (value instanceof MemberExpression) {
return ((MemberExpression) value).getMember();
if (value instanceof MemberExpression memberExpr) {
return memberExpr.getMember();
}
if (value instanceof Literal) {
return ((Literal) value).getValue();
if (value instanceof Literal literal) {
return literal.getValue();
}
return value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public OrderKey( Member member ) {
@Override
public int compareTo( Object o ) {
assert o instanceof OrderKey;
Member otherMember = ( (OrderKey) o ).member;
OrderKey other = (OrderKey) o;
Member otherMember = other.member;
final boolean thisCalculated = this.member.isCalculatedInQuery();
final boolean otherCalculated = otherMember.isCalculatedInQuery();
if ( thisCalculated ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -996,9 +996,9 @@ public int hashCode() {
@Override
public boolean equals( Object obj ) {
return this == obj
|| obj instanceof ObjIntPair
&& this.i == ( (ObjIntPair) obj ).i
&& Objects.equals( this.t, ( (ObjIntPair) obj ).t );
|| obj instanceof ObjIntPair<?> other
&& this.i == other.i
&& Objects.equals( this.t, other.t );
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ private TupleList evaluateNative(
private Expression getOriginalExp(final Query query) {
originalExp.accept(
new TransformFromFormulasVisitor(query, compiler));
if (originalExp instanceof NamedSetExpression) {
if (originalExp instanceof NamedSetExpression namedSetExpr) {
//named sets get their evaluator cached in RolapResult.
//We do not want to use the cached evaluator, so pass along the
//expression instead.
return ((NamedSetExpression) originalExp).getNamedSet().getExp();
return namedSetExpr.getNamedSet().getExp();
}
return originalExp;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ private void addSentinelMembers(List<Expression> args) {
Expression curr = args.get(i);
if (prev.toString().equals(curr.toString())) {
OlapElement element = null;
if (curr instanceof NamedSetExpression) {
element = ((NamedSetExpression) curr).getNamedSet();
} else if (curr instanceof MemberExpression) {
element = ((MemberExpression) curr).getMember();
if (curr instanceof NamedSetExpression namedSetExpr) {
element = namedSetExpr.getNamedSet();
} else if (curr instanceof MemberExpression memberExpr) {
element = memberExpr.getMember();
}
if (element != null) {
Level level = element.getHierarchy().getLevels().getFirst();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,8 @@ static boolean isConstant(Expression typeArg) {
if (typeArg instanceof FunctionCall hierarchyCall) {
if (hierarchyCall.getOperationAtom().name().equals("Hierarchy")
&& hierarchyCall.getArgCount() > 0
&& hierarchyCall.getArg(0) instanceof FunctionCall)
&& hierarchyCall.getArg(0) instanceof FunctionCall currentMemberCall)
{
FunctionCall currentMemberCall = (FunctionCall) hierarchyCall.getArg(0);
if (currentMemberCall.getOperationAtom().name().equals("CurrentMember")
&& currentMemberCall.getArgCount() > 0
&& currentMemberCall.getArg(0) instanceof DimensionExpression)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ protected FunctionDefinition createFunDef(Expression[] args, FunctionMetaData fu
}
if (category == DataType.MEMBER) {
Type expType = exp.getType();
if (expType instanceof SetType) {
expType = ((SetType) expType).getElementType();
if (expType instanceof SetType setType) {
expType = setType.getElementType();
}
if (ParameterResolver.distinctFrom(type.getDimension(), expType.getDimension())
|| ParameterResolver.distinctFrom(type.getHierarchy(), expType.getHierarchy())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ public static ResolvedFunCall wrapAsSet(Expression... args) {
final Expression arg = args[i];
categories[i] = new FunctionParameterR(arg.getCategory());
final Type argType = arg.getType();
if (argType instanceof SetType) {
type = ((SetType) argType).getElementType();
if (argType instanceof SetType setType) {
type = setType.getElementType();
} else {
type = argType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public TupleList evaluateInternal(Evaluator evaluator) {
final Object o = mapMemberToValue.get(key);
if (o == Util.nullValue) {
nullCount++;
} else if (o instanceof Number) {
runningTotal += ((Number) o).doubleValue();
} else if (o instanceof Number n) {
runningTotal += n.doubleValue();
} else if (o instanceof Exception) {
// ignore the error
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,10 @@ public Object evaluateInternal(Evaluator evaluator) {
// if there is no matching member, return the null member for
// the specified dimension/hierarchy
Object arg0 = hierarchyCalc.evaluate(evaluator);
if (arg0 instanceof Hierarchy) {
resultDateMember = ((Hierarchy) arg0).getNullMember();
} else {
resultDateMember =
((Dimension) arg0).getHierarchy().getNullMember();
if (arg0 instanceof Hierarchy hier) {
resultDateMember = hier.getNullMember();
} else if (arg0 instanceof Dimension dim) {
resultDateMember = dim.getHierarchy().getNullMember();
}
return resultDateMember;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,9 @@ public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof Map)) {
if (!(o instanceof Map<?, ?> m)) {
return false;
}
Map<K, V> m = (Map<K, V>) o;
if (m.size() != size()) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,7 @@ public int hashCode() {
}

public boolean equals(Object obj) {
if (obj instanceof ParseRegionImpl) {
final ParseRegionImpl that = (ParseRegionImpl) obj;
if (obj instanceof ParseRegionImpl that) {
return this.startLine == that.startLine
&& this.startColumn == that.startColumn
&& this.endLine == that.endLine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
return obj instanceof ByteString
&& Arrays.equals(bytes, ((ByteString) obj).bytes);
return obj instanceof ByteString other
&& Arrays.equals(bytes, other.bytes);
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions common/src/main/java/org/eclipse/daanse/olap/util/Format.java
Original file line number Diff line number Diff line change
Expand Up @@ -2953,9 +2953,9 @@ private StringBuilder format(Object o, StringBuilder buf) {
bigInteger.longValue(), buf);
} else if (clazz == String.class) {
formatValue.format((String) o, buf);
} else if (o instanceof java.util.Date) {
} else if (o instanceof java.util.Date date) {
// includes java.sql.Date, java.sql.Time and java.sql.Timestamp
formatValue.format((Date) o, buf);
formatValue.format(date, buf);
} else if (o instanceof Calendar calendar) {
formatValue.format(calendar, buf);
} else {
Expand Down
4 changes: 1 addition & 3 deletions common/src/main/java/org/eclipse/daanse/olap/util/Pair.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ public static <L, R> Pair<L, R> of(L left, R right) {

@Override
public boolean equals(Object obj) {
if (obj instanceof Pair) {
//noinspection unchecked
Pair<L, R> pair = (Pair) obj;
if (obj instanceof Pair<?, ?> pair) {
return Objects.equals(this.left, pair.left)
&& Objects.equals(this.right, pair.right);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public static MemberType toMemberType(Type type) {
} else if (type instanceof DimensionType || type instanceof HierarchyType || type instanceof LevelType) {
return MemberType.forType(type);
} else if (type instanceof TupleType tupleType && tupleType.getArity() == 1) {
return MemberType.forHierarchy(((TupleType) type).getHierarchies().get(0));
return MemberType.forHierarchy(tupleType.getHierarchies().get(0));
} else {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,8 @@ static String getValueTypeHint(final String dataType) {
this.value = inputValue;
this.isDecimal = false;

} else if (inputValue instanceof Long) {
} else if (inputValue instanceof Long lval) {
// See if it can be an integer or long
long lval = (Long) inputValue;
setValueAndType(lval);

} else if (inputValue instanceof BigInteger bi) {
Expand Down Expand Up @@ -176,10 +175,10 @@ static String getValueTypeHint(final String dataType) {
}
}

} else if (inputValue instanceof Number) {
} else if (inputValue instanceof Number n) {
// Don't know what Number type we have here.
// Note: this could result in precision loss.
this.value = ((Number) inputValue).longValue();
this.value = n.longValue();
this.valueType = valueTypeHint;
this.isDecimal = false;

Expand All @@ -206,6 +205,7 @@ static String getValueTypeHint(final String dataType) {
|| inputValue instanceof Long) {
// Convert from byte/short/integer/long to double
this.value = ((Number) inputValue).doubleValue();
// Note: Pattern matching not beneficial here as we're checking multiple types
this.valueType = valueTypeHint;
this.isDecimal = true;

Expand Down Expand Up @@ -248,10 +248,10 @@ static String getValueTypeHint(final String dataType) {
this.isDecimal = true;
}

} else if (inputValue instanceof Number) {
} else if (inputValue instanceof Number n) {
// Don't know what Number type we have here.
// Note: this could result in precision loss.
this.value = ((Number) inputValue).doubleValue();
this.value = n.doubleValue();
this.valueType = valueTypeHint;
this.isDecimal = true;

Expand Down Expand Up @@ -285,9 +285,9 @@ static String getValueTypeHint(final String dataType) {
this.value = s.intValue();
this.isDecimal = false;

} else if (inputValue instanceof Long) {
} else if (inputValue instanceof Long lval) {
// See if it can be an integer or long
setValueAndType((Long) inputValue);
setValueAndType(lval);

} else if (inputValue instanceof BigInteger bi) {
// See if it can be an integer or long
Expand Down Expand Up @@ -333,10 +333,10 @@ static String getValueTypeHint(final String dataType) {
}
this.isDecimal = true;

} else if (inputValue instanceof Number) {
} else if (inputValue instanceof Number n) {
// Don't know what Number type we have here.
// Note: this could result in precision loss.
this.value = ((Number) inputValue).longValue();
this.value = n.longValue();
this.valueType = XsdType.XSD_LONG;
this.isDecimal = false;

Expand Down
Loading