Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge pull request #70 from abayer/jenkins-40337-mk2
[JENKINS-40337] Add Declarative-specific options.
- Loading branch information
Showing
32 changed files
with
639 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 0 additions & 95 deletions
95
...c/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTJobProperties.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
...api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package org.jenkinsci.plugins.pipeline.modeldefinition.ast; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import net.sf.json.JSONArray; | ||
import net.sf.json.JSONObject; | ||
import org.jenkinsci.plugins.pipeline.modeldefinition.validator.ModelValidator; | ||
|
||
/** | ||
* A container for one or more {@link ModelASTOption}s | ||
* | ||
* @author Andrew Bayer | ||
*/ | ||
public final class ModelASTOptions extends ModelASTElement { | ||
private List<ModelASTOption> options = new ArrayList<ModelASTOption>(); | ||
|
||
public ModelASTOptions(Object sourceLocation) { | ||
super(sourceLocation); | ||
} | ||
|
||
@Override | ||
public JSONObject toJSON() { | ||
final JSONArray a = new JSONArray(); | ||
for (ModelASTOption option : options) { | ||
a.add(option.toJSON()); | ||
} | ||
return new JSONObject().accumulate("options", a); | ||
} | ||
|
||
@Override | ||
public void validate(final ModelValidator validator) { | ||
validator.validateElement(this); | ||
for (ModelASTOption option : options) { | ||
option.validate(validator); | ||
} | ||
} | ||
|
||
@Override | ||
public String toGroovy() { | ||
StringBuilder result = new StringBuilder("options {\n"); | ||
for (ModelASTOption option : options) { | ||
result.append(option.toGroovy()).append("\n"); | ||
} | ||
result.append("}\n"); | ||
return result.toString(); | ||
} | ||
|
||
@Override | ||
public void removeSourceLocation() { | ||
super.removeSourceLocation(); | ||
for (ModelASTOption option : options) { | ||
option.removeSourceLocation(); | ||
} | ||
} | ||
|
||
public List<ModelASTOption> getOptions() { | ||
return options; | ||
} | ||
|
||
public void setOptions(List<ModelASTOption> options) { | ||
this.options = options; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ModelASTOptions{" + | ||
"options=" + options + | ||
"}"; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
if (!super.equals(o)) { | ||
return false; | ||
} | ||
|
||
ModelASTOptions that = (ModelASTOptions) o; | ||
|
||
return getOptions() != null ? getOptions().equals(that.getOptions()) : that.getOptions() == null; | ||
|
||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = super.hashCode(); | ||
result = 31 * result + (getOptions() != null ? getOptions().hashCode() : 0); | ||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.