/** * <p> * Any tags assigned to the instance. * </p> * * @param tags * Any tags assigned to the instance. * @return Returns a reference to this object so that method calls can be chained together. */ public Instance withTags(java.util.Collection<Tag> tags) { setTags(tags); return this; }
/** * <p> * Any tags assigned to the instance. * </p> * <p> * <b>NOTE:</b> This method appends the values to the existing list (if any). Use * {@link #setTags(java.util.Collection)} or {@link #withTags(java.util.Collection)} if you want to override the * existing values. * </p> * * @param tags * Any tags assigned to the instance. * @return Returns a reference to this object so that method calls can be chained together. */ public Instance withTags(Tag... tags) { if (this.tags == null) { setTags(new com.amazonaws.internal.SdkInternalList<Tag>(tags.length)); } for (Tag ele : tags) { this.tags.add(ele); } return this; }
new Tag("project", project) ); i.setTags(tags); }); recentlyRequestedWorkers.put(graphId, System.currentTimeMillis());
/** * Any tags assigned to the instance. * <p> * Returns a reference to this object so that method calls can be chained together. * * @param tags Any tags assigned to the instance. * * @return A reference to this updated object so that method calls can be chained * together. */ public Instance withTags(Tag... tags) { if (getTags() == null) setTags(new java.util.ArrayList<Tag>(tags.length)); for (Tag value : tags) { getTags().add(value); } return this; }
/** * <p> * Any tags assigned to the instance. * </p> * * @param tags * Any tags assigned to the instance. * @return Returns a reference to this object so that method calls can be chained together. */ public Instance withTags(java.util.Collection<Tag> tags) { setTags(tags); return this; }
/** * <p> * Any tags assigned to the instance. * </p> * <p> * <b>NOTE:</b> This method appends the values to the existing list (if any). Use * {@link #setTags(java.util.Collection)} or {@link #withTags(java.util.Collection)} if you want to override the * existing values. * </p> * * @param tags * Any tags assigned to the instance. * @return Returns a reference to this object so that method calls can be chained together. */ public Instance withTags(Tag... tags) { if (this.tags == null) { setTags(new com.amazonaws.internal.SdkInternalList<Tag>(tags.length)); } for (Tag ele : tags) { this.tags.add(ele); } return this; }
@Test public void testEc2Instance() throws IOException { Instance instance = new Instance(); instance.setInstanceId("i-123456"); instance.setTags(Lists.newArrayList(new Tag("foo", "bar"), new Tag("fizz", "buzz"))); JsonNode n = new JsonConverter().toJson(instance); Assertions.assertThat(n.path("aws_instanceId").asText()).isEqualTo("i-123456"); Assertions.assertThat(n.path("aws_tag_foo").asText()).isEqualTo("bar"); Assertions.assertThat(n.path("aws_tag_fizz").asText()).isEqualTo("buzz"); logger.info("{}", mapper.writerWithDefaultPrettyPrinter().writeValueAsString(n)); }
@Test public void testIt() throws JsonProcessingException { EC2InstanceScanner scanner = getProjector().createBuilder(AWSScannerBuilder.class).withAccountId("111222333444") .build(EC2InstanceScanner.class); Instance test = new Instance(); test.setInstanceId("i-123456789012"); test.setImageId("ami-01010101"); Tag tag = new Tag("foo", "bar"); Tag tag2 = new Tag("fizz", "buzz"); test.setTags(Lists.newArrayList(tag, tag2)); ObjectNode n = scanner.convertAwsObject(test, Region.getRegion(Regions.US_WEST_2)); System.out.println(new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(n)); Assertions.assertThat(n.path("aws_region").asText()).isEqualTo("us-west-2"); Assertions.assertThat(n.path("aws_account").asText()).isEqualTo("111222333444"); Assertions.assertThat(n.path("aws_arn").asText()) .isEqualTo("arn:aws:ec2:us-west-2:111222333444:instance/i-123456789012"); Assertions.assertThat(n.path("aws_imageId").asText()).isEqualTo("ami-01010101"); Assertions.assertThat(n.path("aws_tag_foo").asText()).isEqualTo("bar"); Assertions.assertThat(n.path("aws_tag_fizz").asText()).isEqualTo("buzz"); }
inst.setTags(inst_tags);