1 package org.kuali.common.aws.ec2.impl;
2
3 import static org.kuali.common.util.base.Precondition.checkNotBlank;
4 import static org.kuali.common.util.base.Precondition.checkNotNull;
5
6 import org.kuali.common.aws.ec2.api.EC2Service;
7 import org.kuali.common.util.condition.Condition;
8
9 import com.amazonaws.services.ec2.model.Image;
10
11
12
13
14 public final class AmiStateCondition implements Condition {
15
16 public AmiStateCondition(EC2Service service, String imageId, String state) {
17 this.service = checkNotNull(service, "service");
18 this.imageId = checkNotBlank(imageId, "imageId");
19 this.state = checkNotBlank(state, "state");
20 }
21
22 private final EC2Service service;
23 private final String imageId;
24 private final String state;
25
26 @Override
27 public boolean isTrue() {
28 Image image = service.getImage(imageId);
29 return this.state.equals(image.getState());
30 }
31
32 }