Home Identifier Source Repository
import Vo from 'piggy-module/src/Vo.js'
public class | source

Vo

Value Object

Static Member Summary

Static Public Members
public static get

Get the primary key name

Static Method Summary

Static Public Methods
public static

Check if a Vo property exists, else throw an Error

public static

Get a list of all the properies of the Vo

public static

Get all configuration of a property

public static

Get the default value of a property according to config

public static

Get the type of a property according to config

public static

hasProperty(property: String): boolean

Check if a Vo property exists

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public

data: *

public get

dto: Object: *

Get the cleaned dto

public get

id: String: *

Get the id as string

public get

Is the object unsaved (exist in storage but has changed) ?

public get

Is the object new (not saved) ?

public get

Is the object saved in storage ?

public get

Status (from Vo.STATUS values: 'new', 'changed' or 'saved')

public set

status(value: any): *

To make sure status cannot be access in public

Method Summary

Public Methods
public

castVoPropertyValue(key: String, value: any): any

Cast a Vo property and return property well formated

public

get(key: string, defaultValue: any): any

Property getter

public

resetData(): self

Reset all vo data

public

set(key: string, value: any): self

Property setter

public

setData(data: Object): self

Multi property setting

Protected Methods
protected

statusChangeTrigger(previousStatus: String, newStatus: String)

Method triggered when status change.

Static Public Members

public static get primaryKey: String: * source

Get the primary key name

Return:

String

Static Public Methods

public static assumePropertyExists(property: String) source

Check if a Vo property exists, else throw an Error

Params:

NameTypeAttributeDescription
property String

the property name

public static getPropertiesNames(): String[] source

Get a list of all the properies of the Vo

Return:

String[]

public static getPropertyConfig(property: String): Object source

Get all configuration of a property

Params:

NameTypeAttributeDescription
property String

the property name

Return:

Object

public static getPropertyDefault(property: String): String source

Get the default value of a property according to config

Params:

NameTypeAttributeDescription
property String

the property name

Return:

String

public static getPropertyType(property: String): String source

Get the type of a property according to config

Params:

NameTypeAttributeDescription
property String

the property name

Return:

String

public static hasProperty(property: String): boolean source

Check if a Vo property exists

Params:

NameTypeAttributeDescription
property String

the property name

Return:

boolean

Public Constructors

public constructor(data: Object) source

Params:

NameTypeAttributeDescription
data Object

the object data

Public Members

public data: * source

public get dto: Object: * source

Get the cleaned dto

Return:

Object

public get id: String: * source

Get the id as string

Return:

String

public get isChanged: Boolean: * source

Is the object unsaved (exist in storage but has changed) ?

Return:

Boolean

public get isNew: Boolean: * source

Is the object new (not saved) ?

Return:

Boolean

public get isSaved: Boolean: * source

Is the object saved in storage ?

Return:

Boolean

public get status: String: * source

Status (from Vo.STATUS values: 'new', 'changed' or 'saved')

Return:

String

public set status(value: any): * source

To make sure status cannot be access in public

Public Methods

public castVoPropertyValue(key: String, value: any): any source

Cast a Vo property and return property well formated

Params:

NameTypeAttributeDescription
key String

the property name

value any

the property value to cast

Return:

any

the cast property

public get(key: string, defaultValue: any): any source

Property getter

Params:

NameTypeAttributeDescription
key string

the property name

defaultValue any
  • nullable: true

the default value if the property is not set

Return:

any

public resetData(): self source

Reset all vo data

Return:

self

public set(key: string, value: any): self source

Property setter

Params:

NameTypeAttributeDescription
key string

the property name

value any

the value to assign

Return:

self

public setData(data: Object): self source

Multi property setting

Params:

NameTypeAttributeDescription
data Object

associated key value object

Return:

self

Protected Methods

protected statusChangeTrigger(previousStatus: String, newStatus: String) source

Method triggered when status change. To override by custom one

Params:

NameTypeAttributeDescription
previousStatus String

the old status (one of the Vo.STATUS)

newStatus String

the new status (one of the Vo.STATUS)