blob: 93ec620a97cefbe4c805e5f3c28a8d6e17bd11fc [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.ignite.configuration;
import org.apache.ignite.configuration.annotation.ConfigurationRoot;
import org.apache.ignite.configuration.annotation.ConfigurationType;
/**
* Configuration root selector.
*
* @param <T> Type of the configuration tree described by the root key.
* @param <VIEW> Type of the immutable snapshot view associated with the tree.
*/
public class RootKey<T extends ConfigurationTree<VIEW, ?>, VIEW> {
/**
* Name of the configuration root.
*/
private final String rootName;
/**
* Configuration type of the root.
*/
private final ConfigurationType storageType;
/**
* Schema class for the root.
*/
private final Class<?> schemaClass;
/**
* Constructor.
*
* @param schemaClass Class of the configuration schema.
*/
public RootKey(Class<?> schemaClass) {
this.schemaClass = schemaClass;
ConfigurationRoot rootAnnotation = schemaClass.getAnnotation(ConfigurationRoot.class);
assert rootAnnotation != null;
this.rootName = rootAnnotation.rootName();
this.storageType = rootAnnotation.type();
}
/**
* Returns the name of the configuration root.
*
* @return Name of the configuration root.
*/
public String key() {
return rootName;
}
/**
* Returns the configuration type of the root.
*
* @return Configuration type of the root.
*/
public ConfigurationType type() {
return storageType;
}
/**
* Returns the schema class for the root.
*
* @return Schema class for the root.
*/
public Class<?> schemaClass() {
return schemaClass;
}
}