-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Roberto Cortez <[email protected]>
- Loading branch information
Showing
8 changed files
with
460 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,11 +88,14 @@ | |
* then its {@linkplain AutoCloseable#close() close method} will be called when | ||
* the underlying configuration is released. | ||
* | ||
* @deprecated use the newer api {@link ConfigValueSource} which exposes a {@link ConfigValue} accessor style object. | ||
* | ||
* @author <a href="mailto:[email protected]">Mark Struberg</a> | ||
* @author <a href="mailto:[email protected]">Gerhard Petracek</a> | ||
* @author <a href="mailto:[email protected]">Emily Jiang</a> | ||
* @author <a href="mailto:[email protected]">John D. Ament</a> | ||
*/ | ||
@Deprecated | ||
public interface ConfigSource { | ||
/** | ||
* The name of the configuration ordinal property, "{@code config_ordinal}". | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,11 +41,13 @@ | |
* {@linkplain ClassLoader#getResource(String) resource} which contains | ||
* the fully qualified class name of the custom {@code ConfigSourceProvider} implementation. | ||
* | ||
* @deprecated use the newer api {@link ConfigValueSourceProvider}. | ||
* | ||
* @author <a href="mailto:[email protected]">Mark Struberg</a> | ||
* @author <a href="mailto:[email protected]">Gerhard Petracek</a> | ||
* @author <a href="mailto:[email protected]">Emily Jiang</a> | ||
* | ||
*/ | ||
@Deprecated | ||
public interface ConfigSourceProvider { | ||
|
||
/** | ||
|
161 changes: 161 additions & 0 deletions
161
api/src/main/java/org/eclipse/microprofile/config/spi/ConfigValue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
/* | ||
* Copyright (c) 2020 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* You may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
package org.eclipse.microprofile.config.spi; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* The ConfigValue is a metadata object that holds additional information after the lookup of a configuration. | ||
* <p> | ||
* | ||
* Right now, it is able to hold information like the configuration name, value, the Config Source from where | ||
* the configuration was loaded, the ordinal of the Config Source and a line number from where the configuration was | ||
* read if exists. | ||
* <p> | ||
* | ||
* This is used together with {@link ConfigValueSource} to expose the Configuration lookup metadata. | ||
* | ||
* @author <a href="mailto:[email protected]">Roberto Cortez</a> | ||
*/ | ||
public class ConfigValue { | ||
private final String name; | ||
private final String value; | ||
private final String configSourceName; | ||
private final int configSourceOrdinal; | ||
|
||
private final int lineNumber; | ||
|
||
private ConfigValue(final ConfigValueBuilder builder) { | ||
this.name = builder.name; | ||
this.value = builder.value; | ||
this.configSourceName = builder.configSourceName; | ||
this.configSourceOrdinal = builder.configSourceOrdinal; | ||
this.lineNumber = builder.lineNumber; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
|
||
public String getConfigSourceName() { | ||
return configSourceName; | ||
} | ||
|
||
public int getConfigSourceOrdinal() { | ||
return configSourceOrdinal; | ||
} | ||
|
||
public int getLineNumber() { | ||
return lineNumber; | ||
} | ||
|
||
public ConfigValue withName(final String name) { | ||
return from().withName(name).build(); | ||
} | ||
|
||
public ConfigValue withValue(final String value) { | ||
return from().withValue(value).build(); | ||
} | ||
|
||
public ConfigValue withConfigSourceName(final String configSourceName) { | ||
return from().withConfigSourceName(configSourceName).build(); | ||
} | ||
|
||
public ConfigValue withConfigSourceOrdinal(final int configSourceOrdinal) { | ||
return from().withConfigSourceOrdinal(configSourceOrdinal).build(); | ||
} | ||
|
||
public ConfigValue withLineNumber(final int lineNumber) { | ||
return from().withLineNumber(lineNumber).build(); | ||
} | ||
|
||
@Override | ||
public boolean equals(final Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
final ConfigValue that = (ConfigValue) o; | ||
return name.equals(that.name) && | ||
value.equals(that.value) && | ||
configSourceName.equals(that.configSourceName); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(name, value, configSourceName); | ||
} | ||
|
||
ConfigValueBuilder from() { | ||
return new ConfigValueBuilder() | ||
.withName(name) | ||
.withValue(value) | ||
.withConfigSourceName(configSourceName) | ||
.withConfigSourceOrdinal(configSourceOrdinal) | ||
.withLineNumber(lineNumber); | ||
} | ||
|
||
public static ConfigValueBuilder builder() { | ||
return new ConfigValueBuilder(); | ||
} | ||
|
||
public static class ConfigValueBuilder { | ||
private String name; | ||
private String value; | ||
private String configSourceName; | ||
private int configSourceOrdinal; | ||
private int lineNumber = -1; | ||
|
||
public ConfigValueBuilder withName(final String name) { | ||
this.name = name; | ||
return this; | ||
} | ||
|
||
public ConfigValueBuilder withValue(final String value) { | ||
this.value = value; | ||
return this; | ||
} | ||
|
||
public ConfigValueBuilder withConfigSourceName(final String configSourceName) { | ||
this.configSourceName = configSourceName; | ||
return this; | ||
} | ||
|
||
public ConfigValueBuilder withConfigSourceOrdinal(final int configSourceOrdinal) { | ||
this.configSourceOrdinal = configSourceOrdinal; | ||
return this; | ||
} | ||
|
||
public ConfigValueBuilder withLineNumber(final int lineNumber) { | ||
this.lineNumber = lineNumber; | ||
return this; | ||
} | ||
|
||
public ConfigValue build() { | ||
return new ConfigValue(this); | ||
} | ||
} | ||
} |
Oops, something went wrong.