1 package org.kuali.common.aws.ec2.impl;
2
3 import org.kuali.common.aws.ec2.api.EC2Service;
4 import org.kuali.common.aws.ec2.model.InstanceStateName;
5 import org.kuali.common.util.Assert;
6 import org.kuali.common.util.condition.Condition;
7
8
9
10
11
12 public final class IsOnlineCondition implements Condition {
13
14 public IsOnlineCondition(EC2Service service, String instanceId) {
15 Assert.noNulls(service);
16 Assert.noBlanks(instanceId);
17 this.running = new InstanceStateCondition(service, instanceId, InstanceStateName.RUNNING);
18 this.reachable = new IsReachableCondition(service, instanceId);
19 }
20
21 private final Condition running;
22 private final Condition reachable;
23
24 @Override
25 public boolean isTrue() {
26 return running.isTrue() && reachable.isTrue();
27 }
28
29 public Condition getRunning() {
30 return running;
31 }
32
33 public Condition getReachable() {
34 return reachable;
35 }
36
37 }