Class AbstractAzResource<T extends AbstractAzResource<T,P,R>,P extends AzResource,R>
- java.lang.Object
-
- com.microsoft.azure.toolkit.lib.common.model.AbstractAzResource<T,P,R>
-
- All Implemented Interfaces:
AzComponent,AzResource,Refreshable
- Direct Known Subclasses:
AbstractAzServiceSubscription,AbstractEmulatableAzResource,AzResource.None,GenericResource,ResourceDeployment,ResourceGroup
public abstract class AbstractAzResource<T extends AbstractAzResource<T,P,R>,P extends AzResource,R> extends Object implements AzResource
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.microsoft.azure.toolkit.lib.common.model.AzResource
AzResource.Draft<T extends AzResource,R>, AzResource.FormalStatus, AzResource.None, AzResource.Status
-
-
Field Summary
Fields Modifier and Type Field Description private Cache1<R>cacheprivate DebouncerfireEventsprivate AbstractAzResourceModule<T,P,R>moduleprivate Stringnameprivate StringresourceGroupNameprivate AtomicReference<String>status-
Fields inherited from interface com.microsoft.azure.toolkit.lib.common.model.AzResource
CACHE_LIFETIME, CONNECT_RESOURCE, CREATE_RESOURCE, DEPLOY, NONE, RESOURCE_GROUP_PLACEHOLDER
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractAzResource(AbstractAzResource<T,P,R> origin)copy constructorprotectedAbstractAzResource(String name, AbstractAzResourceModule<T,P,R> module)constructor for non-top resource only.protectedAbstractAzResource(String name, String resourceGroupName, AbstractAzResourceModule<T,P,R> module)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private <D> Dcast(Object origin)voiddelete()private voiddeleteFromAzure()(package private) voiddeleteFromCache()protected voiddoModify(Runnable body, String status)protected RdoModify(Callable<R> body, String status)booleanexists()private voidfireStatusChangedEvent()protected List<AbstractAzResourceModule<?,?,?>>getCachedSubModules()StringgetId()PgetParent()RgetRemote()ResourceGroupgetResourceGroup()StringgetStatus()AbstractAzResourceModule<?,?,?>getSubModule(String moduleName)abstract List<AbstractAzResourceModule<?,?,?>>getSubModules()voidinvalidateCache()static booleanis400(Throwable t)static booleanis404(Throwable t)protected booleanisAuthRequired()booleanisDraft()booleanisDraftForCreating()booleanisDraftForUpdating()static booleanisHttpException(Throwable t, int httpStatusCode)static booleanisHttpException(Throwable t, java.util.function.Predicate<com.azure.core.http.HttpResponse> predicate)protected RloadRemoteFromAzure()protected abstract StringloadStatus(R remote)protected voidonRemoteUpdated(R newRemote, R oldRemote)voidrefresh()protected Optional<R>remoteOptional()protected voidsetRemote(R remote)voidsetStatus(String status)AzResource.Draft<T,R>update()protected voidupdateAdditionalProperties(R newRemote, R oldRemote)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.microsoft.azure.toolkit.lib.common.model.AzComponent
getName
-
Methods inherited from interface com.microsoft.azure.toolkit.lib.common.model.AzResource
getFormalStatus, getFullResourceType, getModule, getPortalUrl, getResourceGroupName, getResourceTypeName, getSubscription, getSubscriptionId, id, name
-
-
-
-
Field Detail
-
module
@Nonnull private final AbstractAzResourceModule<T extends AbstractAzResource<T,P,R>,P extends AzResource,R> module
-
status
@Nonnull private final AtomicReference<String> status
-
-
Constructor Detail
-
AbstractAzResource
protected AbstractAzResource(@Nonnull String name, @Nonnull String resourceGroupName, @Nonnull AbstractAzResourceModule<T,P,R> module)
-
AbstractAzResource
protected AbstractAzResource(@Nonnull String name, @Nonnull AbstractAzResourceModule<T,P,R> module)
constructor for non-top resource only.module.getParent().getResourceGroupName()is only reliable if current resource is not root of resource hierarchy tree.
-
AbstractAzResource
protected AbstractAzResource(@Nonnull AbstractAzResource<T,P,R> origin)
copy constructor
-
-
Method Detail
-
exists
public boolean exists()
- Specified by:
existsin interfaceAzResource
-
refresh
public void refresh()
- Specified by:
refreshin interfaceAzResource- Specified by:
refreshin interfaceRefreshable
-
invalidateCache
public void invalidateCache()
-
setRemote
protected void setRemote(R remote)
-
updateAdditionalProperties
protected void updateAdditionalProperties(@Nullable R newRemote, @Nullable R oldRemote)
-
getStatus
@Nonnull public String getStatus()
- Specified by:
getStatusin interfaceAzResource
-
fireStatusChangedEvent
private void fireStatusChangedEvent()
-
delete
public void delete()
- Specified by:
deletein interfaceAzResource
-
deleteFromAzure
private void deleteFromAzure()
-
deleteFromCache
void deleteFromCache()
-
update
@Nonnull public AzResource.Draft<T,R> update()
-
getId
@Nonnull public String getId()
- Specified by:
getIdin interfaceAzComponent
-
getSubModules
@Nonnull public abstract List<AbstractAzResourceModule<?,?,?>> getSubModules()
-
getCachedSubModules
@Nonnull protected List<AbstractAzResourceModule<?,?,?>> getCachedSubModules()
-
getSubModule
@Nullable public AbstractAzResourceModule<?,?,?> getSubModule(String moduleName)
-
getResourceGroup
@Nullable public ResourceGroup getResourceGroup()
-
isDraft
public boolean isDraft()
-
isDraftForCreating
public boolean isDraftForCreating()
-
isDraftForUpdating
public boolean isDraftForUpdating()
-
isAuthRequired
protected boolean isAuthRequired()
-
is404
public static boolean is404(Throwable t)
-
is400
public static boolean is400(Throwable t)
-
isHttpException
public static boolean isHttpException(Throwable t, int httpStatusCode)
- Parameters:
httpStatusCode-HttpStatus
-
isHttpException
public static boolean isHttpException(Throwable t, java.util.function.Predicate<com.azure.core.http.HttpResponse> predicate)
-
-