io.inverno.mod.configuration.AbstractConfigurableConfigurationSource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of inverno-configuration Show documentation
Show all versions of inverno-configuration Show documentation
Inverno configuration module
/*
* Copyright 2020 Jeremy KUHN
*
* 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.inverno.mod.configuration;
import java.util.Objects;
import io.inverno.mod.base.converter.JoinablePrimitiveEncoder;
import io.inverno.mod.base.converter.SplittablePrimitiveDecoder;
/**
*
* Base implementation for {@link ConfigurableConfigurationSource}.
*
*
*
* Implementors must rely on the encoder and decoder provided in this implementation to respectively store and retrieve configuration values in/from the configuration source.
*
*
* @author Jeremy Kuhn
* @since 1.0
*
* @see ConfigurableConfigurationSource
* @see ConfigurationQuery
* @see ExecutableConfigurationQuery
* @see ConfigurationQueryResult
* @see ConfigurationUpdate
* @see ExecutableConfigurationUpdate
* @see ConfigurationUpdateResult
*
* @param source specific query type
* @param source specific executable query type
* @param source specific list query type
* @param source specific update type
* @param source specific executable update type
* @param raw configuration value type
*/
public abstract class AbstractConfigurableConfigurationSource, B extends ExecutableConfigurationQuery, C extends ListConfigurationQuery, D extends ConfigurationUpdate, E extends ExecutableConfigurationUpdate, F>
extends AbstractConfigurationSource implements ConfigurableConfigurationSource {
/**
* The data encoder to use to encode configuration data into the data source.
*/
protected JoinablePrimitiveEncoder encoder;
/**
*
* Creates a configurable configuration source with the specified encoder and decoder.
*
*
* @param encoder a joinable primitive encoder
* @param decoder a splittable primitive decoder
*
* @throws NullPointerException if one of the specified decoder or encoder is null
*/
public AbstractConfigurableConfigurationSource(JoinablePrimitiveEncoder encoder, SplittablePrimitiveDecoder decoder) {
super(decoder);
this.setEncoder(encoder);
}
/**
*
* Returns the configuration value encoder.
*
*
* @return a joinable primitive encoder
*/
public JoinablePrimitiveEncoder getEncoder() {
return encoder;
}
/**
*
* Sets the configuration value encoder.
*
*
* @param encoder a joinable primitive encoder
*
* @throws NullPointerException if the specified encoder is null
*/
public void setEncoder(JoinablePrimitiveEncoder encoder) {
Objects.requireNonNull(encoder, "Value encoder can't be null");
this.encoder = encoder;
}
}