1 /*
2 * Copyright (C) 2010, Google Inc. and others
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Distribution License v. 1.0 which is available at
6 * https://www.eclipse.org/org/documents/edl-v10.php.
7 *
8 * SPDX-License-Identifier: BSD-3-Clause
9 */
10
11 package org.eclipse.jgit.lib;
12
13 import java.io.IOException;
14
15 import org.eclipse.jgit.errors.ConfigInvalidException;
16
17 /**
18 * Persistent configuration that can be stored and loaded from a location.
19 */
20 public abstract class StoredConfig extends Config {
21 /**
22 * Create a configuration with no default fallback.
23 */
24 public StoredConfig() {
25 super();
26 }
27
28 /**
29 * Create an empty configuration with a fallback for missing keys.
30 *
31 * @param defaultConfig
32 * the base configuration to be consulted when a key is missing
33 * from this configuration instance.
34 */
35 public StoredConfig(Config defaultConfig) {
36 super(defaultConfig);
37 }
38
39 /**
40 * Load the configuration from the persistent store.
41 * <p>
42 * If the configuration does not exist, this configuration is cleared, and
43 * thus behaves the same as though the backing store exists, but is empty.
44 *
45 * @throws java.io.IOException
46 * the configuration could not be read (but does exist).
47 * @throws org.eclipse.jgit.errors.ConfigInvalidException
48 * the configuration is not properly formatted.
49 */
50 public abstract void load() throws IOException, ConfigInvalidException;
51
52 /**
53 * Save the configuration to the persistent store.
54 *
55 * @throws java.io.IOException
56 * the configuration could not be written.
57 */
58 public abstract void save() throws IOException;
59
60 /** {@inheritDoc} */
61 @Override
62 public void clear() {
63 super.clear();
64 }
65 }