31 lines
756 B
TypeScript
31 lines
756 B
TypeScript
|
export const TYPE_PROPERTY_KEY = '@class';
|
||
|
|
||
|
export class ResourceIdentification {
|
||
|
|
||
|
public type: string;
|
||
|
public mandatoryProperties: Set<string>;
|
||
|
public instances: any[];
|
||
|
|
||
|
private first = true;
|
||
|
|
||
|
constructor(type: string) {
|
||
|
this.type = type;
|
||
|
this.mandatoryProperties = new Set<string>();
|
||
|
this.instances = new Array<any>();
|
||
|
}
|
||
|
|
||
|
public add(facet: any) {
|
||
|
if (this.first) {
|
||
|
for (const propertyKey in facet) {
|
||
|
if (propertyKey.localeCompare(TYPE_PROPERTY_KEY) === 0) {
|
||
|
continue;
|
||
|
}
|
||
|
this.mandatoryProperties.add(propertyKey);
|
||
|
}
|
||
|
this.first = false;
|
||
|
}
|
||
|
this.instances.push(facet);
|
||
|
}
|
||
|
|
||
|
}
|