mirror of https://github.com/apache/jclouds.git
removed invalid @Nullable usage and also usage of javax package usage
This commit is contained in:
parent
9981eee038
commit
c7f35d3bb1
|
@ -24,7 +24,6 @@ import static com.google.common.base.Preconditions.checkState;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
@ -68,7 +67,7 @@ public class BindCloneDriveOptionsToPlainTextString implements MapBinder {
|
|||
|
||||
request.setPayload(listOfMapsToListOfKeyValuesDelimitedByBlankLines.apply(ImmutableSet.of(Maps.transformValues(postParams, new Function<Object, String>() {
|
||||
@Override
|
||||
public String apply(@Nullable Object input) {
|
||||
public String apply(Object input) {
|
||||
return input == null ? null : input.toString();
|
||||
}
|
||||
}))));
|
||||
|
|
|
@ -27,7 +27,6 @@ import static org.jclouds.util.InetAddresses2.isPrivateIPAddress;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
|
@ -153,12 +152,12 @@ public class VirtualMachineToNodeMetadata implements Function<VirtualMachine, No
|
|||
filter(getIPForwardingRulesByVirtualMachine.getUnchecked(from.getId()),
|
||||
new Predicate<IPForwardingRule>() {
|
||||
@Override
|
||||
public boolean apply(@Nullable IPForwardingRule rule) {
|
||||
public boolean apply(IPForwardingRule rule) {
|
||||
return !"Deleting".equals(rule.getState());
|
||||
}
|
||||
}), new Function<IPForwardingRule, String>() {
|
||||
@Override
|
||||
public String apply(@Nullable IPForwardingRule rule) {
|
||||
public String apply(IPForwardingRule rule) {
|
||||
return rule.getIPAddress();
|
||||
}
|
||||
}));
|
||||
|
|
|
@ -20,8 +20,6 @@ package org.jclouds.cloudstack.predicates;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.cloudstack.domain.GuestIPType;
|
||||
import org.jclouds.cloudstack.domain.Network;
|
||||
import org.jclouds.cloudstack.domain.NetworkService;
|
||||
|
@ -163,7 +161,7 @@ public class NetworkPredicates {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(@Nullable GuestIPType guestIPType) {
|
||||
public boolean apply(GuestIPType guestIPType) {
|
||||
return guestIPType == this.guestIPType;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,8 +26,6 @@ import static org.testng.Assert.assertTrue;
|
|||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.cloudstack.domain.AsyncCreateResponse;
|
||||
import org.jclouds.cloudstack.domain.FirewallRule;
|
||||
import org.jclouds.cloudstack.domain.Network;
|
||||
|
@ -69,7 +67,7 @@ public class FirewallClientLiveTest extends BaseCloudStackClientLiveTest {
|
|||
network = find(client.getNetworkClient().listNetworks(), Predicates.and(supportsPortForwarding(),
|
||||
new Predicate<Network>() {
|
||||
@Override
|
||||
public boolean apply(@Nullable Network network) {
|
||||
public boolean apply(Network network) {
|
||||
return network.isDefault()
|
||||
&& !network.isSecurityGroupEnabled()
|
||||
&& network.getAccount().equals(user.getAccount());
|
||||
|
|
|
@ -24,8 +24,6 @@ import static org.testng.Assert.assertEquals;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.cloudstack.domain.ConfigurationEntry;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackClientLiveTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
@ -97,7 +95,7 @@ public class GlobalConfigurationClientLiveTest extends BaseCloudStackClientLiveT
|
|||
private ConfigurationEntry getEntryByName(Set<ConfigurationEntry> entries, final String name) {
|
||||
return Iterables.find(entries, new Predicate<ConfigurationEntry>() {
|
||||
@Override
|
||||
public boolean apply(@Nullable ConfigurationEntry entry) {
|
||||
public boolean apply(ConfigurationEntry entry) {
|
||||
return entry != null && Objects.equal(name, entry.getName());
|
||||
}
|
||||
});
|
||||
|
|
|
@ -23,8 +23,6 @@ import static org.jclouds.cloudstack.options.UpdateDomainOptions.Builder.name;
|
|||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.cloudstack.domain.Domain;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackClientLiveTest;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
|
@ -48,7 +46,7 @@ public class GlobalDomainClientLiveTest extends BaseCloudStackClientLiveTest {
|
|||
domainClient = globalAdminClient.getDomainClient();
|
||||
rootDomain = find(domainClient.listDomains(), new Predicate<Domain>() {
|
||||
@Override
|
||||
public boolean apply(@Nullable Domain domain) {
|
||||
public boolean apply(Domain domain) {
|
||||
return domain != null && domain.getName().equals("ROOT");
|
||||
}
|
||||
});
|
||||
|
|
|
@ -30,8 +30,6 @@ import java.util.NoSuchElementException;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.cloudstack.domain.AsyncJob;
|
||||
import org.jclouds.cloudstack.domain.JobResult;
|
||||
import org.jclouds.cloudstack.domain.LoadBalancerRule;
|
||||
|
@ -78,7 +76,7 @@ public class LoadBalancerClientLiveTest extends BaseCloudStackClientLiveTest {
|
|||
Predicates.and(hasLoadBalancerService(), isVirtualNetwork(),
|
||||
new Predicate<Network>() {
|
||||
@Override
|
||||
public boolean apply(@Nullable Network network) {
|
||||
public boolean apply(Network network) {
|
||||
return network.isDefault()
|
||||
&& !network.isSecurityGroupEnabled()
|
||||
&& !network.isSystem()
|
||||
|
|
|
@ -27,8 +27,6 @@ import java.net.URI;
|
|||
import java.net.URLDecoder;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.cloudstack.domain.AsyncCreateResponse;
|
||||
import org.jclouds.cloudstack.domain.AsyncJob;
|
||||
import org.jclouds.cloudstack.domain.ExtractMode;
|
||||
|
@ -107,7 +105,7 @@ public class TemplateClientLiveTest extends BaseCloudStackClientLiveTest {
|
|||
Iterable<Network> networks = client.getNetworkClient().listNetworks(ListNetworksOptions.Builder.zoneId(zone.getId()).isDefault(true));
|
||||
networks = Iterables.filter(networks, new Predicate<Network>() {
|
||||
@Override
|
||||
public boolean apply(@Nullable Network network) {
|
||||
public boolean apply(Network network) {
|
||||
return network != null && network.getState().equals("Implemented");
|
||||
}
|
||||
});
|
||||
|
@ -160,7 +158,7 @@ public class TemplateClientLiveTest extends BaseCloudStackClientLiveTest {
|
|||
Iterable<Network> networks = client.getNetworkClient().listNetworks(ListNetworksOptions.Builder.zoneId(zone.getId()).isDefault(true));
|
||||
networks = Iterables.filter(networks, new Predicate<Network>() {
|
||||
@Override
|
||||
public boolean apply(@Nullable Network network) {
|
||||
public boolean apply(Network network) {
|
||||
return network != null && network.getName().equals("Virtual Network");
|
||||
}
|
||||
});
|
||||
|
@ -181,7 +179,7 @@ public class TemplateClientLiveTest extends BaseCloudStackClientLiveTest {
|
|||
final String zoneId = zone.getId();
|
||||
Predicate<Template> templateReadyPredicate = new Predicate<Template>() {
|
||||
@Override
|
||||
public boolean apply(@Nullable Template template) {
|
||||
public boolean apply(Template template) {
|
||||
if (template == null) return false;
|
||||
Template t2 = client.getTemplateClient().getTemplateInZone(template.getId(), zoneId);
|
||||
Logger.CONSOLE.info("%s", t2.getStatus());
|
||||
|
|
|
@ -34,8 +34,6 @@ import java.util.Set;
|
|||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.cloudstack.CloudStackClient;
|
||||
import org.jclouds.cloudstack.domain.AsyncCreateResponse;
|
||||
import org.jclouds.cloudstack.domain.AsyncJob;
|
||||
|
@ -94,7 +92,7 @@ public class VirtualMachineClientLiveTest extends BaseCloudStackClientLiveTest {
|
|||
if (networks.size() > 0) {
|
||||
Network network = get(filter(networks, new Predicate<Network>() {
|
||||
@Override
|
||||
public boolean apply(@Nullable Network network) {
|
||||
public boolean apply(Network network) {
|
||||
return network != null && network.getState().equals("Implemented");
|
||||
}
|
||||
}), 0);
|
||||
|
@ -143,7 +141,7 @@ public class VirtualMachineClientLiveTest extends BaseCloudStackClientLiveTest {
|
|||
String zoneId = getFirst(networks, null).getZoneId();
|
||||
options.networkIds(Iterables.transform(networks, new Function<Network, String>() {
|
||||
@Override
|
||||
public String apply(@Nullable Network network) {
|
||||
public String apply(Network network) {
|
||||
return network.getId();
|
||||
}
|
||||
}));
|
||||
|
@ -240,7 +238,7 @@ public class VirtualMachineClientLiveTest extends BaseCloudStackClientLiveTest {
|
|||
Network requiredNetwork = getOnlyElement(filter(adminClient.getNetworkClient().listNetworks(
|
||||
ListNetworksOptions.Builder.zoneId(template.getZoneId())), new Predicate<Network>() {
|
||||
@Override
|
||||
public boolean apply(@Nullable Network network) {
|
||||
public boolean apply(Network network) {
|
||||
return network.isDefault() &&
|
||||
network.getGuestIPType() == GuestIPType.VIRTUAL;
|
||||
}
|
||||
|
|
|
@ -26,8 +26,6 @@ import static org.testng.Assert.assertEquals;
|
|||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.cloudstack.domain.IPForwardingRule;
|
||||
import org.jclouds.cloudstack.domain.Network;
|
||||
import org.jclouds.cloudstack.domain.PublicIPAddress;
|
||||
|
@ -96,7 +94,7 @@ public class StaticNATVirtualMachineInNetworkLiveTest extends NATClientLiveTest
|
|||
rule = getOnlyElement(filter(client.getNATClient().getIPForwardingRulesForIPAddress(ip.getId()),
|
||||
new Predicate<IPForwardingRule>() {
|
||||
@Override
|
||||
public boolean apply(@Nullable IPForwardingRule rule) {
|
||||
public boolean apply(IPForwardingRule rule) {
|
||||
return rule != null && rule.getStartPort() == 22;
|
||||
}
|
||||
}));
|
||||
|
|
|
@ -20,8 +20,6 @@ package org.jclouds.ec2;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.ec2.features.WindowsAsyncApi;
|
||||
import org.jclouds.ec2.services.AMIAsyncClient;
|
||||
import org.jclouds.ec2.services.AvailabilityZoneAndRegionAsyncClient;
|
||||
|
@ -31,6 +29,7 @@ import org.jclouds.ec2.services.InstanceAsyncClient;
|
|||
import org.jclouds.ec2.services.KeyPairAsyncClient;
|
||||
import org.jclouds.ec2.services.SecurityGroupAsyncClient;
|
||||
import org.jclouds.ec2.services.WindowsAsyncClient;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.location.Region;
|
||||
import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
|
||||
import org.jclouds.rest.annotations.Delegate;
|
||||
|
|
|
@ -21,8 +21,6 @@ package org.jclouds.ec2;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
import org.jclouds.ec2.features.WindowsApi;
|
||||
import org.jclouds.ec2.services.AMIClient;
|
||||
|
@ -33,6 +31,7 @@ import org.jclouds.ec2.services.InstanceClient;
|
|||
import org.jclouds.ec2.services.KeyPairClient;
|
||||
import org.jclouds.ec2.services.SecurityGroupClient;
|
||||
import org.jclouds.ec2.services.WindowsClient;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.location.Region;
|
||||
import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
|
||||
import org.jclouds.rest.annotations.Delegate;
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.security.KeyFactory;
|
|||
import java.security.PrivateKey;
|
||||
import java.security.spec.KeySpec;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.inject.Inject;
|
||||
|
||||
|
@ -32,6 +31,7 @@ import org.jclouds.crypto.Pems;
|
|||
import org.jclouds.domain.LoginCredentials;
|
||||
import org.jclouds.ec2.compute.domain.PasswordDataAndPrivateKey;
|
||||
import org.jclouds.encryption.internal.Base64;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Throwables;
|
||||
|
|
|
@ -31,7 +31,6 @@ import java.util.NoSuchElementException;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
|
@ -96,7 +95,7 @@ public class ImageToOperatingSystem implements Function<Image, OperatingSystem>
|
|||
try {
|
||||
osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() {
|
||||
@Override
|
||||
public boolean apply(@Nullable OsFamily osFamily) {
|
||||
public boolean apply(OsFamily osFamily) {
|
||||
return any(imageNameParts, equalTo(osFamily.name().toLowerCase()));
|
||||
}
|
||||
});
|
||||
|
|
|
@ -26,8 +26,6 @@ import java.util.Arrays;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.compute.domain.OperatingSystem;
|
||||
import org.jclouds.compute.domain.OsFamily;
|
||||
import org.jclouds.openstack.nova.v2_0.domain.Image;
|
||||
|
@ -69,7 +67,7 @@ public class ImageToOperatingSystemTest {
|
|||
return Iterables.toArray(
|
||||
Iterables.transform(Arrays.asList(OsFamily.values()), new Function<OsFamily, Object[]>() {
|
||||
@Override
|
||||
public Object[] apply(@Nullable OsFamily osFamily) {
|
||||
public Object[] apply(OsFamily osFamily) {
|
||||
return new Object[] { osFamily };
|
||||
}
|
||||
}), Object[].class);
|
||||
|
|
|
@ -36,7 +36,6 @@ import java.util.concurrent.Executors;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.apis.BaseViewLiveTest;
|
||||
|
@ -48,6 +47,7 @@ import org.jclouds.blobstore.domain.StorageMetadata;
|
|||
import org.jclouds.blobstore.domain.StorageType;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.testng.ITestContext;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
|
|
|
@ -27,12 +27,11 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.blobstore.BlobStore;
|
||||
import org.jclouds.blobstore.domain.BlobMetadata;
|
||||
import org.jclouds.blobstore.domain.StorageMetadata;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.util.Strings2;
|
||||
import org.testng.SkipException;
|
||||
import org.testng.annotations.Test;
|
||||
|
|
|
@ -21,13 +21,12 @@ package org.jclouds.elb;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
import org.jclouds.elb.features.AvailabilityZoneApi;
|
||||
import org.jclouds.elb.features.InstanceApi;
|
||||
import org.jclouds.elb.features.LoadBalancerApi;
|
||||
import org.jclouds.elb.features.PolicyApi;
|
||||
import org.jclouds.elb.features.AvailabilityZoneApi;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.location.Region;
|
||||
import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
|
||||
import org.jclouds.rest.annotations.Delegate;
|
||||
|
|
|
@ -20,13 +20,12 @@ package org.jclouds.elb;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.aws.filters.FormSigner;
|
||||
import org.jclouds.elb.features.AvailabilityZoneAsyncApi;
|
||||
import org.jclouds.elb.features.InstanceAsyncApi;
|
||||
import org.jclouds.elb.features.LoadBalancerAsyncApi;
|
||||
import org.jclouds.elb.features.PolicyAsyncApi;
|
||||
import org.jclouds.elb.features.AvailabilityZoneAsyncApi;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.location.Region;
|
||||
import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
|
||||
import org.jclouds.rest.annotations.Delegate;
|
||||
|
|
|
@ -23,8 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
@ -135,7 +133,7 @@ public class PolicyType {
|
|||
return Maps.uniqueIndex(attributeMetadata, new Function<AttributeMetadata<?>, String>(){
|
||||
|
||||
@Override
|
||||
public String apply(@Nullable AttributeMetadata<?> input) {
|
||||
public String apply(AttributeMetadata<?> input) {
|
||||
return input.getName();
|
||||
}
|
||||
|
||||
|
|
|
@ -22,8 +22,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.elb.domain.AttributeMetadata;
|
||||
import org.jclouds.elb.domain.Policy;
|
||||
import org.jclouds.elb.domain.PolicyType;
|
||||
|
@ -95,7 +93,7 @@ public class PolicyApiLiveTest extends BaseELBApiLiveTest {
|
|||
Iterable<String> names = Iterables.transform(response, new Function<PolicyType, String>() {
|
||||
|
||||
@Override
|
||||
public String apply(@Nullable PolicyType input) {
|
||||
public String apply(PolicyType input) {
|
||||
return input.getName();
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
|
||||
package org.jclouds.nodepool.config;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.apis.ApiMetadata;
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.config.JCloudsNativeComputeServiceAdapterContextModule;
|
||||
|
@ -30,6 +28,7 @@ import org.jclouds.compute.domain.NodeMetadata;
|
|||
import org.jclouds.compute.domain.Template;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.domain.LoginCredentials;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.nodepool.NodePoolApiMetadata;
|
||||
import org.jclouds.nodepool.NodePoolComputeServiceAdapter;
|
||||
import org.jclouds.nodepool.NodePoolComputeServiceContext;
|
||||
|
|
|
@ -21,9 +21,8 @@ package org.jclouds.rds;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.location.Region;
|
||||
import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
|
||||
import org.jclouds.rds.features.InstanceApi;
|
||||
|
|
|
@ -20,9 +20,8 @@ package org.jclouds.rds;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.aws.filters.FormSigner;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.location.Region;
|
||||
import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
|
||||
import org.jclouds.rds.features.InstanceAsyncApi;
|
||||
|
|
|
@ -26,8 +26,6 @@ import static org.testng.Assert.assertTrue;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.collect.IterableWithMarker;
|
||||
import org.jclouds.predicates.InetSocketAddressConnect;
|
||||
import org.jclouds.predicates.RetryablePredicate;
|
||||
|
@ -95,7 +93,7 @@ public class InstanceApiLiveTest extends BaseRDSApiLiveTest {
|
|||
return Iterables.all(sgApi().get(input.getName()).getIPRanges(), new Predicate<Authorization>() {
|
||||
|
||||
@Override
|
||||
public boolean apply(@Nullable Authorization i2) {
|
||||
public boolean apply(Authorization i2) {
|
||||
return i2.getStatus() == Status.AUTHORIZED;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,8 +25,6 @@ import static org.testng.Assert.assertTrue;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.collect.IterableWithMarker;
|
||||
import org.jclouds.predicates.RetryablePredicate;
|
||||
import org.jclouds.rds.domain.Authorization;
|
||||
|
@ -65,7 +63,7 @@ public class SecurityGroupApiLiveTest extends BaseRDSApiLiveTest {
|
|||
return Iterables.all(api().get(input.getName()).getIPRanges(), new Predicate<Authorization>() {
|
||||
|
||||
@Override
|
||||
public boolean apply(@Nullable Authorization i2) {
|
||||
public boolean apply(Authorization i2) {
|
||||
return i2.getStatus() == Status.AUTHORIZED;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,10 +9,10 @@ import java.util.UUID;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.domain.LoginCredentials;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.location.Provider;
|
||||
import org.jclouds.rest.annotations.Credential;
|
||||
import org.jclouds.rest.annotations.Identity;
|
||||
|
|
|
@ -24,8 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.virtualbox_4_1.NATProtocol;
|
||||
import org.virtualbox_4_1.NetworkAttachmentType;
|
||||
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
|
||||
package org.jclouds.virtualbox.functions;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.virtualbox_4_1.IMachine;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
@ -37,7 +35,7 @@ public class ApplyMemoryToMachine implements Function<IMachine, Object> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object apply(@Nullable IMachine machine) {
|
||||
public Object apply(IMachine machine) {
|
||||
machine.setMemorySize(memorySize);
|
||||
machine.saveSettings();
|
||||
return null;
|
||||
|
|
|
@ -21,8 +21,6 @@ package org.jclouds.virtualbox.functions;
|
|||
import static org.virtualbox_4_1.NetworkAdapterType.Am79C973;
|
||||
import static org.virtualbox_4_1.NetworkAttachmentType.Bridged;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.virtualbox.domain.NetworkInterfaceCard;
|
||||
import org.virtualbox_4_1.IMachine;
|
||||
import org.virtualbox_4_1.INetworkAdapter;
|
||||
|
@ -42,7 +40,7 @@ public class AttachBridgedAdapterToMachine implements Function<IMachine, Void> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Void apply(@Nullable IMachine machine) {
|
||||
public Void apply(IMachine machine) {
|
||||
INetworkAdapter iNetworkAdapter = machine.getNetworkAdapter(networkInterfaceCard.getSlot());
|
||||
iNetworkAdapter.setAttachmentType(Bridged);
|
||||
iNetworkAdapter.setAdapterType(Am79C973);
|
||||
|
|
|
@ -21,8 +21,6 @@ package org.jclouds.virtualbox.functions;
|
|||
import static org.virtualbox_4_1.NetworkAdapterType.Am79C973;
|
||||
import static org.virtualbox_4_1.NetworkAttachmentType.HostOnly;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.virtualbox.domain.NetworkInterfaceCard;
|
||||
import org.virtualbox_4_1.IMachine;
|
||||
import org.virtualbox_4_1.INetworkAdapter;
|
||||
|
@ -41,7 +39,7 @@ public class AttachHostOnlyAdapter implements Function<IMachine, Void> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Void apply(@Nullable IMachine machine) {
|
||||
public Void apply(IMachine machine) {
|
||||
INetworkAdapter iNetworkAdapter = machine.getNetworkAdapter(networkInterfaceCard.getSlot());
|
||||
iNetworkAdapter.setAttachmentType(HostOnly);
|
||||
iNetworkAdapter.setAdapterType(Am79C973);
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
|
||||
package org.jclouds.virtualbox.functions;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.virtualbox.domain.DeviceDetails;
|
||||
import org.virtualbox_4_1.IMachine;
|
||||
import org.virtualbox_4_1.IMedium;
|
||||
|
@ -44,7 +42,7 @@ public class AttachMediumToMachineIfNotAlreadyAttached implements Function<IMach
|
|||
}
|
||||
|
||||
@Override
|
||||
public Void apply(@Nullable IMachine machine) {
|
||||
public Void apply(IMachine machine) {
|
||||
try {
|
||||
machine.attachDevice(controllerName, device.getPort(), device.getDeviceSlot(), device.getDeviceType(), medium);
|
||||
machine.saveSettings();
|
||||
|
|
|
@ -21,8 +21,6 @@ package org.jclouds.virtualbox.functions;
|
|||
|
||||
import static org.virtualbox_4_1.NetworkAttachmentType.NAT;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.virtualbox.domain.NetworkInterfaceCard;
|
||||
import org.jclouds.virtualbox.domain.RedirectRule;
|
||||
import org.virtualbox_4_1.IMachine;
|
||||
|
@ -43,7 +41,7 @@ public class AttachNATAdapterToMachineIfNotAlreadyExists implements Function<IMa
|
|||
}
|
||||
|
||||
@Override
|
||||
public Void apply(@Nullable IMachine machine) {
|
||||
public Void apply(IMachine machine) {
|
||||
INetworkAdapter iNetworkAdapter = machine.getNetworkAdapter(networkInterfaceCard.getSlot());
|
||||
iNetworkAdapter.setAttachmentType(NAT);
|
||||
for (RedirectRule rule : networkInterfaceCard.getNetworkAdapter().getRedirectRules()) {
|
||||
|
|
|
@ -20,8 +20,6 @@ package org.jclouds.virtualbox.functions;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.virtualbox.domain.NetworkInterfaceCard;
|
||||
import org.jclouds.virtualbox.util.MachineUtils;
|
||||
import org.virtualbox_4_1.NetworkAttachmentType;
|
||||
|
@ -42,7 +40,7 @@ public class AttachNicToMachine implements Function<NetworkInterfaceCard, Void>
|
|||
}
|
||||
|
||||
@Override
|
||||
public Void apply(@Nullable NetworkInterfaceCard nic) {
|
||||
public Void apply(NetworkInterfaceCard nic) {
|
||||
if (hasNatAdapter(nic)) {
|
||||
return machineUtils.writeLockMachineAndApply(vmName, new AttachNATAdapterToMachineIfNotAlreadyExists(nic));
|
||||
} else if (hasBridgedAdapter(nic)) {
|
||||
|
|
|
@ -25,7 +25,6 @@ import static org.jclouds.virtualbox.util.MachineUtils.machineNotFoundException;
|
|||
import java.io.File;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
@ -78,7 +77,7 @@ public class CreateAndRegisterMachineFromIsoIfNotAlreadyExists implements Functi
|
|||
}
|
||||
|
||||
@Override
|
||||
public IMachine apply(@Nullable MasterSpec launchSpecification) {
|
||||
public IMachine apply(MasterSpec launchSpecification) {
|
||||
final IVirtualBox vBox = manager.get().getVBox();
|
||||
String vmName = launchSpecification.getVmSpec().getVmName();
|
||||
String vmId = launchSpecification.getVmSpec().getVmId();
|
||||
|
|
|
@ -22,7 +22,6 @@ package org.jclouds.virtualbox.functions;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
|
@ -62,7 +61,7 @@ public class CreateMediumIfNotAlreadyExists implements Function<HardDisk, IMediu
|
|||
public static final Pattern ATTACHED_PATTERN = Pattern.compile(".*is still attached.*: ([-0-9a-f]+) .*");
|
||||
|
||||
@Override
|
||||
public IMedium apply(@Nullable HardDisk hardDisk) {
|
||||
public IMedium apply(HardDisk hardDisk) {
|
||||
IVirtualBox vBox = manager.get().getVBox();
|
||||
try {
|
||||
String diskPath = hardDisk.getDiskPath();
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
*/
|
||||
package org.jclouds.virtualbox.functions;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.virtualbox_4_1.IMachine;
|
||||
import org.virtualbox_4_1.VBoxException;
|
||||
|
||||
|
@ -42,7 +40,7 @@ public class DetachDistroMediumFromMachine implements Function<IMachine, Void> {
|
|||
|
||||
//TODO: should this be a function on HardDisk?
|
||||
@Override
|
||||
public Void apply(@Nullable IMachine machine) {
|
||||
public Void apply(IMachine machine) {
|
||||
try {
|
||||
machine.detachDevice(controller, port, deviceSlot);
|
||||
machine.saveSettings();
|
||||
|
|
|
@ -21,8 +21,6 @@ package org.jclouds.virtualbox.functions;
|
|||
|
||||
import static org.jclouds.compute.options.RunScriptOptions.Builder.runAsRoot;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.compute.ComputeService;
|
||||
import org.jclouds.compute.domain.ExecResponse;
|
||||
import org.jclouds.compute.options.RunScriptOptions;
|
||||
|
@ -49,7 +47,7 @@ public class IMachineToIpAddress implements Function<IMachine, String> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String apply(@Nullable IMachine machine) {
|
||||
public String apply(IMachine machine) {
|
||||
|
||||
String macAddress = machine.getNetworkAdapter(0l).getMACAddress();
|
||||
int offset = 0, step = 2;
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.jclouds.virtualbox.functions;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Named;
|
||||
|
||||
|
@ -53,7 +52,7 @@ public class IMachineToVmSpec implements Function<IMachine, VmSpec> {
|
|||
protected Logger logger = Logger.NULL;
|
||||
|
||||
@Override
|
||||
public VmSpec apply(@Nullable IMachine machine) {
|
||||
public VmSpec apply(IMachine machine) {
|
||||
List<StorageController> controllers = buildControllers(machine);
|
||||
|
||||
// TODO some parameters are predefined cause the IMachine doesn't have the
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.jclouds.virtualbox.functions;
|
|||
|
||||
import static com.google.common.base.Throwables.propagate;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Named;
|
||||
|
||||
|
@ -70,7 +69,7 @@ public class LaunchMachineIfNotAlreadyRunning implements Function<IMachine, ISes
|
|||
}
|
||||
|
||||
@Override
|
||||
public ISession apply(@Nullable IMachine machine) {
|
||||
public ISession apply(IMachine machine) {
|
||||
ISession session = manager.getSessionObject();
|
||||
try {
|
||||
final IProgress progress = machine
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
|
||||
package org.jclouds.virtualbox.functions;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.virtualbox_4_1.IMachine;
|
||||
import org.virtualbox_4_1.IProgress;
|
||||
|
@ -52,7 +50,7 @@ public class TakeSnapshotIfNotAlreadyAttached implements Function<IMachine, ISna
|
|||
}
|
||||
|
||||
@Override
|
||||
public ISnapshot apply(@Nullable IMachine machine) {
|
||||
public ISnapshot apply(IMachine machine) {
|
||||
// Snapshot a machine
|
||||
ISession session = null;
|
||||
ISnapshot snap = machine.getCurrentSnapshot();
|
||||
|
|
|
@ -25,7 +25,6 @@ import static org.jclouds.compute.options.RunScriptOptions.Builder.runAsRoot;
|
|||
|
||||
import java.net.URI;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
@ -36,8 +35,6 @@ import org.jclouds.compute.domain.NodeMetadata;
|
|||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||
import org.jclouds.location.Provider;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.rest.annotations.Credential;
|
||||
import org.jclouds.rest.annotations.Identity;
|
||||
import org.jclouds.scriptbuilder.domain.Statements;
|
||||
import org.jclouds.virtualbox.predicates.RetryIfSocketNotYetOpen;
|
||||
import org.virtualbox_4_1.SessionState;
|
||||
|
@ -65,8 +62,7 @@ public class StartVBoxIfNotAlreadyRunning implements Supplier<VirtualBoxManager>
|
|||
@Inject
|
||||
public StartVBoxIfNotAlreadyRunning(Function<Supplier<NodeMetadata>, VirtualBoxManager> managerForNode,
|
||||
Factory runScriptOnNodeFactory, RetryIfSocketNotYetOpen socketTester, Supplier<NodeMetadata> host,
|
||||
@Provider Supplier<URI> providerSupplier, @Nullable @Identity String identity,
|
||||
@Nullable @Credential String credential) {
|
||||
@Provider Supplier<URI> providerSupplier) {
|
||||
this.runScriptOnNodeFactory = checkNotNull(runScriptOnNodeFactory, "runScriptOnNodeFactory");
|
||||
this.socketTester = checkNotNull(socketTester, "socketTester");
|
||||
this.socketTester.seconds(3L);
|
||||
|
|
|
@ -27,8 +27,6 @@ import static org.jclouds.virtualbox.predicates.IMediumPredicates.machineIdsCont
|
|||
import static org.jclouds.virtualbox.util.IMediumAttachments.toMedium;
|
||||
import static org.virtualbox_4_1.DeviceType.HardDisk;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.virtualbox_4_1.IMachine;
|
||||
import org.virtualbox_4_1.IMedium;
|
||||
|
||||
|
@ -48,7 +46,7 @@ public class IMachinePredicates {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean apply(@Nullable IMachine machine) {
|
||||
public boolean apply(IMachine machine) {
|
||||
Iterable<IMedium> mediumsOnMachine = transform(machine.getMediumAttachments(), toMedium());
|
||||
// TODO: previous impl walked the parent medium back to the child
|
||||
// before checking machine ids. Determine if that extra walk was really
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.jclouds.virtualbox.predicates;
|
|||
|
||||
import static org.jclouds.compute.options.RunScriptOptions.Builder.wrapInInitScript;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Named;
|
||||
|
||||
|
@ -48,7 +47,7 @@ public class SshAvailable implements Predicate<String> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(@Nullable String nodeId) {
|
||||
public boolean apply(String nodeId) {
|
||||
boolean sshDaemonIsRunning = false;
|
||||
try {
|
||||
if (context.getComputeService()
|
||||
|
|
|
@ -56,8 +56,6 @@ public class StartVBoxIfNotAlreadyRunningLiveTest {
|
|||
RetryIfSocketNotYetOpen client = createMock(RetryIfSocketNotYetOpen.class);
|
||||
NodeMetadata host = new NodeMetadataBuilder().id("host").status(Status.RUNNING).build();
|
||||
URI provider = URI.create("http://localhost:18083/");
|
||||
String identity = "adminstrator";
|
||||
String credential = "12345";
|
||||
expect(client.seconds(3)).andReturn(client);
|
||||
expect(client.apply(HostAndPort.fromParts(provider.getHost(), provider.getPort()))).andReturn(true).anyTimes();
|
||||
manager.connect(provider.toASCIIString(), "", "");
|
||||
|
@ -66,7 +64,7 @@ public class StartVBoxIfNotAlreadyRunningLiveTest {
|
|||
replay(manager, runScriptOnNodeFactory, client);
|
||||
|
||||
new StartVBoxIfNotAlreadyRunning((Function) Functions.constant(manager), runScriptOnNodeFactory, client,
|
||||
Suppliers.ofInstance(host), Suppliers.ofInstance(provider), identity, credential).start();
|
||||
Suppliers.ofInstance(host), Suppliers.ofInstance(provider)).start();
|
||||
|
||||
verify(manager, runScriptOnNodeFactory, client);
|
||||
|
||||
|
@ -83,8 +81,6 @@ public class StartVBoxIfNotAlreadyRunningLiveTest {
|
|||
NodeMetadata host = new NodeMetadataBuilder().id("host").status(Status.RUNNING).operatingSystem(
|
||||
OperatingSystem.builder().description("unix").build()).build();
|
||||
URI provider = URI.create("http://localhost:18083/");
|
||||
String identity = "adminstrator";
|
||||
String credential = "12345";
|
||||
|
||||
expect(client.seconds(3)).andReturn(client);
|
||||
expect(client.apply(HostAndPort.fromParts(provider.getHost(), provider.getPort()))).andReturn(false).once().andReturn(true).once();
|
||||
|
@ -106,7 +102,7 @@ public class StartVBoxIfNotAlreadyRunningLiveTest {
|
|||
|
||||
replay(manager, runScriptOnNodeFactory, runScriptOnNode, client);
|
||||
new StartVBoxIfNotAlreadyRunning((Function) Functions.constant(manager), runScriptOnNodeFactory, client,
|
||||
Suppliers.ofInstance(host), Suppliers.ofInstance(provider), identity, credential);
|
||||
Suppliers.ofInstance(host), Suppliers.ofInstance(provider));
|
||||
verify(manager, runScriptOnNodeFactory, runScriptOnNode, client);
|
||||
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.scriptbuilder.domain.GitRepoAndRef;
|
||||
import org.jclouds.scriptbuilder.domain.OsFamily;
|
||||
import org.jclouds.scriptbuilder.domain.Statement;
|
||||
import org.jclouds.scriptbuilder.domain.Statements;
|
||||
|
@ -33,9 +34,10 @@ import com.google.common.collect.ImmutableSet;
|
|||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
* Clones a repository into a newly created directory, creates remote-tracking branches for each
|
||||
* branch in the cloned repository (visible using git branch -r), and creates and checks out an
|
||||
* initial branch that is forked from the cloned repository's currently active branch. PWD is set to
|
||||
* Clones a gitRepoAndRef into a newly created directory, creates
|
||||
* remote-tracking branches for each branch in the cloned gitRepoAndRef (visible
|
||||
* using git branch -r), and creates and checks out an initial branch that is
|
||||
* forked from the cloned gitRepoAndRef's currently active branch. PWD is set to
|
||||
* the directory being checked out.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
|
@ -52,39 +54,45 @@ public class CloneGitRepo implements Statement {
|
|||
|
||||
public static class Builder {
|
||||
|
||||
protected URI repository;
|
||||
protected Optional<String> branch = Optional.absent();
|
||||
protected Optional<String> tag = Optional.absent();
|
||||
protected GitRepoAndRef.Builder gitRepoAndRef = GitRepoAndRef.builder();
|
||||
protected Optional<String> directory = Optional.absent();
|
||||
|
||||
/**
|
||||
* @see CloneGitRepo#getRepository()
|
||||
* @see GitRepoAndRef#getRepository()
|
||||
*/
|
||||
public Builder repository(URI repository) {
|
||||
this.repository = repository;
|
||||
this.gitRepoAndRef.repository(repository);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see CloneGitRepo#getRepository()
|
||||
* @see GitRepoAndRef#getRepository()
|
||||
*/
|
||||
public Builder repository(String repository) {
|
||||
return repository(URI.create(repository));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see CloneGitRepo#getBranch()
|
||||
* @see GitRepoAndRef#getBranch()
|
||||
*/
|
||||
public Builder branch(String branch) {
|
||||
this.branch = Optional.fromNullable(branch);
|
||||
this.gitRepoAndRef.branch(branch);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see CloneGitRepo#getTag()
|
||||
* @see GitRepoAndRef#getTag()
|
||||
*/
|
||||
public Builder tag(String tag) {
|
||||
this.tag = Optional.fromNullable(tag);
|
||||
this.gitRepoAndRef.tag(tag);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see CloneGitRepo#getGitRepoAndRef()
|
||||
*/
|
||||
public Builder gitRepoAndRef(GitRepoAndRef gitRepoAndRef) {
|
||||
this.gitRepoAndRef.fromGitRepoAndRef(gitRepoAndRef);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -97,54 +105,33 @@ public class CloneGitRepo implements Statement {
|
|||
}
|
||||
|
||||
public CloneGitRepo build() {
|
||||
return new CloneGitRepo(repository, branch, tag, directory);
|
||||
return new CloneGitRepo(gitRepoAndRef.build(), directory);
|
||||
}
|
||||
|
||||
public Builder fromCloneGitRepo(CloneGitRepo in) {
|
||||
return this.repository(in.getRepository()).branch(in.getBranch().orNull()).tag(in.getTag().orNull())
|
||||
.directory(in.getDirectory().orNull());
|
||||
return this.gitRepoAndRef(in.getGitRepoAndRef()).directory(in.getDirectory().orNull());
|
||||
}
|
||||
}
|
||||
|
||||
protected final URI repository;
|
||||
protected final Optional<String> branch;
|
||||
protected final Optional<String> tag;
|
||||
protected final GitRepoAndRef gitRepoAndRef;
|
||||
protected final Optional<String> directory;
|
||||
|
||||
protected CloneGitRepo(URI repository, Optional<String> branch, Optional<String> tag, Optional<String> directory) {
|
||||
this.repository = checkNotNull(repository, "repository");
|
||||
this.branch = checkNotNull(branch, "branch");
|
||||
this.tag = checkNotNull(tag, "tag");
|
||||
protected CloneGitRepo(GitRepoAndRef gitRepoAndRef, Optional<String> directory) {
|
||||
this.gitRepoAndRef = checkNotNull(gitRepoAndRef, "gitRepoAndRef");
|
||||
this.directory = checkNotNull(directory, "directory");
|
||||
}
|
||||
|
||||
/**
|
||||
* The (possibly remote) repository to clone from.
|
||||
* The coordinates to checkout
|
||||
*/
|
||||
public URI getRepository() {
|
||||
return repository;
|
||||
public GitRepoAndRef getGitRepoAndRef() {
|
||||
return gitRepoAndRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instead of pointing the newly created HEAD to the branch pointed to by the cloned repository's
|
||||
* HEAD, point to this branch instead. In a non-bare repository, this is the branch that will be
|
||||
* checked out.
|
||||
*/
|
||||
public Optional<String> getBranch() {
|
||||
return branch;
|
||||
}
|
||||
|
||||
/**
|
||||
* checkout the following tag on the branch
|
||||
*/
|
||||
public Optional<String> getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of a new directory to clone into. The "humanish" part of the source repository is
|
||||
* used if no directory is explicitly given (repo for /path/to/repo.git and foo for
|
||||
* host.xz:foo/.git).
|
||||
* The name of a new directory to clone into. The "humanish" part of the
|
||||
* source gitRepoAndRef is used if no directory is explicitly given (repo for
|
||||
* /path/to/repo.git and foo for host.xz:foo/.git).
|
||||
*/
|
||||
public Optional<String> getDirectory() {
|
||||
return directory;
|
||||
|
@ -155,7 +142,7 @@ public class CloneGitRepo implements Statement {
|
|||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(repository, branch, tag, directory);
|
||||
return Objects.hashCode(gitRepoAndRef, directory);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -170,8 +157,7 @@ public class CloneGitRepo implements Statement {
|
|||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
CloneGitRepo other = CloneGitRepo.class.cast(obj);
|
||||
return Objects.equal(this.repository, other.repository) && Objects.equal(this.branch, other.branch)
|
||||
&& Objects.equal(this.tag, other.tag) && Objects.equal(this.directory, other.directory);
|
||||
return Objects.equal(this.gitRepoAndRef, other.gitRepoAndRef) && Objects.equal(this.directory, other.directory);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -189,16 +175,16 @@ public class CloneGitRepo implements Statement {
|
|||
public String render(OsFamily arg0) {
|
||||
StringBuilder command = new StringBuilder();
|
||||
command.append("git clone");
|
||||
if (branch.isPresent())
|
||||
command.append(" -b ").append(branch.get());
|
||||
command.append(' ').append(repository.toASCIIString());
|
||||
if (gitRepoAndRef.getBranch().isPresent())
|
||||
command.append(" -b ").append(gitRepoAndRef.getBranch().get());
|
||||
command.append(' ').append(gitRepoAndRef.getRepository().toASCIIString());
|
||||
if (directory.isPresent())
|
||||
command.append(' ').append(directory.get());
|
||||
command.append("{lf}");
|
||||
command.append("{cd} ").append(
|
||||
directory.or(Iterables.getLast(Splitter.on('/').split(repository.getPath())).replace(".git", "")));
|
||||
if (tag.isPresent()) {
|
||||
command.append("{lf}").append("git checkout ").append(tag.get());
|
||||
directory.or(Iterables.getLast(Splitter.on('/').split(gitRepoAndRef.getRepository().getPath())).replace(".git", "")));
|
||||
if (gitRepoAndRef.getTag().isPresent()) {
|
||||
command.append("{lf}").append("git checkout ").append(gitRepoAndRef.getTag().get());
|
||||
}
|
||||
return Statements.exec(command.toString()).render(arg0);
|
||||
}
|
||||
|
@ -208,8 +194,8 @@ public class CloneGitRepo implements Statement {
|
|||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper(this).omitNullValues().add("repository", repository).add("branch", branch.orNull())
|
||||
.add("tag", tag.orNull()).add("directory", directory.orNull()).toString();
|
||||
return Objects.toStringHelper(this).omitNullValues().add("gitRepoAndRef", gitRepoAndRef)
|
||||
.add("directory", directory.orNull()).toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue