Sonar correctly points out the expression can be simplified, this
patch does exactly that.
Change-Id: I0ea51d18d551be0f4bd416d7b18da3eb543e0244
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
71892d4c8f435650eeef99f276884f7c2a3d57bd)
@Beta
public abstract class RequireInstanceRestrictedTypeBuilder<T extends RequireInstanceRestrictedTypeDefinition<T>>
extends AbstractRestrictedTypeBuilder<T> {
-
private boolean requireInstance;
RequireInstanceRestrictedTypeBuilder(final T baseType, final SchemaPath path) {
super(baseType, path);
- requireInstance = baseType != null ? baseType.requireInstance() : true;
+ requireInstance = baseType == null || baseType.requireInstance();
}
public final void setRequireInstance(final boolean requireInstance) {
// If the set of supported features has not been provided, all features are supported by default.
final Set<QName> supportedFeatures = getFromNamespace(SupportedFeaturesNamespace.class,
SupportedFeatures.SUPPORTED_FEATURES);
- final boolean ret = supportedFeatures == null ? true
- : StmtContextUtils.checkFeatureSupport(this, supportedFeatures);
-
+ final boolean ret = supportedFeatures == null || StmtContextUtils.checkFeatureSupport(this, supportedFeatures);
supportedByFeatures = OptionalBoolean.of(ret);
return ret;
}
stmt.addToNs(StatementDefinitionNamespace.class, stmt.getStatementArgument(),
new ModelDefinedStatementSupport(new ModelDefinedStatementDefinition(stmt.getStatementArgument(),
argument != null ? argument.getStatementArgument() : null,
- yinElement != null ? yinElement.getStatementArgument() : false)));
+ yinElement != null && yinElement.getStatementArgument())));
}
@Override
public static boolean hasParentOfType(final StmtContext<?, ?, ?> ctx, final StatementDefinition parentType) {
requireNonNull(parentType);
final StmtContext<?, ?, ?> parentContext = ctx.getParentContext();
- return parentContext != null ? parentType.equals(parentContext.getPublicDefinition()) : false;
+ return parentContext != null && parentType.equals(parentContext.getPublicDefinition());
}
/**