Class ModelASTValue
- java.lang.Object
-
- org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTElement
-
- org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTValue
-
- All Implemented Interfaces:
ModelASTEnvironmentValue
,ModelASTMarkerInterface
,ModelASTMethodArg
public abstract class ModelASTValue extends ModelASTElement implements ModelASTMethodArg, ModelASTEnvironmentValue
Represents the value in a key/value pair, as used inModelASTEnvironment
,ModelASTNamedArgumentList
and elsewhere.- Author:
- Andrew Bayer, Kohsuke Kawaguchi
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
static ModelASTValue
fromConstant(Object o, Object sourceLocation)
static ModelASTValue
fromGString(String gstring, Object sourceLocation)
Object
getValue()
Returns a value or an expression that represents this value.int
hashCode()
abstract boolean
isLiteral()
If the value can be determined without side-effect at AST parsing time, this method returns true, andgetValue()
returns its value.net.sf.json.JSONObject
toJSON()
Translates this element and any children it may have into JSON conforming to the schema.String
toString()
void
validate(ModelValidator validator)
Called to do whatever validation is necessary for this element.-
Methods inherited from class org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTElement
getSourceLocation, nullIfEmpty, removeSourceLocation, removeSourceLocationsFrom, removeSourceLocationsFrom, removeSourceLocationsFrom, removeSourceLocationsFrom, setSourceLocation, toGroovy, toGroovy, toGroovy, toGroovyArgList, toGroovyArgList, toGroovyBlock, toGroovyBlock, toGroovyBlock, toGroovyCheckEmpty, toJSON, toJSONArray, toJSONArray, toJSONCheckEmpty, toJSONObject, validate, validate, validate
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTMarkerInterface
removeSourceLocation, toGroovy
-
-
-
-
Method Detail
-
isLiteral
public abstract boolean isLiteral()
If the value can be determined without side-effect at AST parsing time, this method returns true, andgetValue()
returns its value.- Returns:
true
if the value can be determined without side-effects at AST parsing time.
-
getValue
public Object getValue()
Returns a value or an expression that represents this value. This model is used at the compile time, so it's not always possible to obtain the actual value. Imagine something likesecret('12345')
or evenpow(2,10)
. In case the value is an expression, this method returns a string represntation suitable for the editor. For example, if the value isfoobar(x)
, we want the editor to show "${foobar(x)}"- Returns:
- returens the value or an expression that represents this value.
-
validate
public void validate(@NonNull ModelValidator validator)
Description copied from class:ModelASTElement
Called to do whatever validation is necessary for this element. Overridden in most cases.- Specified by:
validate
in interfaceModelASTMarkerInterface
- Overrides:
validate
in classModelASTElement
- Parameters:
validator
- AModelValidator
to use for more complicated validation.
-
toJSON
@NonNull public net.sf.json.JSONObject toJSON()
Description copied from class:ModelASTElement
Translates this element and any children it may have into JSON conforming to the schema.- Specified by:
toJSON
in interfaceModelASTMarkerInterface
- Specified by:
toJSON
in classModelASTElement
- Returns:
- Generally a
JSONObject
orJSONArray
but for some leaf nodes, may be aString
or other simple class.
-
equals
public boolean equals(Object o)
Description copied from class:ModelASTElement
- Overrides:
equals
in classModelASTElement
-
hashCode
public int hashCode()
Description copied from class:ModelASTElement
- Overrides:
hashCode
in classModelASTElement
-
toString
public String toString()
Description copied from class:ModelASTElement
- Overrides:
toString
in classModelASTElement
-
fromConstant
public static ModelASTValue fromConstant(Object o, Object sourceLocation)
-
fromGString
public static ModelASTValue fromGString(String gstring, Object sourceLocation)
-
-