@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; } ModelASTValue that = (ModelASTValue) o; return getValue() != null ? getValue().equals(that.getValue()) : that.getValue() == null; }
@Override public Map<String,?> argListToMap() { List<Object> argList = new ArrayList<>(); for (ModelASTValue v : arguments) { argList.add(v.getValue()); } return Collections.singletonMap(UninstantiatedDescribable.ANONYMOUS_KEY, argList); }
@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; } ModelASTValue that = (ModelASTValue) o; return getValue() != null ? getValue().equals(that.getValue()) : that.getValue() == null; }
@Override public Map<String,?> argListToMap() { List<Object> argList = new ArrayList<>(); for (ModelASTValue v : arguments) { argList.add(v.getValue()); } return Collections.singletonMap(UninstantiatedDescribable.ANONYMOUS_KEY, argList); }
@Override public Map<String,?> argListToMap() { Map<String,Object> m = new LinkedHashMap<>(); for (Map.Entry<ModelASTKey,ModelASTValue> entry : arguments.entrySet()) { m.put(entry.getKey().getKey(), entry.getValue().getValue()); } return m; }
@Override public Map<String,?> argListToMap() { Map<String,Object> m = new LinkedHashMap<>(); for (Map.Entry<ModelASTKey,ModelASTValue> entry : arguments.entrySet()) { m.put(entry.getKey().getKey(), entry.getValue().getValue()); } return m; }
@Override public Map<String,?> argListToMap() { return Collections.singletonMap(UninstantiatedDescribable.ANONYMOUS_KEY, getValue().getValue()); }
@Override public Map<String,?> argListToMap() { return Collections.singletonMap(UninstantiatedDescribable.ANONYMOUS_KEY, getValue().getValue()); }
private String getPatternArgument(ModelASTArgumentList args) { if (args instanceof ModelASTSingleArgument) { return (String) ((ModelASTSingleArgument) args).getValue().getValue(); } else if (args instanceof ModelASTPositionalArgumentList) { final List<ModelASTValue> arguments = ((ModelASTPositionalArgumentList) args).getArguments(); if (!arguments.isEmpty()) { return (String) arguments.get(0).getValue(); } } else if (args instanceof ModelASTNamedArgumentList) { return (String) ((ModelASTNamedArgumentList) args).argListToMap().get("pattern"); } return null; } }
private boolean isEmptyStringLabelAgent() { if (agentType.getKey().equals("label") || agentType.getKey().equals("node")) { if (variables instanceof ModelASTValue && "".equals(((ModelASTValue) variables).getValue())) { return true; } if (variables instanceof ModelASTClosureMap) { Map<ModelASTKey, ModelASTMethodArg> vars = ((ModelASTClosureMap) variables).getVariables(); // Don't actually switch to "agent any" if there are any additional options besides the label. if (vars.size() == 1) { for (Map.Entry<ModelASTKey,ModelASTMethodArg> entry : vars.entrySet()) { if (entry.getKey().getKey().equals("label")) { ModelASTMethodArg argValue = entry.getValue(); if (argValue instanceof ModelASTValue && ((ModelASTValue) argValue).getValue().equals("")) { return true; } } } } } } return false; }
public String codeBlockAsString() { if (getArgs() == null) { return null; } else if (isLiteralSingleArg()) { Object v = getSingleValue().getValue(); if (v instanceof String) { List<String> retList = new ArrayList<>(); for (String s : v.toString().split("\\r?\\n")) { retList.add(s.trim()); } return StringUtils.join(retList, "\n"); } else { return v.toString(); } } else { return getArgs().toGroovy(); } }
public String codeBlockAsString() { if (getArgs() == null) { return null; } else if (isLiteralSingleArg()) { Object v = getSingleValue().getValue(); if (v instanceof String) { List<String> retList = new ArrayList<>(); for (String s : v.toString().split("\\r?\\n")) { retList.add(s.trim()); } return StringUtils.join(retList, "\n"); } else { return v.toString(); } } else { return getArgs().toGroovy(); } }
@Override @CheckForNull public String validateElement(@Nonnull ModelASTOption option, @CheckForNull FlowExecution execution) { if (option.getName() != null && option.getName().equals("preserveStashes")) { for (ModelASTMethodArg arg : option.getArgs()) { if (arg instanceof ModelASTKeyValueOrMethodCallPair) { ModelASTKeyValueOrMethodCallPair namedArg = (ModelASTKeyValueOrMethodCallPair)arg; if (namedArg.getKey().getKey().equals("buildCount")) { if (namedArg.getValue() instanceof ModelASTValue && ((ModelASTValue)namedArg.getValue()).getValue() instanceof Integer) { Integer v = (Integer)((ModelASTValue)namedArg.getValue()).getValue(); if (v < 1 || v > MAX_SAVED_STASHES) { return Messages.PreserveStashesJobProperty_ValidatorImpl_InvalidBuildCount(MAX_SAVED_STASHES); } } } } } } return null; } }
@Override public JSONObject toJSON() { return new JSONObject() .accumulate("isLiteral", isLiteral()) .accumulate("value", getValue()); }
@Override public JSONObject toJSON() { return new JSONObject() .accumulate("isLiteral", isLiteral()) .accumulate("value", getValue()); }
Object realVal = val.getValue();
assertEquals("First branch", val.getValue());