java.lang.Object
org.htmlunit.corejs.javascript.ClassDescriptor.Builder
- Enclosing class:
- ClassDescriptor
A builder for creating class descriptors. Usually created during static initialisation
methods can be added before finally calling
build() to create the final
descriptor.-
Constructor Summary
ConstructorsConstructorDescriptionBuilder(String name, int length, ClassDescriptor.BuiltInJSCodeExec<JSFunction> ctor) Create a builder for a constructor with the standard attributes for a built in EcmaScript class that can only be called as a constructor.Builder(String name, int length, ClassDescriptor.BuiltInJSCodeExec<JSFunction> ctor, int ctorAttrs, int protoAttrs) Create a builder for a constructor with non-standard attributes that can only be called as a constructor.Builder(String name, int length, ClassDescriptor.BuiltInJSCodeExec<JSFunction> call, ClassDescriptor.BuiltInJSCodeExec<JSFunction> construct) Create a builder for a constructor with the standard attributes for a built in EcmaScript class that can be called as either a constructor of as a functio., which may have different behaviours.Builder(String name, int length, ClassDescriptor.BuiltInJSCodeExec<JSFunction> call, ClassDescriptor.BuiltInJSCodeExec<JSFunction> construct, int ctorAttrs, int protoAttrs) Create a builder for a constructor with the standard attributes that can be called as either a constructor of as a functio., which may have different behaviours.Builder(SymbolKey name, int length, ClassDescriptor.BuiltInJSCodeExec<JSFunction> ctor) Builder(SymbolKey name, int length, ClassDescriptor.BuiltInJSCodeExec<JSFunction> call, ClassDescriptor.BuiltInJSCodeExec<JSFunction> construct) Builder(SymbolKey name, int length, ClassDescriptor.BuiltInJSCodeExec<JSFunction> call, ClassDescriptor.BuiltInJSCodeExec<JSFunction> construct, int ctorAttrs, int protoAttrs) Builder(SymbolKey name, String ctorName, int length, ClassDescriptor.BuiltInJSCodeExec<JSFunction> call, ClassDescriptor.BuiltInJSCodeExec<JSFunction> construct) Builder(SymbolKey name, String ctorName, int length, ClassDescriptor.BuiltInJSCodeExec<JSFunction> call, ClassDescriptor.BuiltInJSCodeExec<JSFunction> construct, int ctorAttrs, int protoAttrs) -
Method Summary
Modifier and TypeMethodDescriptionstatic ClassDescriptor.ValueCreatorConvenience method to create an alias of the orignally named slot with the specified attributes.static ClassDescriptor.ValueCreatorConvenience method to create an alias of the orignally named slot.build()static ClassDescriptor.ValueCreatorConvenience method to create a slot with the specified value.static ClassDescriptor.ValueCreatorConvenience method to create a slot with the specified value and attributes.withMethod(ClassDescriptor.Destination dest, String name, int length, ClassDescriptor.BuiltInJSCodeExec<JSFunction> code) Adds a method on the constructor with the standard property attributes for a method on a built in constructor.withMethod(ClassDescriptor.Destination dest, String name, int length, ClassDescriptor.BuiltInJSCodeExec<JSFunction> code, int attributes, int stdAttrs) Adds a method on the constructor with the custom property attributes.withMethod(ClassDescriptor.Destination dest, SymbolKey name, int length, ClassDescriptor.BuiltInJSCodeExec<JSFunction> code) Adds a method on the constructor with the standard property attributes for a method on a built in constructor.withMethod(ClassDescriptor.Destination dest, SymbolKey name, int length, ClassDescriptor.BuiltInJSCodeExec<JSFunction> code, int attributes, int stdAttrs) Adds a method on the constructor with the custom property attributes.<T extends ScriptableObject>
ClassDescriptor.BuilderwithProp(ClassDescriptor.Destination dest, String name, BuiltInSlot.Getter<T> getter, BuiltInSlot.Setter<T> setter, int attributes) withProp(ClassDescriptor.Destination dest, String name, ClassDescriptor.ValueCreator creator) Version ofwithProp(Destination, String, LambdaGetterFunction, LambdaSetterFunction, int)that takes aClassDescriptor.ValueCreatorrather than a getter and setter.withProp(ClassDescriptor.Destination dest, String name, ScriptableObject.LambdaGetterFunction getter, ScriptableObject.LambdaSetterFunction setter, int attributes) Adds an accessor based property to the constructor or prototype with custom property attributes.<T extends ScriptableObject>
ClassDescriptor.BuilderwithProp(ClassDescriptor.Destination dest, SymbolKey name, BuiltInSlot.Getter<T> getter, BuiltInSlot.Setter<T> setter, int attributes) withProp(ClassDescriptor.Destination dest, SymbolKey name, ClassDescriptor.ValueCreator creator) Version ofwithProp(Destination, SymbolKey, LambdaGetterFunction, LambdaSetterFunction, int)that takes aClassDescriptor.ValueCreatorrather than a getter and setter.withProp(ClassDescriptor.Destination dest, SymbolKey name, ScriptableObject.LambdaGetterFunction getter, ScriptableObject.LambdaSetterFunction setter, int attributes) Version ofwithProp(Destination, String, LambdaGetterFunction, LambdaSetterFunction, int)that takes aSymbolKeyas the name.
-
Constructor Details
-
Builder
-
Builder
-
Builder
Create a builder for a constructor with the standard attributes for a built in EcmaScript class that can only be called as a constructor.- Parameters:
name- the constructor's namelength- the constructor's length propertyctor- should usually be a static method reference that can be cast as aJSCodeExec<JSFunction>
-
Builder
-
Builder
public Builder(String name, int length, ClassDescriptor.BuiltInJSCodeExec<JSFunction> ctor, int ctorAttrs, int protoAttrs) Create a builder for a constructor with non-standard attributes that can only be called as a constructor.- Parameters:
name- the constructor's namelength- the constructor's length propertyctor- should usually be a static method reference that can be cast as aJSCodeExec<JSFunction>ctorAttrs- the attributes for the constructor property in its owning scopeprotoAttrs- the attributes for the constructor's prototype property
-
Builder
public Builder(String name, int length, ClassDescriptor.BuiltInJSCodeExec<JSFunction> call, ClassDescriptor.BuiltInJSCodeExec<JSFunction> construct) Create a builder for a constructor with the standard attributes for a built in EcmaScript class that can be called as either a constructor of as a functio., which may have different behaviours.- Parameters:
name- the constructor's namelength- the constructor's length propertycall- should usually be a static method reference that can be cast as aJSCodeExec<JSFunction>. This is what will be executed if the constructor is used as a normal function.construct- should usually be a static method reference that can be cast as aJSCodeExec<JSFunction>This is what will be executed if the constructor is used as a constructor.
-
Builder
public Builder(SymbolKey name, int length, ClassDescriptor.BuiltInJSCodeExec<JSFunction> call, ClassDescriptor.BuiltInJSCodeExec<JSFunction> construct) -
Builder
public Builder(SymbolKey name, String ctorName, int length, ClassDescriptor.BuiltInJSCodeExec<JSFunction> call, ClassDescriptor.BuiltInJSCodeExec<JSFunction> construct) -
Builder
public Builder(String name, int length, ClassDescriptor.BuiltInJSCodeExec<JSFunction> call, ClassDescriptor.BuiltInJSCodeExec<JSFunction> construct, int ctorAttrs, int protoAttrs) Create a builder for a constructor with the standard attributes that can be called as either a constructor of as a functio., which may have different behaviours.- Parameters:
name- the constructor's namelength- the constructor's length propertycall- should usually be a static method reference that can be cast as aJSCodeExec<JSFunction>. This is what will be executed if the constructor is used as a normal function.construct- should usually be a static method reference that can be cast as aJSCodeExec<JSFunction>This is what will be executed if the constructor is used as a constructor.ctorAttrs- the attributes for the constructor property in its owning scopeprotoAttrs- the attributes for the constructor's prototype property
-
Builder
public Builder(SymbolKey name, int length, ClassDescriptor.BuiltInJSCodeExec<JSFunction> call, ClassDescriptor.BuiltInJSCodeExec<JSFunction> construct, int ctorAttrs, int protoAttrs) -
Builder
public Builder(SymbolKey name, String ctorName, int length, ClassDescriptor.BuiltInJSCodeExec<JSFunction> call, ClassDescriptor.BuiltInJSCodeExec<JSFunction> construct, int ctorAttrs, int protoAttrs)
-
-
Method Details
-
withMethod
public ClassDescriptor.Builder withMethod(ClassDescriptor.Destination dest, SymbolKey name, int length, ClassDescriptor.BuiltInJSCodeExec<JSFunction> code) Adds a method on the constructor with the standard property attributes for a method on a built in constructor.- Parameters:
name- the method's name. The symbol will be used as the method's key in the owning scope, and text of that symbol will be used as the method's name.length- the method's length propertycode- should usually be a static method reference that can be cast as aJSCodeExec<JSFunction>. This is what will be executed when the method is called.- Returns:
- this
ClassDescriptor.Builder
-
withMethod
public ClassDescriptor.Builder withMethod(ClassDescriptor.Destination dest, SymbolKey name, int length, ClassDescriptor.BuiltInJSCodeExec<JSFunction> code, int attributes, int stdAttrs) Adds a method on the constructor with the custom property attributes.- Parameters:
name- the method's name. The symbol will be used as the method's key in the owning scope, and text of that symbol will be used as the method's name.length- the method's length propertycode- should usually be a static method reference that can be cast as aJSCodeExec<JSFunction>. This is what will be executed when the method is called.attributes- the attributes for the method's property on the constructorstdAttrs- the attributes for the method's standard properties- Returns:
- this
ClassDescriptor.Builder
-
withMethod
public ClassDescriptor.Builder withMethod(ClassDescriptor.Destination dest, String name, int length, ClassDescriptor.BuiltInJSCodeExec<JSFunction> code) Adds a method on the constructor with the standard property attributes for a method on a built in constructor.- Parameters:
name- the method's name.length- the method's length propertycode- should usually be a static method reference that can be cast as aJSCodeExec<JSFunction>. This is what will be executed when the method is called.- Returns:
- this
ClassDescriptor.Builder
-
withMethod
public ClassDescriptor.Builder withMethod(ClassDescriptor.Destination dest, String name, int length, ClassDescriptor.BuiltInJSCodeExec<JSFunction> code, int attributes, int stdAttrs) Adds a method on the constructor with the custom property attributes.- Parameters:
name- the method's name.length- the method's length propertycode- should usually be a static method reference that can be cast as aJSCodeExec<JSFunction>. This is what will be executed when the method is called.attributes- the attributes for the method's property on the constructorstdAttrs- the attributes for the method's standard properties- Returns:
- this
ClassDescriptor.Builder
-
withProp
public ClassDescriptor.Builder withProp(ClassDescriptor.Destination dest, String name, ScriptableObject.LambdaGetterFunction getter, ScriptableObject.LambdaSetterFunction setter, int attributes) Adds an accessor based property to the constructor or prototype with custom property attributes.- Parameters:
dest- destination for this propertyname- the property's name.getter- should usually be a static method reference that can be cast as aScriptableObject.LambdaSetterFunction. This is what will be executed when the property is set..attributes- the attributes for the property on the prototype- Returns:
- this
ClassDescriptor.Builder
-
withProp
public ClassDescriptor.Builder withProp(ClassDescriptor.Destination dest, SymbolKey name, ScriptableObject.LambdaGetterFunction getter, ScriptableObject.LambdaSetterFunction setter, int attributes) Version ofwithProp(Destination, String, LambdaGetterFunction, LambdaSetterFunction, int)that takes aSymbolKeyas the name. -
withProp
public <T extends ScriptableObject> ClassDescriptor.Builder withProp(ClassDescriptor.Destination dest, String name, BuiltInSlot.Getter<T> getter, BuiltInSlot.Setter<T> setter, int attributes) -
withProp
public <T extends ScriptableObject> ClassDescriptor.Builder withProp(ClassDescriptor.Destination dest, SymbolKey name, BuiltInSlot.Getter<T> getter, BuiltInSlot.Setter<T> setter, int attributes) -
withProp
public ClassDescriptor.Builder withProp(ClassDescriptor.Destination dest, String name, ClassDescriptor.ValueCreator creator) Version ofwithProp(Destination, String, LambdaGetterFunction, LambdaSetterFunction, int)that takes aClassDescriptor.ValueCreatorrather than a getter and setter. -
withProp
public ClassDescriptor.Builder withProp(ClassDescriptor.Destination dest, SymbolKey name, ClassDescriptor.ValueCreator creator) Version ofwithProp(Destination, SymbolKey, LambdaGetterFunction, LambdaSetterFunction, int)that takes aClassDescriptor.ValueCreatorrather than a getter and setter. -
alias
Convenience method to create an alias of the orignally named slot with the specified attributes. -
aliss
Convenience method to create an alias of the orignally named slot. -
value
Convenience method to create a slot with the specified value and attributes. This should only be used for simply values such as strings, symbols, and numbers which remain truly constant between contexts. -
value
Convenience method to create a slot with the specified value. This should only be used for simply values such as strings, symbols, and numbers which remain truly constant between contexts. -
build
-