use of javax.annotation.Nonnull in project sonarqube by SonarSource.
the class ConditionToCondition method apply.
@Override
@Nonnull
public QualityGate.Condition apply(Condition input) {
String metricKey = input.getMetric().getKey();
ConditionStatus conditionStatus = statusPerConditions.get(input);
checkState(conditionStatus != null, "Missing ConditionStatus for condition on metric key %s", metricKey);
return builder.setStatus(convert(conditionStatus.getStatus())).setMetricKey(metricKey).setOperator(convert(input.getOperator())).setErrorThreshold(input.getErrorThreshold()).setWarningThreshold(input.getWarningThreshold()).setOnLeakPeriod(input.hasPeriod()).setValue(conditionStatus.getValue()).build();
}
use of javax.annotation.Nonnull in project sonarqube by SonarSource.
the class MeasureToMeasureDto method toMeasureDto.
@Nonnull
public MeasureDto toMeasureDto(Measure measure, Metric metric, Component component) {
MeasureDto out = new MeasureDto();
out.setMetricId(metric.getId());
out.setComponentUuid(component.getUuid());
out.setAnalysisUuid(analysisMetadataHolder.getUuid());
if (measure.hasVariation()) {
out.setVariation(measure.getVariation());
}
if (measure.hasQualityGateStatus()) {
setAlert(out, measure.getQualityGateStatus());
}
Developer developer = measure.getDeveloper();
if (developer != null) {
out.setDeveloperId(dbIdsRepository.getDeveloperId(developer));
}
out.setDescription(measure.getDescription());
out.setValue(valueAsDouble(measure));
out.setData(data(measure));
return out;
}
use of javax.annotation.Nonnull in project neo4j by neo4j.
the class LabelsAcceptanceTest method beansAPIWithNoMoreLabelIds.
@SuppressWarnings("deprecation")
private GraphDatabaseService beansAPIWithNoMoreLabelIds() {
final EphemeralIdGenerator.Factory idFactory = new EphemeralIdGenerator.Factory() {
private IdTypeConfigurationProvider idTypeConfigurationProvider = new CommunityIdTypeConfigurationProvider();
@Override
public IdGenerator open(File fileName, int grabSize, IdType idType, long highId, long maxId) {
if (idType == IdType.LABEL_TOKEN) {
IdGenerator generator = generators.get(idType);
if (generator == null) {
IdTypeConfiguration idTypeConfiguration = idTypeConfigurationProvider.getIdTypeConfiguration(idType);
generator = new EphemeralIdGenerator(idType, idTypeConfiguration) {
@Override
public long nextId() {
// Same exception as the one thrown by IdGeneratorImpl
throw new UnderlyingStorageException("Id capacity exceeded");
}
};
generators.put(idType, generator);
}
return generator;
}
return super.open(fileName, grabSize, idType, Long.MAX_VALUE, Long.MAX_VALUE);
}
};
TestGraphDatabaseFactory dbFactory = new TestGraphDatabaseFactory() {
@Override
protected GraphDatabaseBuilder.DatabaseCreator createImpermanentDatabaseCreator(final File storeDir, final TestGraphDatabaseFactoryState state) {
return new GraphDatabaseBuilder.DatabaseCreator() {
@Override
public GraphDatabaseService newDatabase(Map<String, String> config) {
return newDatabase(Config.embeddedDefaults(config));
}
@Override
public GraphDatabaseService newDatabase(@Nonnull Config config) {
return new ImpermanentGraphDatabase(storeDir, config, GraphDatabaseDependencies.newDependencies(state.databaseDependencies())) {
@Override
protected void create(File storeDir, Config config, GraphDatabaseFacadeFactory.Dependencies dependencies) {
Function<PlatformModule, EditionModule> factory = (platformModule) -> new CommunityEditionModule(platformModule) {
@Override
protected IdGeneratorFactory createIdGeneratorFactory(FileSystemAbstraction fs, IdTypeConfigurationProvider idTypeConfigurationProvider) {
return idFactory;
}
};
new GraphDatabaseFacadeFactory(DatabaseInfo.COMMUNITY, factory) {
@Override
protected PlatformModule createPlatform(File storeDir, Config config, Dependencies dependencies, GraphDatabaseFacade graphDatabaseFacade) {
return new ImpermanentPlatformModule(storeDir, config, databaseInfo, dependencies, graphDatabaseFacade);
}
}.initFacade(storeDir, config, dependencies, this);
}
};
}
};
}
};
return dbFactory.newImpermanentDatabase();
}
use of javax.annotation.Nonnull in project neo4j by neo4j.
the class CausalClusterConfigurationValidator method validate.
@Override
@Nonnull
public Map<String, String> validate(@Nonnull Collection<SettingValidator> settingValidators, @Nonnull Map<String, String> rawConfig, @Nonnull Log log, boolean parsingFile) throws InvalidSettingException {
// Make sure mode is CC
Mode mode = ClusterSettings.mode.apply(rawConfig::get);
if (!mode.equals(Mode.CORE) && !mode.equals(Mode.READ_REPLICA)) {
// Nothing to validate
return rawConfig;
}
validateInitialDiscoveryMembers(rawConfig::get);
validateBoltConnector(rawConfig);
validateLoadBalancing(rawConfig, log);
return rawConfig;
}
use of javax.annotation.Nonnull in project neo4j by neo4j.
the class BoltConnectorValidator method getSettingFor.
@Override
@Nonnull
protected Optional<Setting<Object>> getSettingFor(@Nonnull String settingName, @Nonnull Map<String, String> params) {
// owns has already verified that 'type' is correct and that this split is possible
String[] parts = settingName.split("\\.");
final String name = parts[2];
final String subsetting = parts[3];
BaseSetting setting;
switch(subsetting) {
case "enabled":
setting = setting(settingName, BOOLEAN, "false");
setting.setDescription("Enable this connector.");
break;
case "type":
setting = setting(settingName, options(Connector.ConnectorType.class), NO_DEFAULT);
setting.setDeprecated(true);
setting.setDescription("Connector type. This setting is deprecated and its value will instead be " + "inferred from the name of the connector.");
break;
case "tls_level":
setting = setting(settingName, options(BoltConnector.EncryptionLevel.class), OPTIONAL.name());
setting.setDescription("Encryption level to require this connector to use.");
break;
case "address":
setting = listenAddress(settingName, 7687);
setting.setDeprecated(true);
setting.setReplacement("dbms.connector." + name + ".listen_address");
setting.setDescription("Address the connector should bind to. Deprecated and replaced by " + setting.replacement().get() + ".");
break;
case "listen_address":
setting = listenAddress(settingName, 7687);
setting.setDescription("Address the connector should bind to.");
break;
case "advertised_address":
setting = advertisedAddress(settingName, listenAddress(settingName, 7687));
setting.setDescription("Advertised address for this connector.");
break;
default:
return Optional.empty();
}
// If not deprecated for other reasons
if (isDeprecatedConnectorName(name) && !setting.deprecated()) {
setting.setDeprecated(true);
setting.setReplacement(format("%s.%s.%s.%s", parts[0], parts[1], "bolt", subsetting));
}
return Optional.of(setting);
}
Aggregations