generator-begcode
Version:
Spring Boot + Angular/React/Vue in one handy generator
32 lines (31 loc) • 1.11 kB
JavaScript
import AbstractJDLOption from './abstract-jdl-option.js';
import BinaryOptions from '../jhipster/binary-options.js';
import { join } from '../utils/set-utils.js';
export default class JDLBinaryOption extends AbstractJDLOption {
value;
constructor(args) {
super(args);
if (typeof args.value !== 'string') {
throw new Error('A binary option must have a value.');
}
this.value = args.value;
}
getType() {
return 'BINARY';
}
toString() {
const entityNames = join(this.entityNames, ', ');
entityNames.slice(1, entityNames.length - 1);
let optionName = this.name;
if (this.name === BinaryOptions.Options.PAGINATION) {
optionName = 'paginate';
}
const firstPart = `${optionName} ${entityNames} with ${this.value}`;
if (this.excludedNames.size === 0) {
return firstPart;
}
const excludedNames = join(this.excludedNames, ', ');
excludedNames.slice(1, this.excludedNames.size - 1);
return `${firstPart} except ${excludedNames}`;
}
}