Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Ninthless committed Jan 31, 2024
0 parents commit 90947ab
Show file tree
Hide file tree
Showing 56 changed files with 7,136 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
### IntelliJ IDEA ###
out/
!**/src/main/**/out/
!**/src/test/**/out/

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/artifacts/Configurate.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/libraries/libs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Configurate.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="libs" level="project" />
</component>
</module>
Binary file added libs/annotations-18.0.0.jar
Binary file not shown.
Binary file added libs/checker-3.1.0.jar
Binary file not shown.
Binary file added libs/config-1.3.1.jar
Binary file not shown.
Binary file added libs/fastutil-8.3.0.jar
Binary file not shown.
Binary file added libs/guava-17.0.jar
Binary file not shown.
10 changes: 10 additions & 0 deletions src/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Class-Path: guava-17.0.jar config-1.3.1.jar checker-3.1.0.jar fastutil-8
.3.0.jar annotations-18.0.0.jar
Implementation-Title: Configurate
Implementation-Version: 0.1
Implementation-Vendor: cn.c9
Specification-Title: Configurate API
Specification-Version: 0.1
Specification-Vendor: cn.c9
Build-Date: 2024-01-30
Created-By: 1.8.0_291 (Oracle Corporation)
116 changes: 116 additions & 0 deletions src/ninja/leaping/configurate/ConfigValue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/*
* Configurate
* Copyright (C) zml and Configurate contributors
*
* 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 ninja.leaping.configurate;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;

import java.util.Iterator;

/**
* The value in a {@link ConfigurationNode}.
*/
abstract class ConfigValue {

/**
* The node this value "belongs" to.
*/
@NonNull
protected final SimpleConfigurationNode holder;

protected ConfigValue(@NonNull SimpleConfigurationNode holder) {
this.holder = holder;
}

abstract ValueType getType();

/**
* Gets the value encapsulated by this instance
*
* @return The value
*/
@Nullable
abstract Object getValue();

/**
* Sets the value encapsulated by this instance
*
* @param value The value
*/
abstract void setValue(@Nullable Object value);

/**
* Put a child value, or null to remove value at that key
*
* @param key The key
* @param value The node to put at key
* @return Existing node at key, if present
*/
@Nullable
abstract SimpleConfigurationNode putChild(@NonNull Object key, @Nullable SimpleConfigurationNode value);

/**
* Put a child value, if one isn't already present at that key
*
* @param key The key
* @param value The node to put at key
* @return Existing node at key, if present
*/
@Nullable
abstract SimpleConfigurationNode putChildIfAbsent(@NonNull Object key, @Nullable SimpleConfigurationNode value);

/**
* Gets the currently present child for the given key. Returns null if no child is present
*
* @param key The key to get child at
* @return The child if any
*/
@Nullable
abstract SimpleConfigurationNode getChild(@Nullable Object key);

/**
* Returns an iterable over all child nodes
*
* @return An iterator
*/
@NonNull
abstract Iterable<SimpleConfigurationNode> iterateChildren();

/**
* Creates a copy of this node
*
* @return A copy
*/
@NonNull
abstract ConfigValue copy(@NonNull SimpleConfigurationNode holder);

/**
* Clears the set value (or any attached child values) from this value
*/
void clear() {
for (Iterator<SimpleConfigurationNode> it = iterateChildren().iterator(); it.hasNext(); ) {
SimpleConfigurationNode node = it.next();
node.attached = false;
it.remove();
if (node.getParentEnsureAttached().equals(holder)) {
node.clear();
}
}
}

}
Loading

0 comments on commit 90947ab

Please sign in to comment.