We have bad signatures here, one of which is needlessly verbose,
the other one is actually plain wrong as it confuses X,Y for A,D.
Fix them up, which removes the need to go throw raw access to make
them work.
Change-Id: I6bfd995c8b4064b99eb673fa30c4ab8f3d52dd5c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
return verifyNotNull(getStatementArgument(), "Statement context %s does not have an argument", this);
}
return verifyNotNull(getStatementArgument(), "Statement context %s does not have an argument", this);
}
- default <X, Y extends DeclaredStatement<X>> boolean producesDeclared(final Class<? super Y> type) {
+ default <Y extends DeclaredStatement<?>> boolean producesDeclared(final Class<? super Y> type) {
return type.isAssignableFrom(getPublicDefinition().getDeclaredRepresentationClass());
}
return type.isAssignableFrom(getPublicDefinition().getDeclaredRepresentationClass());
}
- default <X, Y extends DeclaredStatement<X>, Z extends EffectiveStatement<A, D>> boolean producesEffective(
- final Class<? super Z> type) {
+ default <Z extends EffectiveStatement<?, ?>> boolean producesEffective(final Class<? super Z> type) {
return type.isAssignableFrom(getPublicDefinition().getEffectiveRepresentationClass());
}
return type.isAssignableFrom(getPublicDefinition().getEffectiveRepresentationClass());
}
* @param type Effective statement representation being look up
* @return Effective statement argument, if found
*/
* @param type Effective statement representation being look up
* @return Effective statement argument, if found
*/
- @SuppressWarnings({ "rawtypes", "unchecked" })
+ @SuppressWarnings("unchecked")
public static <A, E extends EffectiveStatement<A, ?>> @NonNull Optional<A> findSubstatementArgument(
final @NonNull StmtContext<?, ?, ?> stmt, final @NonNull Class<E> type) {
return stmt.allSubstatementsStream()
public static <A, E extends EffectiveStatement<A, ?>> @NonNull Optional<A> findSubstatementArgument(
final @NonNull StmtContext<?, ?, ?> stmt, final @NonNull Class<E> type) {
return stmt.allSubstatementsStream()
- .filter(ctx -> ctx.isSupportedToBuildEffective() && ((StmtContext) ctx).producesEffective(type))
+ .filter(ctx -> ctx.isSupportedToBuildEffective() && ctx.producesEffective(type))
.findAny()
.map(ctx -> (A) ctx.coerceStatementArgument());
}
.findAny()
.map(ctx -> (A) ctx.coerceStatementArgument());
}
* @param type Effective statement representation being look up
* @return True if a match is found, false otherwise
*/
* @param type Effective statement representation being look up
* @return True if a match is found, false otherwise
*/
- @SuppressWarnings({ "rawtypes", "unchecked" })
public static boolean hasSubstatement(final @NonNull StmtContext<?, ?, ?> stmt,
final @NonNull Class<? extends EffectiveStatement<?, ?>> type) {
return stmt.allSubstatementsStream()
public static boolean hasSubstatement(final @NonNull StmtContext<?, ?, ?> stmt,
final @NonNull Class<? extends EffectiveStatement<?, ?>> type) {
return stmt.allSubstatementsStream()
- .anyMatch(ctx -> ctx.isSupportedToBuildEffective() && ((StmtContext) ctx).producesEffective(type));
+ .anyMatch(ctx -> ctx.isSupportedToBuildEffective() && ctx.producesEffective(type));