![JAR search and dependency download from the Maven repository](/logo.png)
io.micronaut.cli.config.CodeGenConfig.groovy Maven / Gradle / Ivy
/*
* Copyright 2017-2019 original authors
*
* 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 io.micronaut.cli.config
import groovy.transform.Canonical
import groovy.transform.CompileDynamic
import groovy.transform.CompileStatic
import org.codehaus.groovy.runtime.DefaultGroovyMethods
import org.codehaus.groovy.runtime.typehandling.GroovyCastException
import org.yaml.snakeyaml.Yaml
/**
* A {@link ConfigMap} implementation used at codegen time
*
* @author Lari Hotari
* @author Graeme Rocher
*
* @since 1.0
*/
@CompileStatic
@Canonical
class CodeGenConfig implements Cloneable, ConfigMap {
final NavigableMap configMap
CodeGenConfig() {
configMap = new NavigableMap()
}
CodeGenConfig(CodeGenConfig copyOf) {
this((Map) copyOf.configMap)
}
CodeGenConfig(Map copyOf) {
this()
mergeMap(copyOf)
}
CodeGenConfig clone() {
new CodeGenConfig(this)
}
@Override
int size() {
configMap.size()
}
@Override
boolean isEmpty() {
configMap.isEmpty()
}
@Override
boolean containsKey(Object key) {
configMap.containsKey(key)
}
@Override
boolean containsValue(Object value) {
configMap.containsValue(value)
}
@Override
Object get(Object key) {
configMap.get(key)
}
@Override
Object put(String key, Object value) {
configMap.put(key, value)
}
@Override
Object remove(Object key) {
throw new UnsupportedOperationException("Config cannot be mutated")
}
@Override
void putAll(Map extends String, ?> m) {
throw new UnsupportedOperationException("Config cannot be mutated")
}
@Override
void clear() {
throw new UnsupportedOperationException("Config cannot be mutated")
}
@Override
Set keySet() {
return configMap.keySet()
}
@Override
Collection
© 2015 - 2025 Weber Informatics LLC | Privacy Policy