@accordproject/concerto-core
Version:
Core Implementation for the Concerto Modeling Language
197 lines (196 loc) • 6.67 kB
TypeScript
import Declaration = require('./declaration');
/**
* ClassDeclaration defines the structure (model/schema) of composite data.
* It is composed of a set of Properties, may have an identifying field, and may
* have a super-type.
* A ClassDeclaration is conceptually owned by a ModelFile which
* defines all the classes that are part of a namespace.
*
* @abstract
* @class
* @memberof module:concerto-core
*/
declare class ClassDeclaration extends Declaration {
modelFile: any;
/**
* Process the AST and build the model
*
* @throws {IllegalModelException}
* @private
*/
process(): void;
/**
* Adds a required field named 'timestamp' of type 'DateTime' if this class declaration has the 'concerto.Concept'
* super type.
* This method should only be called by system code.
* @private
*/
addTimestampField(): void;
/**
* Adds a required field named '$identifier' of type 'String'
* This method should only be called by system code.
* @private
*/
addIdentifierField(): void;
/**
* Resolve the super type on this class and store it as an internal property.
* @return {ClassDeclaration} The super type, or null if non specified.
*/
_resolveSuperType(): any;
/**
* Semantic validation of the structure of this class. Subclasses should
* override this method to impose additional semantic constraints on the
* contents/relations of fields.
*
* @throws {IllegalModelException}
* @protected
*/
validate(): void;
/**
* Returns true if this class is declared as abstract in the model file
*
* @return {boolean} true if the class is abstract
*/
isAbstract(): any;
/**
* Returns true if this class declaration declares an identifying field
* (system or explicit)
* @returns {Boolean} true if the class declaration includes an identifier
*/
isIdentified(): boolean;
/**
* Returns true if this class declaration declares a system identifier
* $identifier
* @returns {Boolean} true if the class declaration includes a system identifier
*/
isSystemIdentified(): boolean;
/**
* Returns true if this class declaration declares an explicit identifier
* @returns {Boolean} true if the class declaration includes an explicit identifier
*/
isExplicitlyIdentified(): boolean;
/**
* Returns the name of the identifying field for this class. Note
* that the identifying field may come from a super type.
*
* @return {string} the name of the id field for this class or null if it does not exist
*/
getIdentifierFieldName(): any;
/**
* Returns the field with a given name or null if it does not exist.
* The field must be directly owned by this class -- the super-type is
* not introspected.
*
* @param {string} name the name of the field
* @return {Property} the field definition or null if it does not exist
*/
getOwnProperty(name: any): any;
/**
* Returns the fields directly defined by this class.
*
* @return {Property[]} the array of fields
*/
getOwnProperties(): any;
/**
* Returns the FQN of the super type for this class or null if this
* class does not have a super type.
*
* @return {string} the FQN name of the super type or null
*/
getSuperType(): any;
/**
* Get the super type class declaration for this class.
* @return {ClassDeclaration} the super type declaration, or null if there is no super type.
*/
getSuperTypeDeclaration(): any;
/**
* Get the class declarations for all subclasses of this class, including this class.
* @return {ClassDeclaration[]} subclass declarations.
*/
getAssignableClassDeclarations(): any[];
/**
* Get the class declarations for just the direct subclasses of this class, excluding this class.
* @return {ClassDeclaration[]} direct subclass declarations.
*/
getDirectSubclasses(): unknown[];
/**
* Get all the super-type declarations for this type.
* @return {ClassDeclaration[]} super-type declarations.
*/
getAllSuperTypeDeclarations(): any[];
/**
* Returns the property with a given name or null if it does not exist.
* Fields defined in super-types are also introspected.
*
* @param {string} name the name of the field
* @return {Property} the field, or null if it does not exist
*/
getProperty(name: any): any;
/**
* Returns the properties defined in this class and all super classes.
*
* @return {Property[]} the array of fields
*/
getProperties(): any;
/**
* Get a nested property using a dotted property path
* @param {string} propertyPath The property name or name with nested structure e.g a.b.c
* @returns {Property} the property
* @throws {IllegalModelException} if the property path is invalid or the property does not exist
*/
getNestedProperty(propertyPath: any): any;
/**
* Returns the string representation of this class
* @return {String} the string representation of the class
*/
toString(): string;
/**
* Returns true if this class is the definition of an asset.
*
* @return {boolean} true if the class is an asset
*/
isAsset(): boolean;
/**
* Returns true if this class is the definition of a participant.
*
* @return {boolean} true if the class is an asset
*/
isParticipant(): boolean;
/**
* Returns true if this class is the definition of a transaction.
*
* @return {boolean} true if the class is an asset
*/
isTransaction(): boolean;
/**
* Returns true if this class is the definition of an event.
*
* @return {boolean} true if the class is an asset
*/
isEvent(): boolean;
/**
* Returns true if this class is the definition of a concept.
*
* @return {boolean} true if the class is an asset
*/
isConcept(): boolean;
/**
* Returns true if this class is the definition of a enum.
*
* @return {boolean} true if the class is an asset
*/
isEnum(): boolean;
/**
* Returns true if this class is the definition of a map.
*
* @return {boolean} true if the class is an asset
*/
isMapDeclaration(): boolean;
/**
* Returns true if this class is the definition of a enum.
*
* @return {boolean} true if the class is an asset
*/
isClassDeclaration(): boolean;
}
export = ClassDeclaration;