mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-03-05 11:50:58 +01:00
Rename getCreationContext to oneByType and make the implementation more robust
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
package sonia.scm.repository;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
@@ -97,8 +97,12 @@ public class RepositoryInitializer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Optional<T> getCreationContext(String key, Class<T> type) {
|
||||
return Optional.of(mapper.convertValue(creationContext.get(key), type));
|
||||
public <T> Optional<T> oneByType(String key, Class<T> type) {
|
||||
JsonNode node = creationContext.get(key);
|
||||
if (node != null) {
|
||||
return Optional.of(mapper.convertValue(node, type));
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user