public Tag unmarshall(StaxUnmarshallerContext context) throws Exception { Tag tag = new Tag(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return tag; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("Key", targetDepth)) { tag.setKey(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("Value", targetDepth)) { tag.setValue(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return tag; } } } }
/** * <p> * <i>Required</i>. A string used to identify this tag. You can specify a maximum of 128 characters for a tag key. * Tags owned by Amazon Web Services (AWS) have the reserved prefix: <code>aws:</code>. * </p> * * @param key * <i>Required</i>. A string used to identify this tag. You can specify a maximum of 128 characters for a tag * key. Tags owned by Amazon Web Services (AWS) have the reserved prefix: <code>aws:</code>. * @return Returns a reference to this object so that method calls can be chained together. */ public Tag withKey(String key) { setKey(key); return this; }
/** * <p> * <i>Required</i>. A string used to identify this tag. You can specify a maximum of 128 characters for a tag key. * Tags owned by Amazon Web Services (AWS) have the reserved prefix: <code>aws:</code>. * </p> * * @param key * <i>Required</i>. A string used to identify this tag. You can specify a maximum of 128 characters for a tag * key. Tags owned by Amazon Web Services (AWS) have the reserved prefix: <code>aws:</code>. * @return Returns a reference to this object so that method calls can be chained together. */ public Tag withKey(String key) { setKey(key); return this; }
public static Collection<Tag> parseTags(InputStream is) throws IOException { ObjectMapper mapper = new ObjectMapper(); JsonNode tree = mapper.readTree(is); ArrayNode jsonNodes = (ArrayNode) tree; return StreamSupport.stream(jsonNodes.spliterator(), false) .map(node -> { return new Tag() .withKey(node.get("Key").asText()) .withValue(node.get("Value").asText()); }) .collect(Collectors.toList()); } }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof Tag == false) return false; Tag other = (Tag) obj; if (other.getKey() == null ^ this.getKey() == null) return false; if (other.getKey() != null && other.getKey().equals(this.getKey()) == false) return false; if (other.getValue() == null ^ this.getValue() == null) return false; if (other.getValue() != null && other.getValue().equals(this.getValue()) == false) return false; return true; }
public Tag unmarshall(StaxUnmarshallerContext context) throws Exception { Tag tag = new Tag(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return tag; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("Key", targetDepth)) { tag.setKey(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("Value", targetDepth)) { tag.setValue(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return tag; } } } }
protected final Collection<Tag> getAwsTags(StepExecution stepExecution) { Collection<Tag> tagList = new ArrayList<>(); if (this.tags != null) { for (String tag : this.tags) { int i = tag.indexOf('='); if (i < 0) { throw new IllegalArgumentException("Missing = in tag " + tag); } String key = tag.substring(0, i); String value = tag.substring(i + 1); tagList.add(new Tag().withKey(key).withValue(value)); } } if (this.tagsFile != null) { FilePath tagsFile = loadFileFromWorkspace(stepExecution, this.tagsFile); try { tagList.addAll(TagsFileParser.parseTags(tagsFile.read())); } catch (IOException e) { throw new UncheckedIOException(e); } catch (InterruptedException e) { Thread.interrupted(); throw new RuntimeException(e); } } return tagList; }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getKey() != null) sb.append("Key: ").append(getKey()).append(","); if (getValue() != null) sb.append("Value: ").append(getValue()); sb.append("}"); return sb.toString(); }
.collect(Collectors.toList())); task.conventionMapping("cfnStackTags", () -> cfnExt.getStackTags().entrySet().stream() .map(it -> new Tag() .withKey(it.getKey().toString()) .withValue(it.getValue().toString())) .collect(Collectors.toList())); task.conventionMapping("cfnTemplateUrl", () -> cfnExt.getTemplateURL()); .collect(Collectors.toList())); task.conventionMapping("cfnStackTags", () -> cfnExt.getStackTags().entrySet().stream() .map(it -> new Tag() .withKey(it.getKey().toString()) .withValue(it.getValue().toString())) .collect(Collectors.toList())); task.conventionMapping("cfnTemplateUrl", () -> cfnExt.getTemplateURL());
if (tagsListValue.getKey() != null) { request.addParameter("Tags.member." + tagsListIndex + ".Key", StringUtils.fromString(tagsListValue.getKey())); if (tagsListValue.getValue() != null) { request.addParameter("Tags.member." + tagsListIndex + ".Value", StringUtils.fromString(tagsListValue.getValue()));
if (tagsListValue.getKey() != null) { request.addParameter("Tags.member." + tagsListIndex + ".Key", StringUtils.fromString(tagsListValue.getKey())); if (tagsListValue.getValue() != null) { request.addParameter("Tags.member." + tagsListIndex + ".Value", StringUtils.fromString(tagsListValue.getValue()));
if (tagsListValue.getKey() != null) { request.addParameter("Tags.member." + tagsListIndex + ".Key", StringUtils.fromString(tagsListValue.getKey())); if (tagsListValue.getValue() != null) { request.addParameter("Tags.member." + tagsListIndex + ".Value", StringUtils.fromString(tagsListValue.getValue()));
if (tagsListValue.getKey() != null) { request.addParameter("Tags.member." + tagsListIndex + ".Key", StringUtils.fromString(tagsListValue.getKey())); if (tagsListValue.getValue() != null) { request.addParameter("Tags.member." + tagsListIndex + ".Value", StringUtils.fromString(tagsListValue.getValue()));
if (tagsListValue.getKey() != null) { request.addParameter("Tags.member." + tagsListIndex + ".Key", StringUtils.fromString(tagsListValue.getKey())); if (tagsListValue.getValue() != null) { request.addParameter("Tags.member." + tagsListIndex + ".Value", StringUtils.fromString(tagsListValue.getValue()));
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof Tag == false) return false; Tag other = (Tag) obj; if (other.getKey() == null ^ this.getKey() == null) return false; if (other.getKey() != null && other.getKey().equals(this.getKey()) == false) return false; if (other.getValue() == null ^ this.getValue() == null) return false; if (other.getValue() != null && other.getValue().equals(this.getValue()) == false) return false; return true; }