com.powsybl.afs.ProjectFileExtension Maven / Gradle / Ivy
/**
* Copyright (c) 2017, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package com.powsybl.afs;
/**
* Interface to add a new type of project file to the application file system.
*
*
* In order to add a new type of project file to your {@link AppData} instance,
* you need to implement that interface and declare it to the runtime using the
* {@link com.google.auto.service.AutoService} annotation.
*
*
* The instance needs to define the new class, a name identifying that class ("pseudo class"),
* and to provide a builder object to create an actual instance of the new class. For instance:
*
*
* {@literal @}AutoService(ProjectFileExtension.class)
* public class FooFileExtension implements ProjectFileExtension {
*
* {@literal @}Override
* public Class getProjectFileClass() {
* return FooFile.class;
* }
*
* {@literal @}Override
* public String getProjectFilePseudoClass() {
* return "foo";
* }
*
* {@literal @}Override
* public Class getProjectFileBuilderClass() {
* return FooFileBuilder.class;
* }
*
* {@literal @}Override
* public FooFile createProjectFile(ProjectFileCreationContext context) {
* return new FooFile(context);
* }
*
* {@literal @}Override
* public FooFileBuilder createProjectFileBuilder(ProjectFileBuildContext context) {
* return new FooFileBuilder(context);
* }
* }
*
*
* @author Geoffroy Jamgotchian
*/
public interface ProjectFileExtension> {
/**
* The new project file type to be injected.
*/
Class getProjectFileClass();
/**
* A "pseudo class" name for the new type.
*/
String getProjectFilePseudoClass();
/**
* The builder class for the new type. Builders will be in charge of creating actual instances of the new type.
*/
Class getProjectFileBuilderClass();
/**
* Creates an object with default constructor.
*/
T createProjectFile(ProjectFileCreationContext context);
/**
* Creates a builder object, to build an instance of the new type with additional parameters passed to the builder.
*/
ProjectFileBuilder createProjectFileBuilder(ProjectFileBuildContext context);
}